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