2010-06-23 23:46:08 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 22:32:37 +03:00
|
|
|
/* 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/. */
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2010-06-28 22:51:06 +04:00
|
|
|
#include "IDBIndex.h"
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2020-01-10 18:23:52 +03:00
|
|
|
#include "IDBCursorType.h"
|
2010-06-23 23:46:08 +04:00
|
|
|
#include "IDBEvents.h"
|
2011-11-03 19:57:30 +04:00
|
|
|
#include "IDBKeyRange.h"
|
2010-06-28 22:51:06 +04:00
|
|
|
#include "IDBObjectStore.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "IDBRequest.h"
|
2010-06-28 20:46:21 +04:00
|
|
|
#include "IDBTransaction.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "IndexedDatabase.h"
|
|
|
|
#include "IndexedDatabaseInlines.h"
|
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "mozilla/dom/indexedDB/PBackgroundIDBSharedTypes.h"
|
2013-03-16 10:58:50 +04:00
|
|
|
#include "ProfilerHelpers.h"
|
2014-01-28 04:37:05 +04:00
|
|
|
#include "ReportInternalError.h"
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
// Include this last to avoid path problems on Windows.
|
|
|
|
#include "ActorsChild.h"
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2017-06-07 13:36:20 +03:00
|
|
|
using namespace mozilla::dom::indexedDB;
|
|
|
|
|
2010-06-23 23:46:08 +04:00
|
|
|
namespace {
|
|
|
|
|
2019-12-16 16:17:33 +03:00
|
|
|
RefPtr<IDBRequest> GenerateRequest(JSContext* aCx, IDBIndex* aIndex) {
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(aIndex);
|
|
|
|
aIndex->AssertIsOnOwningThread();
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
auto transaction = aIndex->ObjectStore()->AcquireTransaction();
|
|
|
|
auto* const database = transaction->Database();
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
return IDBRequest::Create(aCx, aIndex, database, std::move(transaction));
|
2014-09-27 03:21:57 +04:00
|
|
|
}
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
IDBIndex::IDBIndex(IDBObjectStore* aObjectStore, const IndexMetadata* aMetadata)
|
|
|
|
: mObjectStore(aObjectStore),
|
2015-01-14 10:59:06 +03:00
|
|
|
mCachedKeyPath(JS::UndefinedValue()),
|
2014-09-27 03:21:57 +04:00
|
|
|
mMetadata(aMetadata),
|
|
|
|
mId(aMetadata->id()),
|
|
|
|
mRooted(false) {
|
|
|
|
MOZ_ASSERT(aObjectStore);
|
|
|
|
aObjectStore->AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(aMetadata);
|
|
|
|
}
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
IDBIndex::~IDBIndex() {
|
|
|
|
AssertIsOnOwningThread();
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (mRooted) {
|
2015-01-14 10:59:06 +03:00
|
|
|
mCachedKeyPath.setUndefined();
|
2014-09-27 03:21:57 +04:00
|
|
|
mozilla::DropJSObjects(this);
|
|
|
|
}
|
|
|
|
}
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2019-12-16 16:17:33 +03:00
|
|
|
RefPtr<IDBIndex> IDBIndex::Create(IDBObjectStore* aObjectStore,
|
|
|
|
const IndexMetadata& aMetadata) {
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(aObjectStore);
|
|
|
|
aObjectStore->AssertIsOnOwningThread();
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2019-12-16 16:17:33 +03:00
|
|
|
return new IDBIndex(aObjectStore, &aMetadata);
|
2014-09-27 03:21:57 +04:00
|
|
|
}
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
#ifdef DEBUG
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void IDBIndex::AssertIsOnOwningThread() const {
|
|
|
|
MOZ_ASSERT(mObjectStore);
|
|
|
|
mObjectStore->AssertIsOnOwningThread();
|
|
|
|
}
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
#endif // DEBUG
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2019-12-16 16:17:33 +03:00
|
|
|
RefPtr<IDBRequest> IDBIndex::OpenCursor(JSContext* aCx,
|
|
|
|
JS::Handle<JS::Value> aRange,
|
|
|
|
IDBCursorDirection aDirection,
|
|
|
|
ErrorResult& aRv) {
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
return OpenCursorInternal(/* aKeysOnly */ false, aCx, aRange, aDirection,
|
|
|
|
aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<IDBRequest> IDBIndex::OpenKeyCursor(JSContext* aCx,
|
|
|
|
JS::Handle<JS::Value> aRange,
|
|
|
|
IDBCursorDirection aDirection,
|
|
|
|
ErrorResult& aRv) {
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
return OpenCursorInternal(/* aKeysOnly */ true, aCx, aRange, aDirection, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<IDBRequest> IDBIndex::Get(JSContext* aCx, JS::Handle<JS::Value> aKey,
|
|
|
|
ErrorResult& aRv) {
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
return GetInternal(/* aKeyOnly */ false, aCx, aKey, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<IDBRequest> IDBIndex::GetKey(JSContext* aCx, JS::Handle<JS::Value> aKey,
|
|
|
|
ErrorResult& aRv) {
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
return GetInternal(/* aKeyOnly */ true, aCx, aKey, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<IDBRequest> IDBIndex::GetAll(JSContext* aCx, JS::Handle<JS::Value> aKey,
|
|
|
|
const Optional<uint32_t>& aLimit,
|
|
|
|
ErrorResult& aRv) {
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
return GetAllInternal(/* aKeysOnly */ false, aCx, aKey, aLimit, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<IDBRequest> IDBIndex::GetAllKeys(JSContext* aCx,
|
|
|
|
JS::Handle<JS::Value> aKey,
|
|
|
|
const Optional<uint32_t>& aLimit,
|
|
|
|
ErrorResult& aRv) {
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
|
|
|
return GetAllInternal(/* aKeysOnly */ true, aCx, aKey, aLimit, aRv);
|
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void IDBIndex::RefreshMetadata(bool aMayDelete) {
|
|
|
|
AssertIsOnOwningThread();
|
2019-12-19 12:57:45 +03:00
|
|
|
MOZ_ASSERT_IF(mDeletedMetadata, mMetadata == mDeletedMetadata.get());
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2019-11-11 11:24:53 +03:00
|
|
|
const auto& indexes = mObjectStore->Spec().indexes();
|
|
|
|
const auto foundIt = std::find_if(
|
|
|
|
indexes.cbegin(), indexes.cend(),
|
|
|
|
[id = Id()](const auto& metadata) { return metadata.id() == id; });
|
|
|
|
const bool found = foundIt != indexes.cend();
|
2011-01-27 04:53:02 +03:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT_IF(!aMayDelete && !mDeletedMetadata, found);
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (found) {
|
2019-11-11 11:24:53 +03:00
|
|
|
mMetadata = &*foundIt;
|
2019-12-19 12:57:45 +03:00
|
|
|
MOZ_ASSERT(mMetadata != mDeletedMetadata.get());
|
2014-09-27 03:21:57 +04:00
|
|
|
mDeletedMetadata = nullptr;
|
|
|
|
} else {
|
|
|
|
NoteDeletion();
|
2014-09-18 03:36:01 +04:00
|
|
|
}
|
2014-09-27 03:21:57 +04:00
|
|
|
}
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void IDBIndex::NoteDeletion() {
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(mMetadata);
|
|
|
|
MOZ_ASSERT(Id() == mMetadata->id());
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (mDeletedMetadata) {
|
2019-12-19 12:57:45 +03:00
|
|
|
MOZ_ASSERT(mMetadata == mDeletedMetadata.get());
|
2014-09-27 03:21:57 +04:00
|
|
|
return;
|
|
|
|
}
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2019-12-19 12:57:45 +03:00
|
|
|
mDeletedMetadata = MakeUnique<IndexMetadata>(*mMetadata);
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2019-12-19 12:57:45 +03:00
|
|
|
mMetadata = mDeletedMetadata.get();
|
2014-09-27 03:21:57 +04:00
|
|
|
}
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
const nsString& IDBIndex::Name() const {
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(mMetadata);
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
return mMetadata->name();
|
2010-06-23 23:46:08 +04:00
|
|
|
}
|
|
|
|
|
2016-03-30 06:04:56 +03:00
|
|
|
void IDBIndex::SetName(const nsAString& aName, ErrorResult& aRv) {
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
const auto& transaction = mObjectStore->TransactionRef();
|
2016-03-30 06:04:56 +03:00
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
if (transaction.GetMode() != IDBTransaction::Mode::VersionChange ||
|
2016-03-30 06:04:56 +03:00
|
|
|
mDeletedMetadata) {
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
if (!transaction.IsActive()) {
|
2016-03-30 06:04:56 +03:00
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aName == mMetadata->name()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cache logging string of this index before renaming.
|
|
|
|
const LoggingString loggingOldIndex(this);
|
|
|
|
|
|
|
|
const int64_t indexId = Id();
|
|
|
|
|
|
|
|
nsresult rv =
|
2020-04-21 17:32:51 +03:00
|
|
|
transaction.Database()->RenameIndex(mObjectStore->Id(), indexId, aName);
|
2016-03-30 06:04:56 +03:00
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't do this in the macro because we always need to increment the serial
|
|
|
|
// number to keep in sync with the parent.
|
|
|
|
const uint64_t requestSerialNumber = IDBRequest::NextSerialNumber();
|
|
|
|
|
2019-09-27 13:11:45 +03:00
|
|
|
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
|
2016-03-30 06:04:56 +03:00
|
|
|
"database(%s).transaction(%s).objectStore(%s).index(%s)."
|
|
|
|
"rename(%s)",
|
2020-04-21 17:32:51 +03:00
|
|
|
"IDBIndex.rename()", transaction.LoggingSerialNumber(),
|
|
|
|
requestSerialNumber, IDB_LOG_STRINGIFY(transaction.Database()),
|
2016-03-30 06:04:56 +03:00
|
|
|
IDB_LOG_STRINGIFY(transaction), IDB_LOG_STRINGIFY(mObjectStore),
|
|
|
|
loggingOldIndex.get(), IDB_LOG_STRINGIFY(this));
|
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
mObjectStore->MutableTransactionRef().RenameIndex(mObjectStore, indexId,
|
|
|
|
aName);
|
2016-03-30 06:04:56 +03:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
bool IDBIndex::Unique() const {
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(mMetadata);
|
2013-07-31 19:48:40 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
return mMetadata->unique();
|
|
|
|
}
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
bool IDBIndex::MultiEntry() const {
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(mMetadata);
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
return mMetadata->multiEntry();
|
|
|
|
}
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2015-09-04 22:12:29 +03:00
|
|
|
bool IDBIndex::LocaleAware() const {
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(mMetadata);
|
|
|
|
|
|
|
|
return mMetadata->locale().IsEmpty();
|
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
const indexedDB::KeyPath& IDBIndex::GetKeyPath() const {
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(mMetadata);
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
return mMetadata->keyPath();
|
2010-06-23 23:46:08 +04:00
|
|
|
}
|
|
|
|
|
2015-09-04 22:12:29 +03:00
|
|
|
void IDBIndex::GetLocale(nsString& aLocale) const {
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(mMetadata);
|
|
|
|
|
|
|
|
if (mMetadata->locale().IsEmpty()) {
|
|
|
|
SetDOMStringToNull(aLocale);
|
|
|
|
} else {
|
2017-07-24 20:23:52 +03:00
|
|
|
CopyASCIItoUTF16(mMetadata->locale(), aLocale);
|
2015-09-04 22:12:29 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsCString& IDBIndex::Locale() const {
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(mMetadata);
|
|
|
|
|
|
|
|
return mMetadata->locale();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IDBIndex::IsAutoLocale() const {
|
|
|
|
AssertIsOnOwningThread();
|
|
|
|
MOZ_ASSERT(mMetadata);
|
|
|
|
|
|
|
|
return mMetadata->autoLocale();
|
|
|
|
}
|
|
|
|
|
2019-03-29 21:05:11 +03:00
|
|
|
nsIGlobalObject* IDBIndex::GetParentObject() const {
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
2012-06-23 01:00:53 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
return mObjectStore->GetParentObject();
|
2014-09-18 03:36:01 +04:00
|
|
|
}
|
2014-09-13 20:12:19 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
void IDBIndex::GetKeyPath(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
|
|
|
|
ErrorResult& aRv) {
|
|
|
|
AssertIsOnOwningThread();
|
2014-09-13 20:12:19 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (!mCachedKeyPath.isUndefined()) {
|
|
|
|
MOZ_ASSERT(mRooted);
|
|
|
|
aResult.set(mCachedKeyPath);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(!mRooted);
|
|
|
|
|
|
|
|
aRv = GetKeyPath().ToJSVal(aCx, mCachedKeyPath);
|
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
|
|
|
return;
|
2012-06-23 01:00:53 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (mCachedKeyPath.isGCThing()) {
|
|
|
|
mozilla::HoldJSObjects(this);
|
|
|
|
mRooted = true;
|
2012-06-01 21:21:12 +04:00
|
|
|
}
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
aResult.set(mCachedKeyPath);
|
2012-06-01 21:21:12 +04:00
|
|
|
}
|
|
|
|
|
2019-12-16 16:17:33 +03:00
|
|
|
RefPtr<IDBRequest> IDBIndex::GetInternal(bool aKeyOnly, JSContext* aCx,
|
|
|
|
JS::Handle<JS::Value> aKey,
|
|
|
|
ErrorResult& aRv) {
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2015-06-20 19:08:23 +03:00
|
|
|
if (mDeletedMetadata) {
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
const auto& transaction = mObjectStore->TransactionRef();
|
|
|
|
if (!transaction.IsActive()) {
|
2013-07-31 19:48:40 +04:00
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
|
|
|
|
return nullptr;
|
2012-06-01 21:21:12 +04:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDBKeyRange> keyRange;
|
2019-12-16 16:18:06 +03:00
|
|
|
IDBKeyRange::FromJSVal(aCx, aKey, &keyRange, aRv);
|
2014-09-27 03:21:57 +04:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
2013-07-31 19:48:40 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (!keyRange) {
|
|
|
|
// Must specify a key or keyRange for get() and getKey().
|
2018-08-15 16:35:58 +03:00
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_KEY_ERR);
|
2013-07-31 19:48:40 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
const int64_t objectStoreId = mObjectStore->Id();
|
|
|
|
const int64_t indexId = Id();
|
2013-03-16 10:58:50 +04:00
|
|
|
|
2015-09-04 22:12:29 +03:00
|
|
|
SerializedKeyRange serializedKeyRange;
|
|
|
|
keyRange->ToSerialized(serializedKeyRange);
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
RequestParams params;
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (aKeyOnly) {
|
2015-09-04 22:12:29 +03:00
|
|
|
params = IndexGetKeyParams(objectStoreId, indexId, serializedKeyRange);
|
2014-09-27 03:21:57 +04:00
|
|
|
} else {
|
2015-09-04 22:12:29 +03:00
|
|
|
params = IndexGetParams(objectStoreId, indexId, serializedKeyRange);
|
2012-06-01 21:21:12 +04:00
|
|
|
}
|
|
|
|
|
2019-12-16 16:17:33 +03:00
|
|
|
auto request = GenerateRequest(aCx, this);
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(request);
|
|
|
|
|
2014-10-16 08:56:52 +04:00
|
|
|
if (aKeyOnly) {
|
2019-09-27 13:11:45 +03:00
|
|
|
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
|
2014-10-16 08:56:52 +04:00
|
|
|
"database(%s).transaction(%s).objectStore(%s).index(%s)."
|
|
|
|
"getKey(%s)",
|
2020-04-21 17:32:51 +03:00
|
|
|
"IDBIndex.getKey()", transaction.LoggingSerialNumber(),
|
2014-10-16 08:56:52 +04:00
|
|
|
request->LoggingSerialNumber(),
|
2020-04-21 17:32:51 +03:00
|
|
|
IDB_LOG_STRINGIFY(transaction.Database()),
|
2014-10-16 08:56:52 +04:00
|
|
|
IDB_LOG_STRINGIFY(transaction), IDB_LOG_STRINGIFY(mObjectStore),
|
|
|
|
IDB_LOG_STRINGIFY(this), IDB_LOG_STRINGIFY(keyRange));
|
|
|
|
} else {
|
2019-09-27 13:11:45 +03:00
|
|
|
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
|
2014-10-16 08:56:52 +04:00
|
|
|
"database(%s).transaction(%s).objectStore(%s).index(%s)."
|
|
|
|
"get(%s)",
|
2020-04-21 17:32:51 +03:00
|
|
|
"IDBIndex.get()", transaction.LoggingSerialNumber(),
|
2019-09-27 13:11:45 +03:00
|
|
|
request->LoggingSerialNumber(),
|
2020-04-21 17:32:51 +03:00
|
|
|
IDB_LOG_STRINGIFY(transaction.Database()),
|
2014-10-16 08:56:52 +04:00
|
|
|
IDB_LOG_STRINGIFY(transaction), IDB_LOG_STRINGIFY(mObjectStore),
|
|
|
|
IDB_LOG_STRINGIFY(this), IDB_LOG_STRINGIFY(keyRange));
|
|
|
|
}
|
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
auto& mutableTransaction = mObjectStore->MutableTransactionRef();
|
|
|
|
|
2019-11-05 17:40:37 +03:00
|
|
|
// TODO: This is necessary to preserve request ordering only. Proper
|
|
|
|
// sequencing of requests should be done in a more sophisticated manner that
|
|
|
|
// doesn't require invalidating cursor caches (Bug 1580499).
|
2020-04-21 17:32:51 +03:00
|
|
|
mutableTransaction.InvalidateCursorCaches();
|
2019-11-05 17:40:37 +03:00
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
mutableTransaction.StartRequest(request, params);
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2019-12-16 16:17:33 +03:00
|
|
|
return request;
|
2012-06-01 21:21:12 +04:00
|
|
|
}
|
|
|
|
|
2019-12-16 16:17:33 +03:00
|
|
|
RefPtr<IDBRequest> IDBIndex::GetAllInternal(bool aKeysOnly, JSContext* aCx,
|
|
|
|
JS::Handle<JS::Value> aKey,
|
|
|
|
const Optional<uint32_t>& aLimit,
|
|
|
|
ErrorResult& aRv) {
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2015-06-20 19:08:23 +03:00
|
|
|
if (mDeletedMetadata) {
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
const auto& transaction = mObjectStore->TransactionRef();
|
|
|
|
if (!transaction.IsActive()) {
|
2013-07-31 19:48:40 +04:00
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
|
|
|
|
return nullptr;
|
2012-06-01 21:21:12 +04:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDBKeyRange> keyRange;
|
2019-12-16 16:18:06 +03:00
|
|
|
IDBKeyRange::FromJSVal(aCx, aKey, &keyRange, aRv);
|
2014-09-27 03:21:57 +04:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
2013-07-31 19:48:40 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
const int64_t objectStoreId = mObjectStore->Id();
|
|
|
|
const int64_t indexId = Id();
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2019-03-15 20:39:59 +03:00
|
|
|
Maybe<SerializedKeyRange> optionalKeyRange;
|
2014-09-27 03:21:57 +04:00
|
|
|
if (keyRange) {
|
|
|
|
SerializedKeyRange serializedKeyRange;
|
|
|
|
keyRange->ToSerialized(serializedKeyRange);
|
2019-03-15 20:39:59 +03:00
|
|
|
optionalKeyRange.emplace(serializedKeyRange);
|
2014-09-13 20:12:19 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
const uint32_t limit = aLimit.WasPassed() ? aLimit.Value() : 0;
|
|
|
|
|
2019-10-03 10:56:45 +03:00
|
|
|
const auto& params =
|
|
|
|
aKeysOnly ? RequestParams{IndexGetAllKeysParams(objectStoreId, indexId,
|
|
|
|
optionalKeyRange, limit)}
|
|
|
|
: RequestParams{IndexGetAllParams(objectStoreId, indexId,
|
|
|
|
optionalKeyRange, limit)};
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2019-12-16 16:17:33 +03:00
|
|
|
auto request = GenerateRequest(aCx, this);
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(request);
|
|
|
|
|
|
|
|
if (aKeysOnly) {
|
2019-09-27 13:11:45 +03:00
|
|
|
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
|
2014-10-16 08:56:52 +04:00
|
|
|
"database(%s).transaction(%s).objectStore(%s).index(%s)."
|
|
|
|
"getAllKeys(%s, %s)",
|
2020-04-21 17:32:51 +03:00
|
|
|
"IDBIndex.getAllKeys()", transaction.LoggingSerialNumber(),
|
2014-10-16 08:56:52 +04:00
|
|
|
request->LoggingSerialNumber(),
|
2020-04-21 17:32:51 +03:00
|
|
|
IDB_LOG_STRINGIFY(transaction.Database()),
|
2014-10-16 08:56:52 +04:00
|
|
|
IDB_LOG_STRINGIFY(transaction), IDB_LOG_STRINGIFY(mObjectStore),
|
|
|
|
IDB_LOG_STRINGIFY(this), IDB_LOG_STRINGIFY(keyRange),
|
|
|
|
IDB_LOG_STRINGIFY(aLimit));
|
2014-09-27 03:21:57 +04:00
|
|
|
} else {
|
2019-09-27 13:11:45 +03:00
|
|
|
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
|
2014-10-16 08:56:52 +04:00
|
|
|
"database(%s).transaction(%s).objectStore(%s).index(%s)."
|
|
|
|
"getAll(%s, %s)",
|
2020-04-21 17:32:51 +03:00
|
|
|
"IDBIndex.getAll()", transaction.LoggingSerialNumber(),
|
2014-10-16 08:56:52 +04:00
|
|
|
request->LoggingSerialNumber(),
|
2020-04-21 17:32:51 +03:00
|
|
|
IDB_LOG_STRINGIFY(transaction.Database()),
|
2014-10-16 08:56:52 +04:00
|
|
|
IDB_LOG_STRINGIFY(transaction), IDB_LOG_STRINGIFY(mObjectStore),
|
|
|
|
IDB_LOG_STRINGIFY(this), IDB_LOG_STRINGIFY(keyRange),
|
|
|
|
IDB_LOG_STRINGIFY(aLimit));
|
2014-09-27 03:21:57 +04:00
|
|
|
}
|
2013-03-16 10:58:50 +04:00
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
auto& mutableTransaction = mObjectStore->MutableTransactionRef();
|
|
|
|
|
2019-11-05 17:40:37 +03:00
|
|
|
// TODO: This is necessary to preserve request ordering only. Proper
|
|
|
|
// sequencing of requests should be done in a more sophisticated manner that
|
|
|
|
// doesn't require invalidating cursor caches (Bug 1580499).
|
2020-04-21 17:32:51 +03:00
|
|
|
mutableTransaction.InvalidateCursorCaches();
|
2019-11-05 17:40:37 +03:00
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
mutableTransaction.StartRequest(request, params);
|
2014-10-16 08:56:52 +04:00
|
|
|
|
2019-12-16 16:17:33 +03:00
|
|
|
return request;
|
2012-06-01 21:21:12 +04:00
|
|
|
}
|
|
|
|
|
2019-12-16 16:17:33 +03:00
|
|
|
RefPtr<IDBRequest> IDBIndex::OpenCursorInternal(bool aKeysOnly, JSContext* aCx,
|
|
|
|
JS::Handle<JS::Value> aRange,
|
|
|
|
IDBCursorDirection aDirection,
|
|
|
|
ErrorResult& aRv) {
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2015-06-20 19:08:23 +03:00
|
|
|
if (mDeletedMetadata) {
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
const auto& transaction = mObjectStore->TransactionRef();
|
|
|
|
if (!transaction.IsActive()) {
|
2013-07-31 19:48:40 +04:00
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
|
2013-09-24 21:14:16 +04:00
|
|
|
return nullptr;
|
2012-06-01 21:21:12 +04:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDBKeyRange> keyRange;
|
2019-12-16 16:18:06 +03:00
|
|
|
IDBKeyRange::FromJSVal(aCx, aRange, &keyRange, aRv);
|
2014-09-27 03:21:57 +04:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
2013-07-31 19:48:40 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2019-10-03 10:56:45 +03:00
|
|
|
const int64_t objectStoreId = mObjectStore->Id();
|
|
|
|
const int64_t indexId = Id();
|
2014-09-13 20:12:19 +04:00
|
|
|
|
2019-03-15 20:39:59 +03:00
|
|
|
Maybe<SerializedKeyRange> optionalKeyRange;
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
if (keyRange) {
|
|
|
|
SerializedKeyRange serializedKeyRange;
|
|
|
|
keyRange->ToSerialized(serializedKeyRange);
|
|
|
|
|
2019-03-15 20:39:59 +03:00
|
|
|
optionalKeyRange.emplace(std::move(serializedKeyRange));
|
2013-07-31 19:48:40 +04:00
|
|
|
}
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2019-09-11 14:51:24 +03:00
|
|
|
const CommonIndexOpenCursorParams commonIndexParams = {
|
2020-01-10 18:23:52 +03:00
|
|
|
{objectStoreId, std::move(optionalKeyRange), aDirection}, indexId};
|
2019-09-11 14:51:24 +03:00
|
|
|
|
|
|
|
const auto params =
|
|
|
|
aKeysOnly ? OpenCursorParams{IndexOpenKeyCursorParams{commonIndexParams}}
|
|
|
|
: OpenCursorParams{IndexOpenCursorParams{commonIndexParams}};
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2019-12-16 16:17:33 +03:00
|
|
|
auto request = GenerateRequest(aCx, this);
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(request);
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-10-16 08:56:52 +04:00
|
|
|
if (aKeysOnly) {
|
2019-09-27 13:11:45 +03:00
|
|
|
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
|
2014-10-16 08:56:52 +04:00
|
|
|
"database(%s).transaction(%s).objectStore(%s).index(%s)."
|
|
|
|
"openKeyCursor(%s, %s)",
|
2020-04-21 17:32:51 +03:00
|
|
|
"IDBIndex.openKeyCursor()", transaction.LoggingSerialNumber(),
|
2014-10-16 08:56:52 +04:00
|
|
|
request->LoggingSerialNumber(),
|
2020-04-21 17:32:51 +03:00
|
|
|
IDB_LOG_STRINGIFY(transaction.Database()),
|
2014-10-16 08:56:52 +04:00
|
|
|
IDB_LOG_STRINGIFY(transaction), IDB_LOG_STRINGIFY(mObjectStore),
|
|
|
|
IDB_LOG_STRINGIFY(this), IDB_LOG_STRINGIFY(keyRange),
|
2020-01-10 18:23:52 +03:00
|
|
|
IDB_LOG_STRINGIFY(aDirection));
|
2014-10-16 08:56:52 +04:00
|
|
|
} else {
|
2019-09-27 13:11:45 +03:00
|
|
|
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
|
2014-10-16 08:56:52 +04:00
|
|
|
"database(%s).transaction(%s).objectStore(%s).index(%s)."
|
|
|
|
"openCursor(%s, %s)",
|
2020-04-21 17:32:51 +03:00
|
|
|
"IDBIndex.openCursor()", transaction.LoggingSerialNumber(),
|
2014-10-16 08:56:52 +04:00
|
|
|
request->LoggingSerialNumber(),
|
2020-04-21 17:32:51 +03:00
|
|
|
IDB_LOG_STRINGIFY(transaction.Database()),
|
2014-10-16 08:56:52 +04:00
|
|
|
IDB_LOG_STRINGIFY(transaction), IDB_LOG_STRINGIFY(mObjectStore),
|
|
|
|
IDB_LOG_STRINGIFY(this), IDB_LOG_STRINGIFY(keyRange),
|
2020-01-10 18:23:52 +03:00
|
|
|
IDB_LOG_STRINGIFY(aDirection));
|
2014-10-16 08:56:52 +04:00
|
|
|
}
|
|
|
|
|
2020-01-10 18:23:52 +03:00
|
|
|
BackgroundCursorChildBase* const actor =
|
|
|
|
aKeysOnly ? static_cast<BackgroundCursorChildBase*>(
|
|
|
|
new BackgroundCursorChild<IDBCursorType::IndexKey>(
|
|
|
|
request, this, aDirection))
|
|
|
|
: new BackgroundCursorChild<IDBCursorType::Index>(request, this,
|
|
|
|
aDirection);
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
auto& mutableTransaction = mObjectStore->MutableTransactionRef();
|
|
|
|
|
2019-11-05 17:40:37 +03:00
|
|
|
// TODO: This is necessary to preserve request ordering only. Proper
|
|
|
|
// sequencing of requests should be done in a more sophisticated manner that
|
|
|
|
// doesn't require invalidating cursor caches (Bug 1580499).
|
2020-04-21 17:32:51 +03:00
|
|
|
mutableTransaction.InvalidateCursorCaches();
|
2019-11-05 17:40:37 +03:00
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
mutableTransaction.OpenCursor(actor, params);
|
2013-03-16 10:58:50 +04:00
|
|
|
|
2019-12-16 16:17:33 +03:00
|
|
|
return request;
|
2012-06-01 21:21:12 +04:00
|
|
|
}
|
|
|
|
|
2019-12-16 16:17:33 +03:00
|
|
|
RefPtr<IDBRequest> IDBIndex::Count(JSContext* aCx, JS::Handle<JS::Value> aKey,
|
|
|
|
ErrorResult& aRv) {
|
2014-09-27 03:21:57 +04:00
|
|
|
AssertIsOnOwningThread();
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2015-06-20 19:08:23 +03:00
|
|
|
if (mDeletedMetadata) {
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
const auto& transaction = mObjectStore->TransactionRef();
|
|
|
|
if (!transaction.IsActive()) {
|
2013-07-31 19:48:40 +04:00
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
|
|
|
|
return nullptr;
|
2012-06-01 21:21:12 +04:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDBKeyRange> keyRange;
|
2019-12-16 16:18:06 +03:00
|
|
|
IDBKeyRange::FromJSVal(aCx, aKey, &keyRange, aRv);
|
2014-09-27 03:21:57 +04:00
|
|
|
if (aRv.Failed()) {
|
2013-07-31 19:48:40 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
IndexCountParams params;
|
|
|
|
params.objectStoreId() = mObjectStore->Id();
|
|
|
|
params.indexId() = Id();
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
if (keyRange) {
|
|
|
|
SerializedKeyRange serializedKeyRange;
|
|
|
|
keyRange->ToSerialized(serializedKeyRange);
|
2019-03-15 20:39:59 +03:00
|
|
|
params.optionalKeyRange().emplace(serializedKeyRange);
|
2012-06-01 21:21:12 +04:00
|
|
|
}
|
|
|
|
|
2019-12-16 16:17:33 +03:00
|
|
|
auto request = GenerateRequest(aCx, this);
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(request);
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2019-09-27 13:11:45 +03:00
|
|
|
IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
|
2014-10-16 08:56:52 +04:00
|
|
|
"database(%s).transaction(%s).objectStore(%s).index(%s)."
|
|
|
|
"count(%s)",
|
2020-04-21 17:32:51 +03:00
|
|
|
"IDBIndex.count()", transaction.LoggingSerialNumber(),
|
|
|
|
request->LoggingSerialNumber(), IDB_LOG_STRINGIFY(transaction.Database()),
|
2014-10-16 08:56:52 +04:00
|
|
|
IDB_LOG_STRINGIFY(transaction), IDB_LOG_STRINGIFY(mObjectStore),
|
|
|
|
IDB_LOG_STRINGIFY(this), IDB_LOG_STRINGIFY(keyRange));
|
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
auto& mutableTransaction = mObjectStore->MutableTransactionRef();
|
|
|
|
|
2019-11-05 17:40:37 +03:00
|
|
|
// TODO: This is necessary to preserve request ordering only. Proper
|
|
|
|
// sequencing of requests should be done in a more sophisticated manner that
|
|
|
|
// doesn't require invalidating cursor caches (Bug 1580499).
|
2020-04-21 17:32:51 +03:00
|
|
|
mutableTransaction.InvalidateCursorCaches();
|
2019-11-05 17:40:37 +03:00
|
|
|
|
2020-04-21 17:32:51 +03:00
|
|
|
mutableTransaction.StartRequest(request, params);
|
2012-06-01 21:21:12 +04:00
|
|
|
|
2019-12-16 16:17:33 +03:00
|
|
|
return request;
|
2012-06-01 21:21:12 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(IDBIndex)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(IDBIndex)
|
2014-09-18 03:36:01 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBIndex)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2020-04-17 17:57:57 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_MULTI_ZONE_JSHOLDER_CLASS(IDBIndex)
|
2013-08-02 05:29:05 +04:00
|
|
|
|
2012-06-23 01:00:53 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBIndex)
|
2013-07-31 19:48:40 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
|
2016-02-22 21:11:02 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mCachedKeyPath)
|
2012-06-23 01:00:53 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
2010-11-11 02:26:03 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBIndex)
|
2012-11-15 11:32:40 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mObjectStore)
|
2010-09-10 02:15:38 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2010-11-11 02:26:03 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBIndex)
|
2013-07-31 19:48:40 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
|
|
|
|
2010-09-10 02:15:38 +04:00
|
|
|
// Don't unlink mObjectStore!
|
2012-06-23 01:00:53 +04:00
|
|
|
|
2015-01-14 10:59:06 +03:00
|
|
|
tmp->mCachedKeyPath.setUndefined();
|
2012-06-23 01:00:53 +04:00
|
|
|
|
|
|
|
if (tmp->mRooted) {
|
2013-08-17 00:10:17 +04:00
|
|
|
mozilla::DropJSObjects(tmp);
|
2012-06-23 01:00:53 +04:00
|
|
|
tmp->mRooted = false;
|
|
|
|
}
|
2010-09-10 02:15:38 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
JSObject* IDBIndex::WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return IDBIndex_Binding::Wrap(aCx, this, aGivenProto);
|
2010-06-23 23:46:08 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|