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
|
|
|
|
2010-06-28 22:51:06 +04:00
|
|
|
#ifndef mozilla_dom_indexeddb_idbindex_h__
|
|
|
|
#define mozilla_dom_indexeddb_idbindex_h__
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2010-09-10 02:15:38 +04:00
|
|
|
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
|
2012-06-22 02:27:13 +04:00
|
|
|
#include "mozilla/dom/indexedDB/KeyPath.h"
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2010-06-28 22:51:06 +04:00
|
|
|
#include "nsIIDBIndex.h"
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2010-11-11 02:26:03 +03:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
|
|
|
|
class nsIScriptContext;
|
|
|
|
class nsPIDOMWindow;
|
2010-09-10 02:15:38 +04:00
|
|
|
|
2010-06-23 23:46:08 +04:00
|
|
|
BEGIN_INDEXEDDB_NAMESPACE
|
|
|
|
|
2010-10-19 21:58:52 +04:00
|
|
|
class AsyncConnectionHelper;
|
2012-06-01 21:21:12 +04:00
|
|
|
class IDBCursor;
|
|
|
|
class IDBKeyRange;
|
2010-06-28 22:51:06 +04:00
|
|
|
class IDBObjectStore;
|
2012-06-01 21:21:12 +04:00
|
|
|
class IDBRequest;
|
|
|
|
class IndexedDBIndexChild;
|
|
|
|
class IndexedDBIndexParent;
|
|
|
|
class Key;
|
|
|
|
|
2010-06-23 23:46:08 +04:00
|
|
|
struct IndexInfo;
|
|
|
|
|
2012-05-15 08:50:29 +04:00
|
|
|
class IDBIndex MOZ_FINAL : public nsIIDBIndex
|
2010-06-23 23:46:08 +04:00
|
|
|
{
|
|
|
|
public:
|
2010-11-11 02:26:03 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2010-06-23 23:46:08 +04:00
|
|
|
NS_DECL_NSIIDBINDEX
|
|
|
|
|
2012-06-23 01:00:53 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBIndex)
|
2010-09-10 02:15:38 +04:00
|
|
|
|
2010-06-28 22:51:06 +04:00
|
|
|
static already_AddRefed<IDBIndex>
|
2010-06-28 22:51:06 +04:00
|
|
|
Create(IDBObjectStore* aObjectStore,
|
2012-06-01 21:21:12 +04:00
|
|
|
const IndexInfo* aIndexInfo,
|
|
|
|
bool aCreating);
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2010-06-28 22:51:06 +04:00
|
|
|
IDBObjectStore* ObjectStore()
|
2010-06-23 23:46:08 +04:00
|
|
|
{
|
|
|
|
return mObjectStore;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
const int64_t Id() const
|
2010-10-19 21:58:52 +04:00
|
|
|
{
|
|
|
|
return mId;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsString& Name() const
|
|
|
|
{
|
|
|
|
return mName;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsUnique() const
|
|
|
|
{
|
|
|
|
return mUnique;
|
|
|
|
}
|
|
|
|
|
2011-12-04 21:39:01 +04:00
|
|
|
bool IsMultiEntry() const
|
|
|
|
{
|
|
|
|
return mMultiEntry;
|
|
|
|
}
|
|
|
|
|
2012-06-22 02:27:13 +04:00
|
|
|
const KeyPath& GetKeyPath() const
|
2010-10-19 21:58:52 +04:00
|
|
|
{
|
2011-01-23 21:16:00 +03:00
|
|
|
return mKeyPath;
|
2010-10-19 21:58:52 +04:00
|
|
|
}
|
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
void
|
|
|
|
SetActor(IndexedDBIndexChild* aActorChild)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!aActorChild || !mActorChild, "Shouldn't have more than one!");
|
|
|
|
mActorChild = aActorChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SetActor(IndexedDBIndexParent* aActorParent)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!aActorParent || !mActorParent,
|
|
|
|
"Shouldn't have more than one!");
|
|
|
|
mActorParent = aActorParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
IndexedDBIndexChild*
|
|
|
|
GetActorChild() const
|
|
|
|
{
|
|
|
|
return mActorChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
IndexedDBIndexParent*
|
|
|
|
GetActorParent() const
|
|
|
|
{
|
|
|
|
return mActorParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult GetInternal(IDBKeyRange* aKeyRange,
|
2012-06-29 20:48:34 +04:00
|
|
|
JSContext* aCx,
|
2012-06-01 21:21:12 +04:00
|
|
|
IDBRequest** _retval);
|
|
|
|
|
|
|
|
nsresult GetKeyInternal(IDBKeyRange* aKeyRange,
|
2012-06-29 20:48:34 +04:00
|
|
|
JSContext* aCx,
|
2012-06-01 21:21:12 +04:00
|
|
|
IDBRequest** _retval);
|
|
|
|
|
|
|
|
nsresult GetAllInternal(IDBKeyRange* aKeyRange,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aLimit,
|
2012-06-29 20:48:34 +04:00
|
|
|
JSContext* aCx,
|
2012-06-01 21:21:12 +04:00
|
|
|
IDBRequest** _retval);
|
|
|
|
|
|
|
|
nsresult GetAllKeysInternal(IDBKeyRange* aKeyRange,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aLimit,
|
2012-06-29 20:48:34 +04:00
|
|
|
JSContext* aCx,
|
2012-06-01 21:21:12 +04:00
|
|
|
IDBRequest** _retval);
|
|
|
|
|
|
|
|
nsresult CountInternal(IDBKeyRange* aKeyRange,
|
2012-06-29 20:48:34 +04:00
|
|
|
JSContext* aCx,
|
2012-06-01 21:21:12 +04:00
|
|
|
IDBRequest** _retval);
|
|
|
|
|
|
|
|
nsresult OpenCursorFromChildProcess(
|
|
|
|
IDBRequest* aRequest,
|
|
|
|
size_t aDirection,
|
|
|
|
const Key& aKey,
|
|
|
|
const Key& aObjectKey,
|
|
|
|
IDBCursor** _retval);
|
|
|
|
|
|
|
|
nsresult OpenKeyCursorInternal(IDBKeyRange* aKeyRange,
|
|
|
|
size_t aDirection,
|
2012-06-29 20:48:34 +04:00
|
|
|
JSContext* aCx,
|
2012-06-01 21:21:12 +04:00
|
|
|
IDBRequest** _retval);
|
|
|
|
|
|
|
|
nsresult OpenCursorInternal(IDBKeyRange* aKeyRange,
|
|
|
|
size_t aDirection,
|
2012-06-29 20:48:34 +04:00
|
|
|
JSContext* aCx,
|
2012-06-01 21:21:12 +04:00
|
|
|
IDBRequest** _retval);
|
|
|
|
|
|
|
|
nsresult OpenCursorFromChildProcess(
|
|
|
|
IDBRequest* aRequest,
|
|
|
|
size_t aDirection,
|
|
|
|
const Key& aKey,
|
|
|
|
const Key& aObjectKey,
|
|
|
|
const SerializedStructuredCloneReadInfo& aCloneInfo,
|
2012-08-02 10:02:29 +04:00
|
|
|
nsTArray<StructuredCloneFile>& aBlobs,
|
2012-06-01 21:21:12 +04:00
|
|
|
IDBCursor** _retval);
|
|
|
|
|
2010-09-10 02:15:38 +04:00
|
|
|
private:
|
2010-06-28 22:51:06 +04:00
|
|
|
IDBIndex();
|
|
|
|
~IDBIndex();
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2010-06-28 22:51:06 +04:00
|
|
|
nsRefPtr<IDBObjectStore> mObjectStore;
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t mId;
|
2010-06-23 23:46:08 +04:00
|
|
|
nsString mName;
|
2012-06-22 02:27:13 +04:00
|
|
|
KeyPath mKeyPath;
|
2012-06-23 01:00:53 +04:00
|
|
|
JS::Value mCachedKeyPath;
|
2012-06-01 21:21:12 +04:00
|
|
|
|
|
|
|
IndexedDBIndexChild* mActorChild;
|
|
|
|
IndexedDBIndexParent* mActorParent;
|
|
|
|
|
2010-06-23 23:46:08 +04:00
|
|
|
bool mUnique;
|
2011-12-04 21:39:01 +04:00
|
|
|
bool mMultiEntry;
|
2012-06-23 01:00:53 +04:00
|
|
|
bool mRooted;
|
2010-06-23 23:46:08 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
END_INDEXEDDB_NAMESPACE
|
|
|
|
|
2010-06-28 22:51:06 +04:00
|
|
|
#endif // mozilla_dom_indexeddb_idbindex_h__
|