gecko-dev/dom/indexedDB/IDBCursor.h

220 строки
4.7 KiB
C
Исходник Обычный вид История

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=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/. */
#ifndef mozilla_dom_indexeddb_idbcursor_h__
#define mozilla_dom_indexeddb_idbcursor_h__
#include "IndexedDatabase.h"
#include "js/RootingAPI.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/IDBCursorBinding.h"
#include "mozilla/dom/indexedDB/Key.h"
#include "nsAutoPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"
class nsPIDOMWindow;
namespace mozilla {
class ErrorResult;
namespace dom {
class OwningIDBObjectStoreOrIDBIndex;
namespace indexedDB {
class BackgroundCursorChild;
class IDBIndex;
class IDBObjectStore;
class IDBRequest;
class IDBTransaction;
class IDBCursor final
: public nsISupports
, public nsWrapperCache
{
public:
enum Direction
{
NEXT = 0,
NEXT_UNIQUE,
PREV,
PREV_UNIQUE,
// Only needed for IPC serialization helper, should never be used in code.
DIRECTION_INVALID
};
private:
enum Type
{
Type_ObjectStore,
Type_ObjectStoreKey,
Type_Index,
Type_IndexKey,
};
2014-11-08 03:42:53 +03:00
BackgroundCursorChild* mBackgroundActor;
Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat The bulk of this commit was generated with a script, executed at the top level of a typical source code checkout. The only non-machine-generated part was modifying MFBT's moz.build to reflect the new naming. CLOSED TREE makes big refactorings like this a piece of cake. # The main substitution. find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \ xargs perl -p -i -e ' s/nsRefPtr\.h/RefPtr\.h/g; # handle includes s/nsRefPtr ?</RefPtr</g; # handle declarations and variables ' # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h. perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h # Handle nsRefPtr.h itself, a couple places that define constructors # from nsRefPtr, and code generators specially. We do this here, rather # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename # things like nsRefPtrHashtable. perl -p -i -e 's/nsRefPtr/RefPtr/g' \ mfbt/nsRefPtr.h \ xpcom/glue/nsCOMPtr.h \ xpcom/base/OwningNonNull.h \ ipc/ipdl/ipdl/lower.py \ ipc/ipdl/ipdl/builtin.py \ dom/bindings/Codegen.py \ python/lldbutils/lldbutils/utils.py # In our indiscriminate substitution above, we renamed # nsRefPtrGetterAddRefs, the class behind getter_AddRefs. Fix that up. find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \ xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g' if [ -d .git ]; then git mv mfbt/nsRefPtr.h mfbt/RefPtr.h else hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h fi --HG-- rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 08:24:48 +03:00
RefPtr<IDBRequest> mRequest;
RefPtr<IDBObjectStore> mSourceObjectStore;
RefPtr<IDBIndex> mSourceIndex;
2014-11-08 03:42:53 +03:00
// mSourceObjectStore or mSourceIndex will hold this alive.
IDBTransaction* mTransaction;
JS::Heap<JSObject*> mScriptOwner;
// These are cycle-collected!
JS::Heap<JS::Value> mCachedKey;
JS::Heap<JS::Value> mCachedPrimaryKey;
JS::Heap<JS::Value> mCachedValue;
Key mKey;
Key mSortKey;
Key mPrimaryKey;
StructuredCloneReadInfo mCloneInfo;
const Type mType;
const Direction mDirection;
bool mHaveCachedKey : 1;
bool mHaveCachedPrimaryKey : 1;
bool mHaveCachedValue : 1;
bool mRooted : 1;
bool mContinueCalled : 1;
bool mHaveValue : 1;
public:
static already_AddRefed<IDBCursor>
2014-11-08 03:42:53 +03:00
Create(BackgroundCursorChild* aBackgroundActor,
const Key& aKey,
StructuredCloneReadInfo&& aCloneInfo);
static already_AddRefed<IDBCursor>
2014-11-08 03:42:53 +03:00
Create(BackgroundCursorChild* aBackgroundActor,
const Key& aKey);
static already_AddRefed<IDBCursor>
2014-11-08 03:42:53 +03:00
Create(BackgroundCursorChild* aBackgroundActor,
const Key& aKey,
const Key& aSortKey,
const Key& aPrimaryKey,
StructuredCloneReadInfo&& aCloneInfo);
static already_AddRefed<IDBCursor>
2014-11-08 03:42:53 +03:00
Create(BackgroundCursorChild* aBackgroundActor,
const Key& aKey,
const Key& aSortKey,
const Key& aPrimaryKey);
static Direction
ConvertDirection(IDBCursorDirection aDirection);
void
AssertIsOnOwningThread() const
#ifdef DEBUG
;
#else
{ }
#endif
nsPIDOMWindow*
GetParentObject() const;
void
GetSource(OwningIDBObjectStoreOrIDBIndex& aSource) const;
IDBCursorDirection
GetDirection() const;
bool IsContinueCalled() const { return mContinueCalled; }
void
GetKey(JSContext* aCx,
JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv);
void
GetPrimaryKey(JSContext* aCx,
JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv);
void
GetValue(JSContext* aCx,
JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv);
void
Continue(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv);
void
Advance(uint32_t aCount, ErrorResult& aRv);
already_AddRefed<IDBRequest>
Update(JSContext* aCx, JS::Handle<JS::Value> aValue, ErrorResult& aRv);
already_AddRefed<IDBRequest>
Delete(JSContext* aCx, ErrorResult& aRv);
void
Reset();
void
Reset(Key&& aKey, StructuredCloneReadInfo&& aValue);
void
Reset(Key&& aKey);
void
Reset(Key&& aKey, Key&& aSortKey, Key&& aPrimaryKey, StructuredCloneReadInfo&& aValue);
void
Reset(Key&& aKey, Key&& aSortKey, Key&& aPrimaryKey);
void
ClearBackgroundActor()
{
AssertIsOnOwningThread();
mBackgroundActor = nullptr;
}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBCursor)
// nsWrapperCache
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
private:
IDBCursor(Type aType,
BackgroundCursorChild* aBackgroundActor,
const Key& aKey);
~IDBCursor();
#ifdef ENABLE_INTL_API
// Checks if this is a locale aware cursor (ie. the index's sortKey is unset)
bool
IsLocaleAware() const;
#endif
void
DropJSObjects();
bool
IsSourceDeleted() const;
};
} // namespace indexedDB
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_indexeddb_idbcursor_h__