2010-06-23 12:46:08 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-06-23 12:46:08 -07:00
|
|
|
|
|
|
|
#ifndef mozilla_dom_indexeddb_indexeddatabase_h__
|
|
|
|
#define mozilla_dom_indexeddb_indexeddatabase_h__
|
|
|
|
|
|
|
|
#include "nsIProgrammingLanguage.h"
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-08-19 23:43:47 -07:00
|
|
|
#include "js/StructuredClone.h"
|
2010-06-23 12:46:08 -07:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsDebug.h"
|
2012-07-27 07:03:27 -07:00
|
|
|
#include "nsError.h"
|
2013-09-23 10:25:00 -07:00
|
|
|
#include "nsString.h"
|
2010-06-23 12:46:08 -07:00
|
|
|
#include "nsTArray.h"
|
2013-09-06 10:50:24 -07:00
|
|
|
#include "nsIInputStream.h"
|
2010-06-23 12:46:08 -07:00
|
|
|
|
|
|
|
#define BEGIN_INDEXEDDB_NAMESPACE \
|
|
|
|
namespace mozilla { namespace dom { namespace indexedDB {
|
|
|
|
|
|
|
|
#define END_INDEXEDDB_NAMESPACE \
|
|
|
|
} /* namespace indexedDB */ } /* namepsace dom */ } /* namespace mozilla */
|
|
|
|
|
|
|
|
#define USING_INDEXEDDB_NAMESPACE \
|
|
|
|
using namespace mozilla::dom::indexedDB;
|
|
|
|
|
2011-12-15 23:34:24 -08:00
|
|
|
class nsIDOMBlob;
|
|
|
|
|
2010-12-09 18:15:00 -08:00
|
|
|
BEGIN_INDEXEDDB_NAMESPACE
|
|
|
|
|
2011-12-15 23:34:24 -08:00
|
|
|
class FileInfo;
|
2012-06-03 09:33:52 -07:00
|
|
|
class IDBDatabase;
|
|
|
|
class IDBTransaction;
|
|
|
|
|
2012-08-01 23:02:29 -07:00
|
|
|
struct StructuredCloneFile
|
|
|
|
{
|
|
|
|
bool operator==(const StructuredCloneFile& aOther) const
|
|
|
|
{
|
|
|
|
return this->mFile == aOther.mFile &&
|
|
|
|
this->mFileInfo == aOther.mFileInfo &&
|
|
|
|
this->mInputStream == aOther.mInputStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMBlob> mFile;
|
|
|
|
nsRefPtr<FileInfo> mFileInfo;
|
|
|
|
nsCOMPtr<nsIInputStream> mInputStream;
|
|
|
|
};
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
struct SerializedStructuredCloneReadInfo;
|
|
|
|
|
|
|
|
struct StructuredCloneReadInfo
|
|
|
|
{
|
2012-06-03 09:33:52 -07:00
|
|
|
// In IndexedDatabaseInlines.h
|
|
|
|
inline StructuredCloneReadInfo();
|
|
|
|
|
2014-01-31 18:50:07 -08:00
|
|
|
inline StructuredCloneReadInfo&
|
|
|
|
operator=(StructuredCloneReadInfo&& aCloneReadInfo);
|
2011-12-15 23:34:24 -08:00
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
// In IndexedDatabaseInlines.h
|
|
|
|
inline bool
|
|
|
|
SetFromSerialized(const SerializedStructuredCloneReadInfo& aOther);
|
|
|
|
|
2011-12-15 23:34:24 -08:00
|
|
|
JSAutoStructuredCloneBuffer mCloneBuffer;
|
2012-08-01 23:02:29 -07:00
|
|
|
nsTArray<StructuredCloneFile> mFiles;
|
2012-06-03 09:33:52 -07:00
|
|
|
IDBDatabase* mDatabase;
|
2011-12-15 23:34:24 -08:00
|
|
|
};
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
struct SerializedStructuredCloneReadInfo
|
|
|
|
{
|
|
|
|
SerializedStructuredCloneReadInfo()
|
2012-07-30 07:20:58 -07:00
|
|
|
: data(nullptr), dataLength(0)
|
2012-06-01 10:21:12 -07:00
|
|
|
{ }
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const SerializedStructuredCloneReadInfo& aOther) const
|
|
|
|
{
|
|
|
|
return this->data == aOther.data &&
|
|
|
|
this->dataLength == aOther.dataLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
SerializedStructuredCloneReadInfo&
|
|
|
|
operator=(const StructuredCloneReadInfo& aOther)
|
|
|
|
{
|
|
|
|
data = aOther.mCloneBuffer.data();
|
|
|
|
dataLength = aOther.mCloneBuffer.nbytes();
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure to update ipc/SerializationHelpers.h when changing members here!
|
|
|
|
uint64_t* data;
|
|
|
|
size_t dataLength;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SerializedStructuredCloneWriteInfo;
|
|
|
|
|
|
|
|
struct StructuredCloneWriteInfo
|
|
|
|
{
|
2012-06-03 09:33:52 -07:00
|
|
|
// In IndexedDatabaseInlines.h
|
|
|
|
inline StructuredCloneWriteInfo();
|
2014-01-31 18:50:07 -08:00
|
|
|
inline StructuredCloneWriteInfo(StructuredCloneWriteInfo&& aCloneWriteInfo);
|
2011-12-15 23:34:24 -08:00
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
bool operator==(const StructuredCloneWriteInfo& aOther) const
|
|
|
|
{
|
|
|
|
return this->mCloneBuffer.nbytes() == aOther.mCloneBuffer.nbytes() &&
|
|
|
|
this->mCloneBuffer.data() == aOther.mCloneBuffer.data() &&
|
2012-06-03 09:33:52 -07:00
|
|
|
this->mFiles == aOther.mFiles &&
|
|
|
|
this->mTransaction == aOther.mTransaction &&
|
2012-06-01 10:21:12 -07:00
|
|
|
this->mOffsetToKeyProp == aOther.mOffsetToKeyProp;
|
|
|
|
}
|
|
|
|
|
|
|
|
// In IndexedDatabaseInlines.h
|
|
|
|
inline bool
|
|
|
|
SetFromSerialized(const SerializedStructuredCloneWriteInfo& aOther);
|
|
|
|
|
2011-12-15 23:34:24 -08:00
|
|
|
JSAutoStructuredCloneBuffer mCloneBuffer;
|
2012-06-03 09:33:52 -07:00
|
|
|
nsTArray<StructuredCloneFile> mFiles;
|
|
|
|
IDBTransaction* mTransaction;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t mOffsetToKeyProp;
|
2011-12-15 23:34:24 -08:00
|
|
|
};
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
struct SerializedStructuredCloneWriteInfo
|
2010-12-09 18:15:00 -08:00
|
|
|
{
|
2012-06-01 10:21:12 -07:00
|
|
|
SerializedStructuredCloneWriteInfo()
|
2012-07-30 07:20:58 -07:00
|
|
|
: data(nullptr), dataLength(0), offsetToKeyProp(0)
|
2012-06-01 10:21:12 -07:00
|
|
|
{ }
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const SerializedStructuredCloneWriteInfo& aOther) const
|
|
|
|
{
|
|
|
|
return this->data == aOther.data &&
|
|
|
|
this->dataLength == aOther.dataLength &&
|
|
|
|
this->offsetToKeyProp == aOther.offsetToKeyProp;
|
2010-12-09 18:15:00 -08:00
|
|
|
}
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
SerializedStructuredCloneWriteInfo&
|
|
|
|
operator=(const StructuredCloneWriteInfo& aOther)
|
|
|
|
{
|
|
|
|
data = aOther.mCloneBuffer.data();
|
|
|
|
dataLength = aOther.mCloneBuffer.nbytes();
|
|
|
|
offsetToKeyProp = aOther.mOffsetToKeyProp;
|
|
|
|
return *this;
|
2010-12-09 18:15:00 -08:00
|
|
|
}
|
|
|
|
|
2012-06-01 10:21:12 -07:00
|
|
|
// Make sure to update ipc/SerializationHelpers.h when changing members here!
|
|
|
|
uint64_t* data;
|
|
|
|
size_t dataLength;
|
|
|
|
uint64_t offsetToKeyProp;
|
|
|
|
};
|
2010-12-09 18:15:00 -08:00
|
|
|
|
|
|
|
END_INDEXEDDB_NAMESPACE
|
|
|
|
|
2010-06-23 12:46:08 -07:00
|
|
|
#endif // mozilla_dom_indexeddb_indexeddatabase_h__
|