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_idbcursor_h__
|
|
|
|
#define mozilla_dom_indexeddb_idbcursor_h__
|
2010-06-23 19:46:08 +00:00
|
|
|
|
2010-09-09 22:15:38 +00:00
|
|
|
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
|
2010-06-28 18:51:06 +00:00
|
|
|
#include "mozilla/dom/indexedDB/IDBObjectStore.h"
|
2011-11-03 15:57:30 +00:00
|
|
|
#include "mozilla/dom/indexedDB/Key.h"
|
2010-09-09 22:15:38 +00:00
|
|
|
|
2011-02-11 07:47:00 +00:00
|
|
|
#include "nsIIDBCursorWithValue.h"
|
2010-06-23 19:46:08 +00:00
|
|
|
|
2010-11-10 23:26:03 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2010-09-09 22:15:38 +00:00
|
|
|
|
2010-06-23 19:46:08 +00:00
|
|
|
class nsIRunnable;
|
2010-11-10 23:26:03 +00:00
|
|
|
class nsIScriptContext;
|
|
|
|
class nsPIDOMWindow;
|
2010-06-23 19:46:08 +00:00
|
|
|
|
|
|
|
BEGIN_INDEXEDDB_NAMESPACE
|
|
|
|
|
2010-12-10 02:15:00 +00:00
|
|
|
class ContinueHelper;
|
|
|
|
class ContinueObjectStoreHelper;
|
|
|
|
class ContinueIndexHelper;
|
|
|
|
class ContinueIndexObjectHelper;
|
2012-06-01 17:21:12 +00:00
|
|
|
class IDBIndex;
|
|
|
|
class IDBRequest;
|
|
|
|
class IDBTransaction;
|
|
|
|
class IndexedDBCursorChild;
|
|
|
|
class IndexedDBCursorParent;
|
2010-06-23 19:46:08 +00:00
|
|
|
|
2012-05-15 04:50:29 +00:00
|
|
|
class IDBCursor MOZ_FINAL : public nsIIDBCursorWithValue
|
2010-06-23 19:46:08 +00:00
|
|
|
{
|
2010-12-10 02:15:00 +00:00
|
|
|
friend class ContinueHelper;
|
|
|
|
friend class ContinueObjectStoreHelper;
|
|
|
|
friend class ContinueIndexHelper;
|
|
|
|
friend class ContinueIndexObjectHelper;
|
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_NSIIDBCURSOR
|
2011-02-11 07:47:00 +00:00
|
|
|
NS_DECL_NSIIDBCURSORWITHVALUE
|
2010-06-23 19:46:08 +00:00
|
|
|
|
2010-11-10 23:26:03 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBCursor)
|
2010-09-09 22:15:38 +00:00
|
|
|
|
2012-03-13 04:44:45 +00:00
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
OBJECTSTORE = 0,
|
|
|
|
INDEXKEY,
|
|
|
|
INDEXOBJECT
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Direction
|
|
|
|
{
|
|
|
|
NEXT = 0,
|
|
|
|
NEXT_UNIQUE,
|
|
|
|
PREV,
|
2012-06-01 17:21:12 +00:00
|
|
|
PREV_UNIQUE,
|
|
|
|
|
|
|
|
// Only needed for IPC serialization helper, should never be used in code.
|
|
|
|
DIRECTION_INVALID
|
2012-03-13 04:44:45 +00:00
|
|
|
};
|
|
|
|
|
2010-12-10 02:15:00 +00:00
|
|
|
// For OBJECTSTORE cursors.
|
2010-06-23 19:46:08 +00:00
|
|
|
static
|
2010-06-28 18:51:06 +00:00
|
|
|
already_AddRefed<IDBCursor>
|
2010-06-23 19:46:08 +00:00
|
|
|
Create(IDBRequest* aRequest,
|
2010-06-28 16:46:21 +00:00
|
|
|
IDBTransaction* aTransaction,
|
2010-06-28 18:51:06 +00:00
|
|
|
IDBObjectStore* aObjectStore,
|
2012-03-13 04:44:45 +00:00
|
|
|
Direction aDirection,
|
2010-12-10 02:15:00 +00:00
|
|
|
const Key& aRangeKey,
|
|
|
|
const nsACString& aContinueQuery,
|
|
|
|
const nsACString& aContinueToQuery,
|
|
|
|
const Key& aKey,
|
2011-12-16 07:34:24 +00:00
|
|
|
StructuredCloneReadInfo& aCloneReadInfo);
|
2010-06-23 19:46:08 +00:00
|
|
|
|
2011-02-11 07:47:00 +00:00
|
|
|
// For INDEXKEY cursors.
|
2010-06-23 19:46:08 +00:00
|
|
|
static
|
2010-06-28 18:51:06 +00:00
|
|
|
already_AddRefed<IDBCursor>
|
2010-06-23 19:46:08 +00:00
|
|
|
Create(IDBRequest* aRequest,
|
2010-06-28 16:46:21 +00:00
|
|
|
IDBTransaction* aTransaction,
|
2010-06-28 18:51:06 +00:00
|
|
|
IDBIndex* aIndex,
|
2012-03-13 04:44:45 +00:00
|
|
|
Direction aDirection,
|
2010-12-10 02:15:00 +00:00
|
|
|
const Key& aRangeKey,
|
|
|
|
const nsACString& aContinueQuery,
|
|
|
|
const nsACString& aContinueToQuery,
|
|
|
|
const Key& aKey,
|
|
|
|
const Key& aObjectKey);
|
2010-06-23 19:46:08 +00:00
|
|
|
|
2010-12-10 02:15:00 +00:00
|
|
|
// For INDEXOBJECT cursors.
|
2010-06-23 19:46:08 +00:00
|
|
|
static
|
2010-06-28 18:51:06 +00:00
|
|
|
already_AddRefed<IDBCursor>
|
2010-06-23 19:46:08 +00:00
|
|
|
Create(IDBRequest* aRequest,
|
2010-06-28 16:46:21 +00:00
|
|
|
IDBTransaction* aTransaction,
|
2010-06-28 18:51:06 +00:00
|
|
|
IDBIndex* aIndex,
|
2012-03-13 04:44:45 +00:00
|
|
|
Direction aDirection,
|
2010-12-10 02:15:00 +00:00
|
|
|
const Key& aRangeKey,
|
|
|
|
const nsACString& aContinueQuery,
|
|
|
|
const nsACString& aContinueToQuery,
|
|
|
|
const Key& aKey,
|
|
|
|
const Key& aObjectKey,
|
2011-12-16 07:34:24 +00:00
|
|
|
StructuredCloneReadInfo& aCloneReadInfo);
|
2010-06-23 19:46:08 +00:00
|
|
|
|
2012-06-01 17:21:12 +00:00
|
|
|
IDBTransaction* Transaction() const
|
2010-09-09 22:15:38 +00:00
|
|
|
{
|
|
|
|
return mTransaction;
|
|
|
|
}
|
|
|
|
|
2012-06-01 17:21:12 +00:00
|
|
|
IDBRequest* Request() const
|
|
|
|
{
|
|
|
|
return mRequest;
|
|
|
|
}
|
|
|
|
|
2012-03-13 04:44:45 +00:00
|
|
|
static nsresult ParseDirection(const nsAString& aDirection,
|
|
|
|
Direction* aResult);
|
|
|
|
|
2012-06-01 17:21:12 +00:00
|
|
|
void
|
|
|
|
SetActor(IndexedDBCursorChild* aActorChild)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!aActorChild || !mActorChild, "Shouldn't have more than one!");
|
|
|
|
mActorChild = aActorChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SetActor(IndexedDBCursorParent* aActorParent)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!aActorParent || !mActorParent,
|
|
|
|
"Shouldn't have more than one!");
|
|
|
|
mActorParent = aActorParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
IndexedDBCursorChild*
|
|
|
|
GetActorChild() const
|
|
|
|
{
|
|
|
|
return mActorChild;
|
|
|
|
}
|
|
|
|
|
2012-11-10 03:29:07 +00:00
|
|
|
IndexedDBCursorParent*
|
|
|
|
GetActorParent() const
|
|
|
|
{
|
|
|
|
return mActorParent;
|
|
|
|
}
|
|
|
|
|
2012-06-01 17:21:12 +00:00
|
|
|
nsresult
|
|
|
|
ContinueInternal(const Key& aKey,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aCount);
|
2012-06-01 17:21:12 +00:00
|
|
|
|
2010-06-23 19:46:08 +00:00
|
|
|
protected:
|
2010-06-28 18:51:06 +00:00
|
|
|
IDBCursor();
|
|
|
|
~IDBCursor();
|
2010-06-23 19:46:08 +00:00
|
|
|
|
2012-11-28 01:37:57 +00:00
|
|
|
void DropJSObjects();
|
|
|
|
|
2010-06-23 19:46:08 +00:00
|
|
|
static
|
2010-06-28 18:51:06 +00:00
|
|
|
already_AddRefed<IDBCursor>
|
2010-06-23 19:46:08 +00:00
|
|
|
CreateCommon(IDBRequest* aRequest,
|
2010-06-28 16:46:21 +00:00
|
|
|
IDBTransaction* aTransaction,
|
2010-12-10 02:15:00 +00:00
|
|
|
IDBObjectStore* aObjectStore,
|
2012-03-13 04:44:45 +00:00
|
|
|
Direction aDirection,
|
2010-12-10 02:15:00 +00:00
|
|
|
const Key& aRangeKey,
|
|
|
|
const nsACString& aContinueQuery,
|
|
|
|
const nsACString& aContinueToQuery);
|
2010-06-23 19:46:08 +00:00
|
|
|
|
|
|
|
nsRefPtr<IDBRequest> mRequest;
|
2010-06-28 16:46:21 +00:00
|
|
|
nsRefPtr<IDBTransaction> mTransaction;
|
2010-06-28 18:51:06 +00:00
|
|
|
nsRefPtr<IDBObjectStore> mObjectStore;
|
2010-06-28 18:51:06 +00:00
|
|
|
nsRefPtr<IDBIndex> mIndex;
|
2010-06-23 19:46:08 +00:00
|
|
|
|
2012-01-24 10:03:37 +00:00
|
|
|
JSObject* mScriptOwner;
|
2010-11-10 23:26:03 +00:00
|
|
|
|
2010-12-10 02:15:00 +00:00
|
|
|
Type mType;
|
2012-03-13 04:44:45 +00:00
|
|
|
Direction mDirection;
|
2010-12-10 02:15:00 +00:00
|
|
|
nsCString mContinueQuery;
|
|
|
|
nsCString mContinueToQuery;
|
2010-06-23 19:46:08 +00:00
|
|
|
|
2011-02-11 07:47:00 +00:00
|
|
|
// These are cycle-collected!
|
2011-11-03 15:57:30 +00:00
|
|
|
jsval mCachedKey;
|
2011-02-11 07:47:00 +00:00
|
|
|
jsval mCachedPrimaryKey;
|
2010-06-23 19:46:08 +00:00
|
|
|
jsval mCachedValue;
|
2010-12-10 02:15:00 +00:00
|
|
|
|
|
|
|
Key mRangeKey;
|
|
|
|
|
|
|
|
Key mKey;
|
|
|
|
Key mObjectKey;
|
2011-12-16 07:34:24 +00:00
|
|
|
StructuredCloneReadInfo mCloneReadInfo;
|
2010-12-10 02:15:00 +00:00
|
|
|
Key mContinueToKey;
|
|
|
|
|
2012-06-01 17:21:12 +00:00
|
|
|
IndexedDBCursorChild* mActorChild;
|
|
|
|
IndexedDBCursorParent* mActorParent;
|
|
|
|
|
2011-11-03 15:57:30 +00:00
|
|
|
bool mHaveCachedKey;
|
2011-02-11 07:47:00 +00:00
|
|
|
bool mHaveCachedPrimaryKey;
|
2010-06-23 19:46:08 +00:00
|
|
|
bool mHaveCachedValue;
|
2011-02-11 07:47:00 +00:00
|
|
|
bool mRooted;
|
2010-06-23 19:46:08 +00:00
|
|
|
bool mContinueCalled;
|
2011-01-07 06:21:36 +00:00
|
|
|
bool mHaveValue;
|
2010-06-23 19:46:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
END_INDEXEDDB_NAMESPACE
|
|
|
|
|
2010-06-28 18:51:06 +00:00
|
|
|
#endif // mozilla_dom_indexeddb_idbcursor_h__
|