2010-06-23 23:46:08 +04: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 15:12:37 +04: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 23:46:08 +04:00
|
|
|
|
|
|
|
#ifndef mozilla_dom_indexeddb_indexeddatabase_h__
|
|
|
|
#define mozilla_dom_indexeddb_indexeddatabase_h__
|
|
|
|
|
|
|
|
#include "nsIProgrammingLanguage.h"
|
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-08-20 10:43:47 +04:00
|
|
|
#include "js/StructuredClone.h"
|
2010-06-23 23:46:08 +04:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsDebug.h"
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2010-06-23 23:46:08 +04:00
|
|
|
#include "nsStringGlue.h"
|
|
|
|
#include "nsTArray.h"
|
2013-09-06 21:50:24 +04:00
|
|
|
#include "nsIInputStream.h"
|
2010-06-23 23:46:08 +04: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-16 11:34:24 +04:00
|
|
|
class nsIDOMBlob;
|
|
|
|
|
2010-12-10 05:15:00 +03:00
|
|
|
BEGIN_INDEXEDDB_NAMESPACE
|
|
|
|
|
2011-12-16 11:34:24 +04:00
|
|
|
class FileInfo;
|
2012-06-03 20:33:52 +04:00
|
|
|
class IDBDatabase;
|
|
|
|
class IDBTransaction;
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
void SwapData(T& aData1, T& aData2)
|
|
|
|
{
|
|
|
|
T temp = aData2;
|
|
|
|
aData2 = aData1;
|
|
|
|
aData1 = temp;
|
|
|
|
}
|
2011-12-16 11:34:24 +04:00
|
|
|
|
2012-08-02 10:02:29 +04: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 21:21:12 +04:00
|
|
|
struct SerializedStructuredCloneReadInfo;
|
|
|
|
|
|
|
|
struct StructuredCloneReadInfo
|
|
|
|
{
|
2012-06-03 20:33:52 +04:00
|
|
|
// In IndexedDatabaseInlines.h
|
|
|
|
inline StructuredCloneReadInfo();
|
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
void Swap(StructuredCloneReadInfo& aCloneReadInfo)
|
|
|
|
{
|
2011-12-16 11:34:24 +04:00
|
|
|
mCloneBuffer.swap(aCloneReadInfo.mCloneBuffer);
|
2012-08-02 10:02:29 +04:00
|
|
|
mFiles.SwapElements(aCloneReadInfo.mFiles);
|
2012-06-03 20:33:52 +04:00
|
|
|
SwapData(mDatabase, aCloneReadInfo.mDatabase);
|
2011-12-16 11:34:24 +04:00
|
|
|
}
|
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
// In IndexedDatabaseInlines.h
|
|
|
|
inline bool
|
|
|
|
SetFromSerialized(const SerializedStructuredCloneReadInfo& aOther);
|
|
|
|
|
2011-12-16 11:34:24 +04:00
|
|
|
JSAutoStructuredCloneBuffer mCloneBuffer;
|
2012-08-02 10:02:29 +04:00
|
|
|
nsTArray<StructuredCloneFile> mFiles;
|
2012-06-03 20:33:52 +04:00
|
|
|
IDBDatabase* mDatabase;
|
2011-12-16 11:34:24 +04:00
|
|
|
};
|
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
struct SerializedStructuredCloneReadInfo
|
|
|
|
{
|
|
|
|
SerializedStructuredCloneReadInfo()
|
2012-07-30 18:20:58 +04:00
|
|
|
: data(nullptr), dataLength(0)
|
2012-06-01 21:21:12 +04: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 20:33:52 +04:00
|
|
|
// In IndexedDatabaseInlines.h
|
|
|
|
inline StructuredCloneWriteInfo();
|
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
void Swap(StructuredCloneWriteInfo& aCloneWriteInfo)
|
|
|
|
{
|
2011-12-16 11:34:24 +04:00
|
|
|
mCloneBuffer.swap(aCloneWriteInfo.mCloneBuffer);
|
2012-06-03 20:33:52 +04:00
|
|
|
mFiles.SwapElements(aCloneWriteInfo.mFiles);
|
|
|
|
SwapData(mTransaction, aCloneWriteInfo.mTransaction);
|
|
|
|
SwapData(mOffsetToKeyProp, aCloneWriteInfo.mOffsetToKeyProp);
|
2011-12-16 11:34:24 +04:00
|
|
|
}
|
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
bool operator==(const StructuredCloneWriteInfo& aOther) const
|
|
|
|
{
|
|
|
|
return this->mCloneBuffer.nbytes() == aOther.mCloneBuffer.nbytes() &&
|
|
|
|
this->mCloneBuffer.data() == aOther.mCloneBuffer.data() &&
|
2012-06-03 20:33:52 +04:00
|
|
|
this->mFiles == aOther.mFiles &&
|
|
|
|
this->mTransaction == aOther.mTransaction &&
|
2012-06-01 21:21:12 +04:00
|
|
|
this->mOffsetToKeyProp == aOther.mOffsetToKeyProp;
|
|
|
|
}
|
|
|
|
|
|
|
|
// In IndexedDatabaseInlines.h
|
|
|
|
inline bool
|
|
|
|
SetFromSerialized(const SerializedStructuredCloneWriteInfo& aOther);
|
|
|
|
|
2011-12-16 11:34:24 +04:00
|
|
|
JSAutoStructuredCloneBuffer mCloneBuffer;
|
2012-06-03 20:33:52 +04:00
|
|
|
nsTArray<StructuredCloneFile> mFiles;
|
|
|
|
IDBTransaction* mTransaction;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t mOffsetToKeyProp;
|
2011-12-16 11:34:24 +04:00
|
|
|
};
|
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
struct SerializedStructuredCloneWriteInfo
|
2010-12-10 05:15:00 +03:00
|
|
|
{
|
2012-06-01 21:21:12 +04:00
|
|
|
SerializedStructuredCloneWriteInfo()
|
2012-07-30 18:20:58 +04:00
|
|
|
: data(nullptr), dataLength(0), offsetToKeyProp(0)
|
2012-06-01 21:21:12 +04:00
|
|
|
{ }
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const SerializedStructuredCloneWriteInfo& aOther) const
|
|
|
|
{
|
|
|
|
return this->data == aOther.data &&
|
|
|
|
this->dataLength == aOther.dataLength &&
|
|
|
|
this->offsetToKeyProp == aOther.offsetToKeyProp;
|
2010-12-10 05:15:00 +03:00
|
|
|
}
|
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
SerializedStructuredCloneWriteInfo&
|
|
|
|
operator=(const StructuredCloneWriteInfo& aOther)
|
|
|
|
{
|
|
|
|
data = aOther.mCloneBuffer.data();
|
|
|
|
dataLength = aOther.mCloneBuffer.nbytes();
|
|
|
|
offsetToKeyProp = aOther.mOffsetToKeyProp;
|
|
|
|
return *this;
|
2010-12-10 05:15:00 +03:00
|
|
|
}
|
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
// Make sure to update ipc/SerializationHelpers.h when changing members here!
|
|
|
|
uint64_t* data;
|
|
|
|
size_t dataLength;
|
|
|
|
uint64_t offsetToKeyProp;
|
|
|
|
};
|
2010-12-10 05:15:00 +03:00
|
|
|
|
|
|
|
END_INDEXEDDB_NAMESPACE
|
|
|
|
|
2010-06-23 23:46:08 +04:00
|
|
|
#endif // mozilla_dom_indexeddb_indexeddatabase_h__
|