2010-06-23 19:46:08 +00: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 11:12:37 +00: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 19:46:08 +00:00
|
|
|
|
|
|
|
#ifndef mozilla_dom_indexeddb_indexeddatabase_h__
|
|
|
|
#define mozilla_dom_indexeddb_indexeddatabase_h__
|
|
|
|
|
|
|
|
#include "nsIProgrammingLanguage.h"
|
|
|
|
|
2012-06-01 17:21:12 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2010-08-26 20:57:25 +00:00
|
|
|
#include "jsapi.h"
|
2010-06-23 19:46:08 +00:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsDebug.h"
|
2012-07-27 14:03:27 +00:00
|
|
|
#include "nsError.h"
|
2010-06-23 19:46:08 +00:00
|
|
|
#include "nsStringGlue.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
|
|
|
|
#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 07:34:24 +00:00
|
|
|
class nsIDOMBlob;
|
2012-06-03 16:33:52 +00:00
|
|
|
class nsIInputStream;
|
2011-12-16 07:34:24 +00:00
|
|
|
|
2010-12-10 02:15:00 +00:00
|
|
|
BEGIN_INDEXEDDB_NAMESPACE
|
|
|
|
|
2011-12-16 07:34:24 +00:00
|
|
|
class FileInfo;
|
2012-06-03 16:33:52 +00:00
|
|
|
class IDBDatabase;
|
|
|
|
class IDBTransaction;
|
|
|
|
|
2012-08-01 21:09:23 +00:00
|
|
|
enum FactoryPrivilege {
|
|
|
|
Content,
|
|
|
|
Chrome
|
|
|
|
};
|
|
|
|
|
2012-06-03 16:33:52 +00:00
|
|
|
template <class T>
|
|
|
|
void SwapData(T& aData1, T& aData2)
|
|
|
|
{
|
|
|
|
T temp = aData2;
|
|
|
|
aData2 = aData1;
|
|
|
|
aData1 = temp;
|
|
|
|
}
|
2011-12-16 07:34:24 +00:00
|
|
|
|
2012-08-02 06:02:29 +00: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 17:21:12 +00:00
|
|
|
struct SerializedStructuredCloneReadInfo;
|
|
|
|
|
|
|
|
struct StructuredCloneReadInfo
|
|
|
|
{
|
2012-06-03 16:33:52 +00:00
|
|
|
// In IndexedDatabaseInlines.h
|
|
|
|
inline StructuredCloneReadInfo();
|
|
|
|
|
2012-06-01 17:21:12 +00:00
|
|
|
void Swap(StructuredCloneReadInfo& aCloneReadInfo)
|
|
|
|
{
|
2011-12-16 07:34:24 +00:00
|
|
|
mCloneBuffer.swap(aCloneReadInfo.mCloneBuffer);
|
2012-08-02 06:02:29 +00:00
|
|
|
mFiles.SwapElements(aCloneReadInfo.mFiles);
|
2012-06-03 16:33:52 +00:00
|
|
|
SwapData(mDatabase, aCloneReadInfo.mDatabase);
|
2011-12-16 07:34:24 +00:00
|
|
|
}
|
|
|
|
|
2012-06-01 17:21:12 +00:00
|
|
|
// In IndexedDatabaseInlines.h
|
|
|
|
inline bool
|
|
|
|
SetFromSerialized(const SerializedStructuredCloneReadInfo& aOther);
|
|
|
|
|
2011-12-16 07:34:24 +00:00
|
|
|
JSAutoStructuredCloneBuffer mCloneBuffer;
|
2012-08-02 06:02:29 +00:00
|
|
|
nsTArray<StructuredCloneFile> mFiles;
|
2012-06-03 16:33:52 +00:00
|
|
|
IDBDatabase* mDatabase;
|
2011-12-16 07:34:24 +00:00
|
|
|
};
|
|
|
|
|
2012-06-01 17:21:12 +00:00
|
|
|
struct SerializedStructuredCloneReadInfo
|
|
|
|
{
|
|
|
|
SerializedStructuredCloneReadInfo()
|
2012-07-30 14:20:58 +00:00
|
|
|
: data(nullptr), dataLength(0)
|
2012-06-01 17:21:12 +00: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 16:33:52 +00:00
|
|
|
// In IndexedDatabaseInlines.h
|
|
|
|
inline StructuredCloneWriteInfo();
|
|
|
|
|
2012-06-01 17:21:12 +00:00
|
|
|
void Swap(StructuredCloneWriteInfo& aCloneWriteInfo)
|
|
|
|
{
|
2011-12-16 07:34:24 +00:00
|
|
|
mCloneBuffer.swap(aCloneWriteInfo.mCloneBuffer);
|
2012-06-03 16:33:52 +00:00
|
|
|
mFiles.SwapElements(aCloneWriteInfo.mFiles);
|
|
|
|
SwapData(mTransaction, aCloneWriteInfo.mTransaction);
|
|
|
|
SwapData(mOffsetToKeyProp, aCloneWriteInfo.mOffsetToKeyProp);
|
2011-12-16 07:34:24 +00:00
|
|
|
}
|
|
|
|
|
2012-06-01 17:21:12 +00:00
|
|
|
bool operator==(const StructuredCloneWriteInfo& aOther) const
|
|
|
|
{
|
|
|
|
return this->mCloneBuffer.nbytes() == aOther.mCloneBuffer.nbytes() &&
|
|
|
|
this->mCloneBuffer.data() == aOther.mCloneBuffer.data() &&
|
2012-06-03 16:33:52 +00:00
|
|
|
this->mFiles == aOther.mFiles &&
|
|
|
|
this->mTransaction == aOther.mTransaction &&
|
2012-06-01 17:21:12 +00:00
|
|
|
this->mOffsetToKeyProp == aOther.mOffsetToKeyProp;
|
|
|
|
}
|
|
|
|
|
|
|
|
// In IndexedDatabaseInlines.h
|
|
|
|
inline bool
|
|
|
|
SetFromSerialized(const SerializedStructuredCloneWriteInfo& aOther);
|
|
|
|
|
2011-12-16 07:34:24 +00:00
|
|
|
JSAutoStructuredCloneBuffer mCloneBuffer;
|
2012-06-03 16:33:52 +00:00
|
|
|
nsTArray<StructuredCloneFile> mFiles;
|
|
|
|
IDBTransaction* mTransaction;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint64_t mOffsetToKeyProp;
|
2011-12-16 07:34:24 +00:00
|
|
|
};
|
|
|
|
|
2012-06-01 17:21:12 +00:00
|
|
|
struct SerializedStructuredCloneWriteInfo
|
2010-12-10 02:15:00 +00:00
|
|
|
{
|
2012-06-01 17:21:12 +00:00
|
|
|
SerializedStructuredCloneWriteInfo()
|
2012-07-30 14:20:58 +00:00
|
|
|
: data(nullptr), dataLength(0), offsetToKeyProp(0)
|
2012-06-01 17:21:12 +00:00
|
|
|
{ }
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const SerializedStructuredCloneWriteInfo& aOther) const
|
|
|
|
{
|
|
|
|
return this->data == aOther.data &&
|
|
|
|
this->dataLength == aOther.dataLength &&
|
|
|
|
this->offsetToKeyProp == aOther.offsetToKeyProp;
|
2010-12-10 02:15:00 +00:00
|
|
|
}
|
|
|
|
|
2012-06-01 17:21:12 +00:00
|
|
|
SerializedStructuredCloneWriteInfo&
|
|
|
|
operator=(const StructuredCloneWriteInfo& aOther)
|
|
|
|
{
|
|
|
|
data = aOther.mCloneBuffer.data();
|
|
|
|
dataLength = aOther.mCloneBuffer.nbytes();
|
|
|
|
offsetToKeyProp = aOther.mOffsetToKeyProp;
|
|
|
|
return *this;
|
2010-12-10 02:15:00 +00:00
|
|
|
}
|
|
|
|
|
2012-06-01 17:21:12 +00:00
|
|
|
// Make sure to update ipc/SerializationHelpers.h when changing members here!
|
|
|
|
uint64_t* data;
|
|
|
|
size_t dataLength;
|
|
|
|
uint64_t offsetToKeyProp;
|
|
|
|
};
|
2010-12-10 02:15:00 +00:00
|
|
|
|
2012-10-23 16:31:19 +00:00
|
|
|
class OriginOrPatternString : public nsCString
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static OriginOrPatternString
|
|
|
|
FromOrigin(const nsACString& aOrigin)
|
|
|
|
{
|
|
|
|
return OriginOrPatternString(aOrigin, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static OriginOrPatternString
|
|
|
|
FromPattern(const nsACString& aPattern)
|
|
|
|
{
|
|
|
|
return OriginOrPatternString(aPattern, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsOrigin() const
|
|
|
|
{
|
|
|
|
return mIsOrigin;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsPattern() const
|
|
|
|
{
|
|
|
|
return !mIsOrigin;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
OriginOrPatternString(const nsACString& aOriginOrPattern, bool aIsOrigin)
|
|
|
|
: nsCString(aOriginOrPattern), mIsOrigin(aIsOrigin)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const OriginOrPatternString& aOther) MOZ_DELETE;
|
|
|
|
|
|
|
|
bool mIsOrigin;
|
|
|
|
};
|
|
|
|
|
2010-12-10 02:15:00 +00:00
|
|
|
END_INDEXEDDB_NAMESPACE
|
|
|
|
|
2010-06-23 19:46:08 +00:00
|
|
|
#endif // mozilla_dom_indexeddb_indexeddatabase_h__
|