зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 98452610cfcc (bug 1539407
) for browser-chrome failure at /builds/worker/workspace/build/src/dom/indexedDB/IDBRequest.cpp:284. On a CLOSED TREE
--HG-- extra : histedit_source : 236c5d6a7a4440a7b545c1ec5a0a72a8c5777b6b
This commit is contained in:
Родитель
c80e2408ea
Коммит
7af208ab28
|
@ -1153,7 +1153,7 @@ void nsGlobalWindowInner::FreeInnerObjects() {
|
|||
}
|
||||
|
||||
if (mIndexedDB) {
|
||||
mIndexedDB->DisconnectFromGlobal(this);
|
||||
mIndexedDB->DisconnectFromWindow(this);
|
||||
mIndexedDB = nullptr;
|
||||
}
|
||||
|
||||
|
@ -1449,7 +1449,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindowInner)
|
|||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mApplicationCache)
|
||||
}
|
||||
if (tmp->mIndexedDB) {
|
||||
tmp->mIndexedDB->DisconnectFromGlobal(tmp);
|
||||
tmp->mIndexedDB->DisconnectFromWindow(tmp);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mIndexedDB)
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocumentPrincipal)
|
||||
|
|
|
@ -522,8 +522,7 @@ void DeserializeStructuredCloneFiles(
|
|||
RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(ipcBlob);
|
||||
MOZ_ASSERT(blobImpl);
|
||||
|
||||
RefPtr<Blob> blob =
|
||||
Blob::Create(aDatabase->GetOwnerGlobal(), blobImpl);
|
||||
RefPtr<Blob> blob = Blob::Create(aDatabase->GetOwner(), blobImpl);
|
||||
|
||||
StructuredCloneFile* file = aFiles.AppendElement();
|
||||
MOZ_ASSERT(file);
|
||||
|
@ -611,8 +610,7 @@ void DeserializeStructuredCloneFiles(
|
|||
RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(ipcBlob);
|
||||
MOZ_ASSERT(blobImpl);
|
||||
|
||||
RefPtr<Blob> blob =
|
||||
Blob::Create(aDatabase->GetOwnerGlobal(), blobImpl);
|
||||
RefPtr<Blob> blob = Blob::Create(aDatabase->GetOwner(), blobImpl);
|
||||
|
||||
StructuredCloneFile* file = aFiles.AppendElement();
|
||||
MOZ_ASSERT(file);
|
||||
|
@ -1227,8 +1225,7 @@ already_AddRefed<File> ConvertActorToFile(
|
|||
RefPtr<BlobImpl> blobImplSnapshot =
|
||||
new BlobImplSnapshot(blobImpl, static_cast<IDBFileHandle*>(aFileHandle));
|
||||
|
||||
RefPtr<File> file =
|
||||
File::Create(mutableFile->GetOwnerGlobal(), blobImplSnapshot);
|
||||
RefPtr<File> file = File::Create(mutableFile->GetOwner(), blobImplSnapshot);
|
||||
return file.forget();
|
||||
}
|
||||
|
||||
|
@ -1680,8 +1677,7 @@ mozilla::ipc::IPCResult BackgroundFactoryRequestChild::RecvPermissionChallenge(
|
|||
}
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
nsCOMPtr<nsIGlobalObject> global = mFactory->GetParentObject();
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(global);
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = mFactory->GetParentObject();
|
||||
MOZ_ASSERT(window);
|
||||
|
||||
nsCOMPtr<Element> ownerElement =
|
||||
|
|
|
@ -34,6 +34,7 @@ IDBCursor::IDBCursor(Type aType, BackgroundCursorChild* aBackgroundActor,
|
|||
mSourceObjectStore(aBackgroundActor->GetObjectStore()),
|
||||
mSourceIndex(aBackgroundActor->GetIndex()),
|
||||
mTransaction(mRequest->GetTransaction()),
|
||||
mScriptOwner(mTransaction->Database()->GetScriptOwner()),
|
||||
mCachedKey(JS::UndefinedValue()),
|
||||
mCachedPrimaryKey(JS::UndefinedValue()),
|
||||
mCachedValue(JS::UndefinedValue()),
|
||||
|
@ -54,6 +55,12 @@ IDBCursor::IDBCursor(Type aType, BackgroundCursorChild* aBackgroundActor,
|
|||
MOZ_ASSERT_IF(aType == Type_Index || aType == Type_IndexKey, mSourceIndex);
|
||||
MOZ_ASSERT(mTransaction);
|
||||
MOZ_ASSERT(!aKey.IsUnset());
|
||||
MOZ_ASSERT(mScriptOwner);
|
||||
|
||||
if (mScriptOwner) {
|
||||
mozilla::HoldJSObjects(this);
|
||||
mRooted = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool IDBCursor::IsLocaleAware() const {
|
||||
|
@ -183,6 +190,7 @@ void IDBCursor::DropJSObjects() {
|
|||
return;
|
||||
}
|
||||
|
||||
mScriptOwner = nullptr;
|
||||
mRooted = false;
|
||||
|
||||
mozilla::DropJSObjects(this);
|
||||
|
@ -226,7 +234,7 @@ void IDBCursor::Reset() {
|
|||
mContinueCalled = false;
|
||||
}
|
||||
|
||||
nsIGlobalObject* IDBCursor::GetParentObject() const {
|
||||
nsPIDOMWindowInner* IDBCursor::GetParentObject() const {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(mTransaction);
|
||||
|
||||
|
@ -865,6 +873,7 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBCursor)
|
|||
MOZ_ASSERT_IF(!tmp->mHaveCachedValue, tmp->mCachedValue.isUndefined());
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mScriptOwner)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mCachedKey)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mCachedPrimaryKey)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mCachedValue)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsIGlobalObject;
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -65,6 +65,8 @@ class IDBCursor final : public nsISupports, public nsWrapperCache {
|
|||
// 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;
|
||||
|
@ -112,7 +114,7 @@ class IDBCursor final : public nsISupports, public nsWrapperCache {
|
|||
}
|
||||
#endif
|
||||
|
||||
nsIGlobalObject* GetParentObject() const;
|
||||
nsPIDOMWindowInner* GetParentObject() const;
|
||||
|
||||
void GetSource(OwningIDBObjectStoreOrIDBIndex& aSource) const;
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ class IDBDatabase::Observer final : public nsIObserver {
|
|||
|
||||
IDBDatabase::IDBDatabase(IDBOpenDBRequest* aRequest, IDBFactory* aFactory,
|
||||
BackgroundDatabaseChild* aActor, DatabaseSpec* aSpec)
|
||||
: DOMEventTargetHelper(aRequest),
|
||||
: IDBWrapperCache(aRequest),
|
||||
mFactory(aFactory),
|
||||
mSpec(aSpec),
|
||||
mBackgroundActor(aActor),
|
||||
|
@ -184,10 +184,10 @@ already_AddRefed<IDBDatabase> IDBDatabase::Create(
|
|||
|
||||
RefPtr<IDBDatabase> db = new IDBDatabase(aRequest, aFactory, aActor, aSpec);
|
||||
|
||||
db->SetScriptOwner(aRequest->GetScriptOwner());
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> window =
|
||||
do_QueryInterface(aFactory->GetParentObject());
|
||||
if (window) {
|
||||
if (nsPIDOMWindowInner* window = aFactory->GetParentObject()) {
|
||||
uint64_t windowId = window->WindowID();
|
||||
|
||||
RefPtr<Observer> observer = new Observer(db, windowId);
|
||||
|
@ -318,6 +318,10 @@ void IDBDatabase::RefreshSpec(bool aMayDelete) {
|
|||
}
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* IDBDatabase::GetParentObject() const {
|
||||
return mFactory->GetParentObject();
|
||||
}
|
||||
|
||||
const nsString& IDBDatabase::Name() const {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(mSpec);
|
||||
|
@ -1056,22 +1060,20 @@ void IDBDatabase::LogWarning(const char* aMessageName,
|
|||
mFactory->InnerWindowID());
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(IDBDatabase, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBDatabase, DOMEventTargetHelper)
|
||||
NS_IMPL_ADDREF_INHERITED(IDBDatabase, IDBWrapperCache)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBDatabase, IDBWrapperCache)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBDatabase)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBDatabase)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBDatabase,
|
||||
DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBDatabase, IDBWrapperCache)
|
||||
tmp->AssertIsOnOwningThread();
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFactory)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBDatabase,
|
||||
DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBDatabase, IDBWrapperCache)
|
||||
tmp->AssertIsOnOwningThread();
|
||||
|
||||
// Don't unlink mFactory!
|
||||
|
@ -1083,7 +1085,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|||
|
||||
void IDBDatabase::DisconnectFromOwner() {
|
||||
InvalidateInternal();
|
||||
DOMEventTargetHelper::DisconnectFromOwner();
|
||||
IDBWrapperCache::DisconnectFromOwner();
|
||||
}
|
||||
|
||||
void IDBDatabase::LastRelease() {
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/IDBTransactionBinding.h"
|
||||
#include "mozilla/dom/StorageTypeBinding.h"
|
||||
#include "mozilla/dom/IDBWrapperCache.h"
|
||||
#include "mozilla/dom/quota/PersistenceType.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
|
@ -19,7 +19,7 @@
|
|||
#include "nsTHashtable.h"
|
||||
|
||||
class nsIEventTarget;
|
||||
class nsIGlobalObject;
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -47,7 +47,7 @@ class DatabaseSpec;
|
|||
class PBackgroundIDBDatabaseFileChild;
|
||||
} // namespace indexedDB
|
||||
|
||||
class IDBDatabase final : public DOMEventTargetHelper {
|
||||
class IDBDatabase final : public IDBWrapperCache {
|
||||
typedef mozilla::dom::indexedDB::DatabaseSpec DatabaseSpec;
|
||||
typedef mozilla::dom::StorageType StorageType;
|
||||
typedef mozilla::dom::quota::PersistenceType PersistenceType;
|
||||
|
@ -178,6 +178,8 @@ class IDBDatabase final : public DOMEventTargetHelper {
|
|||
|
||||
void NoteFinishedMutableFile(IDBMutableFile* aMutableFile);
|
||||
|
||||
nsPIDOMWindowInner* GetParentObject() const;
|
||||
|
||||
already_AddRefed<DOMStringList> ObjectStoreNames() const;
|
||||
|
||||
already_AddRefed<IDBObjectStore> CreateObjectStore(
|
||||
|
@ -226,7 +228,7 @@ class IDBDatabase final : public DOMEventTargetHelper {
|
|||
const DatabaseSpec* Spec() const { return mSpec; }
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBDatabase, DOMEventTargetHelper)
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBDatabase, IDBWrapperCache)
|
||||
|
||||
// DOMEventTargetHelper
|
||||
void DisconnectFromOwner() override;
|
||||
|
|
|
@ -70,7 +70,8 @@ struct IDBFactory::PendingRequestInfo {
|
|||
};
|
||||
|
||||
IDBFactory::IDBFactory()
|
||||
: mBackgroundActor(nullptr),
|
||||
: mOwningObject(nullptr),
|
||||
mBackgroundActor(nullptr),
|
||||
mInnerWindowID(0),
|
||||
mActiveTransactionCount(0),
|
||||
mActiveDatabaseCount(0),
|
||||
|
@ -82,6 +83,9 @@ IDBFactory::IDBFactory()
|
|||
IDBFactory::~IDBFactory() {
|
||||
MOZ_ASSERT_IF(mBackgroundActorFailed, !mBackgroundActor);
|
||||
|
||||
mOwningObject = nullptr;
|
||||
mozilla::DropJSObjects(this);
|
||||
|
||||
if (mBackgroundActor) {
|
||||
mBackgroundActor->SendDeleteMeInternal();
|
||||
MOZ_ASSERT(!mBackgroundActor, "SendDeleteMeInternal should have cleared!");
|
||||
|
@ -139,10 +143,7 @@ nsresult IDBFactory::CreateForWindow(nsPIDOMWindowInner* aWindow,
|
|||
|
||||
RefPtr<IDBFactory> factory = new IDBFactory();
|
||||
factory->mPrincipalInfo = std::move(principalInfo);
|
||||
|
||||
factory->mGlobal = do_QueryInterface(aWindow);
|
||||
MOZ_ASSERT(factory->mGlobal);
|
||||
|
||||
factory->mWindow = aWindow;
|
||||
factory->mTabChild = TabChild::GetFrom(aWindow);
|
||||
factory->mEventTarget =
|
||||
nsGlobalWindowInner::Cast(aWindow)->EventTargetFor(TaskCategory::Other);
|
||||
|
@ -155,18 +156,13 @@ nsresult IDBFactory::CreateForWindow(nsPIDOMWindowInner* aWindow,
|
|||
}
|
||||
|
||||
// static
|
||||
nsresult IDBFactory::CreateForMainThreadJS(nsIGlobalObject* aGlobal,
|
||||
nsresult IDBFactory::CreateForMainThreadJS(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aOwningObject,
|
||||
IDBFactory** aFactory) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aGlobal);
|
||||
|
||||
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(aGlobal);
|
||||
if (NS_WARN_IF(!sop)) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
nsAutoPtr<PrincipalInfo> principalInfo(new PrincipalInfo());
|
||||
nsIPrincipal* principal = sop->GetPrincipal();
|
||||
nsIPrincipal* principal = nsContentUtils::ObjectPrincipal(aOwningObject);
|
||||
MOZ_ASSERT(principal);
|
||||
bool isSystem;
|
||||
if (!AllowedForPrincipal(principal, &isSystem)) {
|
||||
|
@ -182,7 +178,8 @@ nsresult IDBFactory::CreateForMainThreadJS(nsIGlobalObject* aGlobal,
|
|||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
rv = CreateForMainThreadJSInternal(aGlobal, principalInfo, aFactory);
|
||||
rv = CreateForMainThreadJSInternal(aCx, aOwningObject, principalInfo,
|
||||
aFactory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -193,18 +190,18 @@ nsresult IDBFactory::CreateForMainThreadJS(nsIGlobalObject* aGlobal,
|
|||
}
|
||||
|
||||
// static
|
||||
nsresult IDBFactory::CreateForWorker(nsIGlobalObject* aGlobal,
|
||||
nsresult IDBFactory::CreateForWorker(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aOwningObject,
|
||||
const PrincipalInfo& aPrincipalInfo,
|
||||
uint64_t aInnerWindowID,
|
||||
IDBFactory** aFactory) {
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
MOZ_ASSERT(aGlobal);
|
||||
MOZ_ASSERT(aPrincipalInfo.type() != PrincipalInfo::T__None);
|
||||
|
||||
nsAutoPtr<PrincipalInfo> principalInfo(new PrincipalInfo(aPrincipalInfo));
|
||||
|
||||
nsresult rv =
|
||||
CreateInternal(aGlobal, principalInfo, aInnerWindowID, aFactory);
|
||||
nsresult rv = CreateForJSInternal(aCx, aOwningObject, principalInfo,
|
||||
aInnerWindowID, aFactory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -216,10 +213,9 @@ nsresult IDBFactory::CreateForWorker(nsIGlobalObject* aGlobal,
|
|||
|
||||
// static
|
||||
nsresult IDBFactory::CreateForMainThreadJSInternal(
|
||||
nsIGlobalObject* aGlobal, nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
|
||||
IDBFactory** aFactory) {
|
||||
JSContext* aCx, JS::Handle<JSObject*> aOwningObject,
|
||||
nsAutoPtr<PrincipalInfo>& aPrincipalInfo, IDBFactory** aFactory) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aGlobal);
|
||||
MOZ_ASSERT(aPrincipalInfo);
|
||||
|
||||
if (aPrincipalInfo->type() != PrincipalInfo::TSystemPrincipalInfo &&
|
||||
|
@ -234,8 +230,8 @@ nsresult IDBFactory::CreateForMainThreadJSInternal(
|
|||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
nsresult rv =
|
||||
CreateInternal(aGlobal, aPrincipalInfo, /* aInnerWindowID */ 0, aFactory);
|
||||
nsresult rv = CreateForJSInternal(aCx, aOwningObject, aPrincipalInfo,
|
||||
/* aInnerWindowID */ 0, aFactory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -244,14 +240,16 @@ nsresult IDBFactory::CreateForMainThreadJSInternal(
|
|||
}
|
||||
|
||||
// static
|
||||
nsresult IDBFactory::CreateInternal(nsIGlobalObject* aGlobal,
|
||||
nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
|
||||
uint64_t aInnerWindowID,
|
||||
IDBFactory** aFactory) {
|
||||
MOZ_ASSERT(aGlobal);
|
||||
nsresult IDBFactory::CreateForJSInternal(
|
||||
JSContext* aCx, JS::Handle<JSObject*> aOwningObject,
|
||||
nsAutoPtr<PrincipalInfo>& aPrincipalInfo, uint64_t aInnerWindowID,
|
||||
IDBFactory** aFactory) {
|
||||
MOZ_ASSERT(aCx);
|
||||
MOZ_ASSERT(aOwningObject);
|
||||
MOZ_ASSERT(aPrincipalInfo);
|
||||
MOZ_ASSERT(aPrincipalInfo->type() != PrincipalInfo::T__None);
|
||||
MOZ_ASSERT(aFactory);
|
||||
MOZ_ASSERT(JS_IsGlobalObject(aOwningObject));
|
||||
|
||||
if (aPrincipalInfo->type() != PrincipalInfo::TContentPrincipalInfo &&
|
||||
aPrincipalInfo->type() != PrincipalInfo::TSystemPrincipalInfo) {
|
||||
|
@ -263,7 +261,8 @@ nsresult IDBFactory::CreateInternal(nsIGlobalObject* aGlobal,
|
|||
|
||||
RefPtr<IDBFactory> factory = new IDBFactory();
|
||||
factory->mPrincipalInfo = aPrincipalInfo.forget();
|
||||
factory->mGlobal = aGlobal;
|
||||
factory->mOwningObject = aOwningObject;
|
||||
mozilla::HoldJSObjects(factory.get());
|
||||
factory->mEventTarget = GetCurrentThreadEventTarget();
|
||||
factory->mInnerWindowID = aInnerWindowID;
|
||||
|
||||
|
@ -378,9 +377,8 @@ void IDBFactory::UpdateActiveTransactionCount(int32_t aDelta) {
|
|||
MOZ_DIAGNOSTIC_ASSERT(aDelta > 0 || (mActiveTransactionCount + aDelta) <
|
||||
mActiveTransactionCount);
|
||||
mActiveTransactionCount += aDelta;
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(mGlobal);
|
||||
if (window) {
|
||||
window->UpdateActiveIndexedDBTransactionCount(aDelta);
|
||||
if (mWindow) {
|
||||
mWindow->UpdateActiveIndexedDBTransactionCount(aDelta);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -389,10 +387,8 @@ void IDBFactory::UpdateActiveDatabaseCount(int32_t aDelta) {
|
|||
MOZ_DIAGNOSTIC_ASSERT(aDelta > 0 ||
|
||||
(mActiveDatabaseCount + aDelta) < mActiveDatabaseCount);
|
||||
mActiveDatabaseCount += aDelta;
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(mGlobal);
|
||||
if (window) {
|
||||
window->UpdateActiveIndexedDBDatabaseCount(aDelta);
|
||||
if (mWindow) {
|
||||
mWindow->UpdateActiveIndexedDBDatabaseCount(aDelta);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,9 +421,8 @@ already_AddRefed<IDBOpenDBRequest> IDBFactory::Open(
|
|||
JSContext* aCx, const nsAString& aName, const IDBOpenDBOptions& aOptions,
|
||||
CallerType aCallerType, ErrorResult& aRv) {
|
||||
if (!IsChrome() && aOptions.mStorage.WasPassed()) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(mGlobal);
|
||||
if (window && window->GetExtantDoc()) {
|
||||
window->GetExtantDoc()->WarnOnceAbout(
|
||||
if (mWindow && mWindow->GetExtantDoc()) {
|
||||
mWindow->GetExtantDoc()->WarnOnceAbout(
|
||||
Document::eIDBOpenDBOptions_StorageType);
|
||||
} else if (!NS_IsMainThread()) {
|
||||
// The method below reports on the main thread too, so we need to make
|
||||
|
@ -568,7 +563,8 @@ already_AddRefed<IDBOpenDBRequest> IDBFactory::OpenInternal(
|
|||
const Optional<uint64_t>& aVersion,
|
||||
const Optional<StorageType>& aStorageType, bool aDeleting,
|
||||
CallerType aCallerType, ErrorResult& aRv) {
|
||||
MOZ_ASSERT(mGlobal);
|
||||
MOZ_ASSERT(mWindow || mOwningObject);
|
||||
MOZ_ASSERT_IF(!mWindow, !mPrivateBrowsingMode);
|
||||
|
||||
CommonFactoryRequestParams commonParams;
|
||||
|
||||
|
@ -728,12 +724,24 @@ already_AddRefed<IDBOpenDBRequest> IDBFactory::OpenInternal(
|
|||
}
|
||||
}
|
||||
|
||||
RefPtr<IDBOpenDBRequest> request =
|
||||
IDBOpenDBRequest::Create(aCx, this, mGlobal);
|
||||
if (!request) {
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
aRv.ThrowUncatchableException();
|
||||
return nullptr;
|
||||
RefPtr<IDBOpenDBRequest> request;
|
||||
|
||||
if (mWindow) {
|
||||
JS::Rooted<JSObject*> scriptOwner(
|
||||
aCx, nsGlobalWindowInner::Cast(mWindow.get())->FastGetGlobalJSObject());
|
||||
MOZ_ASSERT(scriptOwner);
|
||||
|
||||
request =
|
||||
IDBOpenDBRequest::CreateForWindow(aCx, this, mWindow, scriptOwner);
|
||||
} else {
|
||||
JS::Rooted<JSObject*> scriptOwner(aCx, mOwningObject);
|
||||
|
||||
request = IDBOpenDBRequest::CreateForJS(aCx, this, scriptOwner);
|
||||
if (!request) {
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
aRv.ThrowUncatchableException();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_ASSERT(request);
|
||||
|
@ -809,12 +817,12 @@ nsresult IDBFactory::InitiateRequest(IDBOpenDBRequest* aRequest,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void IDBFactory::DisconnectFromGlobal(nsIGlobalObject* aOldGlobal) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(aOldGlobal);
|
||||
// If CC unlinks us first, then mGlobal might be nullptr
|
||||
MOZ_DIAGNOSTIC_ASSERT(!mGlobal || mGlobal == aOldGlobal);
|
||||
void IDBFactory::DisconnectFromWindow(nsPIDOMWindowInner* aOldWindow) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(aOldWindow);
|
||||
// If CC unlinks us first, then mWindow might be nullptr
|
||||
MOZ_DIAGNOSTIC_ASSERT(!mWindow || mWindow == aOldWindow);
|
||||
|
||||
mGlobal = nullptr;
|
||||
mWindow = nullptr;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(IDBFactory)
|
||||
|
@ -828,20 +836,22 @@ NS_INTERFACE_MAP_END
|
|||
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBFactory)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBFactory)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTabChild)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mEventTarget)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBFactory)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal)
|
||||
tmp->mOwningObject = nullptr;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindow)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTabChild)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mEventTarget)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBFactory)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mOwningObject)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
JSObject* IDBFactory::WrapObject(JSContext* aCx,
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "nsTArray.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsIGlobalObject;
|
||||
class nsIEventTarget;
|
||||
class nsIPrincipal;
|
||||
class nsPIDOMWindowInner;
|
||||
|
@ -59,7 +58,10 @@ class IDBFactory final : public nsISupports, public nsWrapperCache {
|
|||
|
||||
nsAutoPtr<PrincipalInfo> mPrincipalInfo;
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> mGlobal;
|
||||
// If this factory lives on a window then mWindow must be non-null. Otherwise
|
||||
// mOwningObject must be non-null.
|
||||
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
||||
JS::Heap<JSObject*> mOwningObject;
|
||||
|
||||
// This will only be set if the factory belongs to a window in a child
|
||||
// process.
|
||||
|
@ -82,10 +84,12 @@ class IDBFactory final : public nsISupports, public nsWrapperCache {
|
|||
static nsresult CreateForWindow(nsPIDOMWindowInner* aWindow,
|
||||
IDBFactory** aFactory);
|
||||
|
||||
static nsresult CreateForMainThreadJS(nsIGlobalObject* aGlobal,
|
||||
static nsresult CreateForMainThreadJS(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aOwningObject,
|
||||
IDBFactory** aFactory);
|
||||
|
||||
static nsresult CreateForWorker(nsIGlobalObject* aGlobal,
|
||||
static nsresult CreateForWorker(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aOwningObject,
|
||||
const PrincipalInfo& aPrincipalInfo,
|
||||
uint64_t aInnerWindowID,
|
||||
IDBFactory** aFactory);
|
||||
|
@ -123,7 +127,7 @@ class IDBFactory final : public nsISupports, public nsWrapperCache {
|
|||
|
||||
void IncrementParentLoggingRequestSerialNumber();
|
||||
|
||||
nsIGlobalObject* GetParentObject() const { return mGlobal; }
|
||||
nsPIDOMWindowInner* GetParentObject() const { return mWindow; }
|
||||
|
||||
TabChild* GetTabChild() const { return mTabChild; }
|
||||
|
||||
|
@ -174,7 +178,7 @@ class IDBFactory final : public nsISupports, public nsWrapperCache {
|
|||
const IDBOpenDBOptions& aOptions, SystemCallerGuarantee,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void DisconnectFromGlobal(nsIGlobalObject* aOldGlobal);
|
||||
void DisconnectFromWindow(nsPIDOMWindowInner* aOldWindow);
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBFactory)
|
||||
|
@ -188,13 +192,14 @@ class IDBFactory final : public nsISupports, public nsWrapperCache {
|
|||
~IDBFactory();
|
||||
|
||||
static nsresult CreateForMainThreadJSInternal(
|
||||
nsIGlobalObject* aGlobal, nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
|
||||
IDBFactory** aFactory);
|
||||
JSContext* aCx, JS::Handle<JSObject*> aOwningObject,
|
||||
nsAutoPtr<PrincipalInfo>& aPrincipalInfo, IDBFactory** aFactory);
|
||||
|
||||
static nsresult CreateInternal(nsIGlobalObject* aGlobal,
|
||||
nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
|
||||
uint64_t aInnerWindowID,
|
||||
IDBFactory** aFactory);
|
||||
static nsresult CreateForJSInternal(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aOwningObject,
|
||||
nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
|
||||
uint64_t aInnerWindowID,
|
||||
IDBFactory** aFactory);
|
||||
|
||||
static nsresult AllowedForWindowInternal(nsPIDOMWindowInner* aWindow,
|
||||
nsIPrincipal** aPrincipal);
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include "nsIRunnable.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
@ -110,6 +112,11 @@ class IDBFileHandle final : public DOMEventTargetHelper,
|
|||
void Abort();
|
||||
|
||||
// WebIDL
|
||||
nsPIDOMWindowInner* GetParentObject() const {
|
||||
AssertIsOnOwningThread();
|
||||
return GetOwner();
|
||||
}
|
||||
|
||||
IDBMutableFile* GetMutableFile() const {
|
||||
AssertIsOnOwningThread();
|
||||
return mMutableFile;
|
||||
|
|
|
@ -26,7 +26,7 @@ using namespace mozilla::dom::indexedDB;
|
|||
|
||||
IDBFileRequest::IDBFileRequest(IDBFileHandle* aFileHandle,
|
||||
bool aWrapAsDOMRequest)
|
||||
: DOMRequest(aFileHandle->GetOwnerGlobal()),
|
||||
: DOMRequest(aFileHandle->GetOwner()),
|
||||
mFileHandle(aFileHandle),
|
||||
mWrapAsDOMRequest(aWrapAsDOMRequest),
|
||||
mHasEncoding(false) {
|
||||
|
@ -72,7 +72,7 @@ void IDBFileRequest::SetResultCallback(ResultCallback* aCallback) {
|
|||
MOZ_ASSERT(aCallback);
|
||||
|
||||
AutoJSAPI autoJS;
|
||||
if (NS_WARN_IF(!autoJS.Init(GetOwnerGlobal()))) {
|
||||
if (NS_WARN_IF(!autoJS.Init(GetOwner()))) {
|
||||
FireError(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ bool IDBIndex::IsAutoLocale() const {
|
|||
return mMetadata->autoLocale();
|
||||
}
|
||||
|
||||
nsIGlobalObject* IDBIndex::GetParentObject() const {
|
||||
nsPIDOMWindowInner* IDBIndex::GetParentObject() const {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
return mObjectStore->GetParentObject();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "nsTArrayForwardDeclare.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsIGlobalObject;
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -83,7 +83,7 @@ class IDBIndex final : public nsISupports, public nsWrapperCache {
|
|||
return mObjectStore;
|
||||
}
|
||||
|
||||
nsIGlobalObject* GetParentObject() const;
|
||||
nsPIDOMWindowInner* GetParentObject() const;
|
||||
|
||||
void GetName(nsString& aName) const { aName = Name(); }
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include "nsString.h"
|
||||
#include "nsTHashtable.h"
|
||||
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ErrorResult;
|
||||
|
@ -103,6 +105,8 @@ class IDBMutableFile final : public DOMEventTargetHelper {
|
|||
void AbortFileHandles();
|
||||
|
||||
// WebIDL
|
||||
nsPIDOMWindowInner* GetParentObject() const { return GetOwner(); }
|
||||
|
||||
void GetName(nsString& aName) const { aName = mName; }
|
||||
|
||||
void GetType(nsString& aType) const { aType = mType; }
|
||||
|
|
|
@ -1869,7 +1869,7 @@ JSObject* IDBObjectStore::WrapObject(JSContext* aCx,
|
|||
return IDBObjectStore_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
nsIGlobalObject* IDBObjectStore::GetParentObject() const {
|
||||
nsPIDOMWindowInner* IDBObjectStore::GetParentObject() const {
|
||||
return mTransaction->GetParentObject();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "nsWrapperCache.h"
|
||||
|
||||
struct JSClass;
|
||||
class nsIGlobalObject;
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -137,7 +137,7 @@ class IDBObjectStore final : public nsISupports, public nsWrapperCache {
|
|||
|
||||
bool HasValidKeyPath() const;
|
||||
|
||||
nsIGlobalObject* GetParentObject() const;
|
||||
nsPIDOMWindowInner* GetParentObject() const;
|
||||
|
||||
void GetName(nsString& aName) const {
|
||||
AssertIsOnOwningThread();
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "mozilla/ContentEvents.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
#include "mozilla/Move.h"
|
||||
#include "mozilla/dom/DOMException.h"
|
||||
#include "mozilla/dom/ErrorEventBinding.h"
|
||||
|
@ -30,7 +29,7 @@
|
|||
#include "nsContentUtils.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsString.h"
|
||||
#include "ReportInternalError.h"
|
||||
|
||||
|
@ -50,7 +49,7 @@ NS_DEFINE_IID(kIDBRequestIID, PRIVATE_IDBREQUEST_IID);
|
|||
} // namespace
|
||||
|
||||
IDBRequest::IDBRequest(IDBDatabase* aDatabase)
|
||||
: DOMEventTargetHelper(aDatabase),
|
||||
: IDBWrapperCache(aDatabase),
|
||||
mLoggingSerialNumber(0),
|
||||
mLineNo(0),
|
||||
mColumn(0),
|
||||
|
@ -61,8 +60,8 @@ IDBRequest::IDBRequest(IDBDatabase* aDatabase)
|
|||
InitMembers();
|
||||
}
|
||||
|
||||
IDBRequest::IDBRequest(nsIGlobalObject* aGlobal)
|
||||
: DOMEventTargetHelper(aGlobal),
|
||||
IDBRequest::IDBRequest(nsPIDOMWindowInner* aOwner)
|
||||
: IDBWrapperCache(aOwner),
|
||||
mLoggingSerialNumber(0),
|
||||
mLineNo(0),
|
||||
mColumn(0),
|
||||
|
@ -70,10 +69,7 @@ IDBRequest::IDBRequest(nsIGlobalObject* aGlobal)
|
|||
InitMembers();
|
||||
}
|
||||
|
||||
IDBRequest::~IDBRequest() {
|
||||
AssertIsOnOwningThread();
|
||||
mozilla::DropJSObjects(this);
|
||||
}
|
||||
IDBRequest::~IDBRequest() { AssertIsOnOwningThread(); }
|
||||
|
||||
void IDBRequest::InitMembers() {
|
||||
AssertIsOnOwningThread();
|
||||
|
@ -98,6 +94,7 @@ already_AddRefed<IDBRequest> IDBRequest::Create(JSContext* aCx,
|
|||
CaptureCaller(aCx, request->mFilename, &request->mLineNo, &request->mColumn);
|
||||
|
||||
request->mTransaction = aTransaction;
|
||||
request->SetScriptOwner(aDatabase->GetScriptOwner());
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
|
@ -184,7 +181,6 @@ void IDBRequest::Reset() {
|
|||
AssertIsOnOwningThread();
|
||||
|
||||
mResultVal.setUndefined();
|
||||
|
||||
mHaveResultOrErrorCode = false;
|
||||
mError = nullptr;
|
||||
}
|
||||
|
@ -280,16 +276,25 @@ void IDBRequest::SetResultCallback(ResultCallback* aCallback) {
|
|||
AutoJSAPI autoJS;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
|
||||
// Otherwise our owner is a window and we use that to initialize.
|
||||
MOZ_ASSERT(GetOwnerGlobal());
|
||||
if (!autoJS.Init(GetOwnerGlobal())) {
|
||||
IDB_WARNING("Failed to initialize AutoJSAPI!");
|
||||
SetError(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
return;
|
||||
if (GetScriptOwner()) {
|
||||
// If we have a script owner we want the SafeJSContext and then to enter the
|
||||
// script owner's realm.
|
||||
autoJS.Init();
|
||||
ar.emplace(autoJS.cx(), GetScriptOwner());
|
||||
} else {
|
||||
// Otherwise our owner is a window and we use that to initialize.
|
||||
MOZ_ASSERT(GetOwner());
|
||||
if (!autoJS.Init(GetOwner())) {
|
||||
IDB_WARNING("Failed to initialize AutoJSAPI!");
|
||||
SetError(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
JSContext* cx = autoJS.cx();
|
||||
|
||||
AssertIsRooted();
|
||||
|
||||
JS::Rooted<JS::Value> result(cx);
|
||||
nsresult rv = aCallback->GetResult(cx, &result);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
@ -305,9 +310,7 @@ void IDBRequest::SetResultCallback(ResultCallback* aCallback) {
|
|||
}
|
||||
|
||||
mError = nullptr;
|
||||
|
||||
mResultVal = result;
|
||||
mozilla::HoldJSObjects(this);
|
||||
|
||||
mHaveResultOrErrorCode = true;
|
||||
}
|
||||
|
@ -325,8 +328,7 @@ DOMException* IDBRequest::GetError(ErrorResult& aRv) {
|
|||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBRequest)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBRequest,
|
||||
DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceAsObjectStore)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceAsIndex)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceAsCursor)
|
||||
|
@ -334,10 +336,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBRequest,
|
|||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mError)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBRequest,
|
||||
DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
tmp->mResultVal.setUndefined();
|
||||
mozilla::DropJSObjects(tmp);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSourceAsObjectStore)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSourceAsIndex)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSourceAsCursor)
|
||||
|
@ -345,7 +345,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBRequest,
|
|||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mError)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(IDBRequest, DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
// Don't need NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER because
|
||||
// DOMEventTargetHelper does it for us.
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mResultVal)
|
||||
|
@ -355,10 +355,10 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBRequest)
|
|||
if (aIID.Equals(kIDBRequestIID)) {
|
||||
foundInterface = this;
|
||||
} else
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(IDBRequest, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBRequest, DOMEventTargetHelper)
|
||||
NS_IMPL_ADDREF_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
|
||||
void IDBRequest::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
|
||||
AssertIsOnOwningThread();
|
||||
|
@ -368,15 +368,16 @@ void IDBRequest::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
|
|||
}
|
||||
|
||||
IDBOpenDBRequest::IDBOpenDBRequest(IDBFactory* aFactory,
|
||||
nsIGlobalObject* aGlobal,
|
||||
nsPIDOMWindowInner* aOwner,
|
||||
bool aFileHandleDisabled)
|
||||
: IDBRequest(aGlobal),
|
||||
: IDBRequest(aOwner),
|
||||
mFactory(aFactory),
|
||||
mFileHandleDisabled(aFileHandleDisabled),
|
||||
mIncreasedActiveDatabaseCount(false) {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aFactory);
|
||||
MOZ_ASSERT(aGlobal);
|
||||
|
||||
// aOwner may be null.
|
||||
}
|
||||
|
||||
IDBOpenDBRequest::~IDBOpenDBRequest() {
|
||||
|
@ -385,18 +386,42 @@ IDBOpenDBRequest::~IDBOpenDBRequest() {
|
|||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<IDBOpenDBRequest> IDBOpenDBRequest::Create(
|
||||
JSContext* aCx, IDBFactory* aFactory, nsIGlobalObject* aGlobal) {
|
||||
already_AddRefed<IDBOpenDBRequest> IDBOpenDBRequest::CreateForWindow(
|
||||
JSContext* aCx, IDBFactory* aFactory, nsPIDOMWindowInner* aOwner,
|
||||
JS::Handle<JSObject*> aScriptOwner) {
|
||||
MOZ_ASSERT(aFactory);
|
||||
aFactory->AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aGlobal);
|
||||
MOZ_ASSERT(aOwner);
|
||||
MOZ_ASSERT(aScriptOwner);
|
||||
|
||||
bool fileHandleDisabled = !IndexedDatabaseManager::IsFileHandleEnabled();
|
||||
|
||||
RefPtr<IDBOpenDBRequest> request =
|
||||
new IDBOpenDBRequest(aFactory, aGlobal, fileHandleDisabled);
|
||||
new IDBOpenDBRequest(aFactory, aOwner, fileHandleDisabled);
|
||||
CaptureCaller(aCx, request->mFilename, &request->mLineNo, &request->mColumn);
|
||||
|
||||
request->SetScriptOwner(aScriptOwner);
|
||||
|
||||
request->IncreaseActiveDatabaseCount();
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<IDBOpenDBRequest> IDBOpenDBRequest::CreateForJS(
|
||||
JSContext* aCx, IDBFactory* aFactory, JS::Handle<JSObject*> aScriptOwner) {
|
||||
MOZ_ASSERT(aFactory);
|
||||
aFactory->AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aScriptOwner);
|
||||
|
||||
bool fileHandleDisabled = !IndexedDatabaseManager::IsFileHandleEnabled();
|
||||
|
||||
RefPtr<IDBOpenDBRequest> request =
|
||||
new IDBOpenDBRequest(aFactory, nullptr, fileHandleDisabled);
|
||||
CaptureCaller(aCx, request->mFilename, &request->mLineNo, &request->mColumn);
|
||||
|
||||
request->SetScriptOwner(aScriptOwner);
|
||||
|
||||
if (!NS_IsMainThread()) {
|
||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_ASSERT(workerPrivate);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "mozilla/dom/IDBRequestBinding.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/IDBWrapperCache.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
|||
} \
|
||||
}
|
||||
|
||||
class nsIGlobalObject;
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -42,7 +42,7 @@ struct Nullable;
|
|||
class OwningIDBObjectStoreOrIDBIndexOrIDBCursor;
|
||||
class StrongWorkerRef;
|
||||
|
||||
class IDBRequest : public DOMEventTargetHelper {
|
||||
class IDBRequest : public IDBWrapperCache {
|
||||
protected:
|
||||
// mSourceAsObjectStore and mSourceAsIndex are exclusive and one must always
|
||||
// be set. mSourceAsCursor is sometimes set also.
|
||||
|
@ -128,7 +128,7 @@ class IDBRequest : public DOMEventTargetHelper {
|
|||
|
||||
void SetLoggingSerialNumber(uint64_t aLoggingSerialNumber);
|
||||
|
||||
nsIGlobalObject* GetParentObject() const { return GetOwnerGlobal(); }
|
||||
nsPIDOMWindowInner* GetParentObject() const { return GetOwner(); }
|
||||
|
||||
void GetResult(JS::MutableHandle<JS::Value> aResult, ErrorResult& aRv) const;
|
||||
|
||||
|
@ -154,7 +154,7 @@ class IDBRequest : public DOMEventTargetHelper {
|
|||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(IDBRequest,
|
||||
DOMEventTargetHelper)
|
||||
IDBWrapperCache)
|
||||
|
||||
// nsWrapperCache
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
|
@ -162,7 +162,7 @@ class IDBRequest : public DOMEventTargetHelper {
|
|||
|
||||
protected:
|
||||
explicit IDBRequest(IDBDatabase* aDatabase);
|
||||
explicit IDBRequest(nsIGlobalObject* aGlobal);
|
||||
explicit IDBRequest(nsPIDOMWindowInner* aOwner);
|
||||
~IDBRequest();
|
||||
|
||||
void InitMembers();
|
||||
|
@ -189,9 +189,12 @@ class IDBOpenDBRequest final : public IDBRequest {
|
|||
bool mIncreasedActiveDatabaseCount;
|
||||
|
||||
public:
|
||||
static already_AddRefed<IDBOpenDBRequest> Create(JSContext* aCx,
|
||||
IDBFactory* aFactory,
|
||||
nsIGlobalObject* aGlobal);
|
||||
static already_AddRefed<IDBOpenDBRequest> CreateForWindow(
|
||||
JSContext* aCx, IDBFactory* aFactory, nsPIDOMWindowInner* aOwner,
|
||||
JS::Handle<JSObject*> aScriptOwner);
|
||||
|
||||
static already_AddRefed<IDBOpenDBRequest> CreateForJS(
|
||||
JSContext* aCx, IDBFactory* aFactory, JS::Handle<JSObject*> aScriptOwner);
|
||||
|
||||
bool IsFileHandleDisabled() const { return mFileHandleDisabled; }
|
||||
|
||||
|
@ -217,7 +220,7 @@ class IDBOpenDBRequest final : public IDBRequest {
|
|||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
private:
|
||||
IDBOpenDBRequest(IDBFactory* aFactory, nsIGlobalObject* aGlobal,
|
||||
IDBOpenDBRequest(IDBFactory* aFactory, nsPIDOMWindowInner* aOwner,
|
||||
bool aFileHandleDisabled);
|
||||
|
||||
~IDBOpenDBRequest();
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "IDBRequest.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
#include "mozilla/dom/DOMException.h"
|
||||
#include "mozilla/dom/DOMStringList.h"
|
||||
#include "mozilla/dom/WorkerRef.h"
|
||||
|
@ -40,7 +39,7 @@ using namespace mozilla::ipc;
|
|||
IDBTransaction::IDBTransaction(IDBDatabase* aDatabase,
|
||||
const nsTArray<nsString>& aObjectStoreNames,
|
||||
Mode aMode)
|
||||
: DOMEventTargetHelper(aDatabase),
|
||||
: IDBWrapperCache(aDatabase),
|
||||
mDatabase(aDatabase),
|
||||
mObjectStoreNames(aObjectStoreNames),
|
||||
mLoggingSerialNumber(0),
|
||||
|
@ -96,8 +95,6 @@ IDBTransaction::IDBTransaction(IDBDatabase* aDatabase,
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
mozilla::HoldJSObjects(this);
|
||||
}
|
||||
|
||||
IDBTransaction::~IDBTransaction() {
|
||||
|
@ -133,9 +130,6 @@ IDBTransaction::~IDBTransaction() {
|
|||
MOZ_ASSERT(!mBackgroundActor.mNormalBackgroundActor,
|
||||
"SendDeleteMeInternal should have cleared!");
|
||||
}
|
||||
|
||||
ReleaseWrapper(this);
|
||||
mozilla::DropJSObjects(this);
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -157,6 +151,8 @@ already_AddRefed<IDBTransaction> IDBTransaction::CreateVersionChange(
|
|||
aOpenRequest->GetCallerLocation(transaction->mFilename, &transaction->mLineNo,
|
||||
&transaction->mColumn);
|
||||
|
||||
transaction->SetScriptOwner(aDatabase->GetScriptOwner());
|
||||
|
||||
transaction->NoteActiveTransaction();
|
||||
|
||||
transaction->mBackgroundActor.mVersionChangeBackgroundActor = aActor;
|
||||
|
@ -184,6 +180,8 @@ already_AddRefed<IDBTransaction> IDBTransaction::Create(
|
|||
IDBRequest::CaptureCaller(aCx, transaction->mFilename, &transaction->mLineNo,
|
||||
&transaction->mColumn);
|
||||
|
||||
transaction->SetScriptOwner(aDatabase->GetScriptOwner());
|
||||
|
||||
if (!NS_IsMainThread()) {
|
||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_ASSERT(workerPrivate);
|
||||
|
@ -800,7 +798,7 @@ int64_t IDBTransaction::NextIndexId() {
|
|||
return mNextIndexId++;
|
||||
}
|
||||
|
||||
nsIGlobalObject* IDBTransaction::GetParentObject() const {
|
||||
nsPIDOMWindowInner* IDBTransaction::GetParentObject() const {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
return mDatabase->GetParentObject();
|
||||
|
@ -904,25 +902,24 @@ already_AddRefed<IDBObjectStore> IDBTransaction::ObjectStore(
|
|||
return objectStore.forget();
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(IDBTransaction, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBTransaction, DOMEventTargetHelper)
|
||||
NS_IMPL_ADDREF_INHERITED(IDBTransaction, IDBWrapperCache)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBTransaction, IDBWrapperCache)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBTransaction)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRunnable)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBTransaction)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBTransaction,
|
||||
DOMEventTargetHelper)
|
||||
IDBWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDatabase)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mError)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mObjectStores)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDeletedObjectStores)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBTransaction,
|
||||
DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBTransaction, IDBWrapperCache)
|
||||
// Don't unlink mDatabase!
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mError)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mObjectStores)
|
||||
|
|
|
@ -9,13 +9,15 @@
|
|||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/IDBTransactionBinding.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/IDBWrapperCache.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ErrorResult;
|
||||
|
@ -42,7 +44,7 @@ class OpenCursorParams;
|
|||
class RequestParams;
|
||||
} // namespace indexedDB
|
||||
|
||||
class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
|
||||
class IDBTransaction final : public IDBWrapperCache, public nsIRunnable {
|
||||
friend class indexedDB::BackgroundCursorChild;
|
||||
friend class indexedDB::BackgroundRequestChild;
|
||||
|
||||
|
@ -228,7 +230,7 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
|
|||
return mLoggingSerialNumber;
|
||||
}
|
||||
|
||||
nsIGlobalObject* GetParentObject() const;
|
||||
nsPIDOMWindowInner* GetParentObject() const;
|
||||
|
||||
IDBTransactionMode GetMode(ErrorResult& aRv) const;
|
||||
|
||||
|
@ -255,7 +257,7 @@ class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
|
|||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIRUNNABLE
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBTransaction, DOMEventTargetHelper)
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBTransaction, IDBWrapperCache)
|
||||
|
||||
// nsWrapperCache
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#include "IDBWrapperCache.h"
|
||||
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBWrapperCache)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBWrapperCache,
|
||||
DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBWrapperCache,
|
||||
DOMEventTargetHelper)
|
||||
if (tmp->mScriptOwner) {
|
||||
tmp->mScriptOwner = nullptr;
|
||||
mozilla::DropJSObjects(tmp);
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(IDBWrapperCache,
|
||||
DOMEventTargetHelper)
|
||||
// Don't need NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER because
|
||||
// DOMEventTargetHelper does it for us.
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mScriptOwner)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBWrapperCache)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(IDBWrapperCache, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBWrapperCache, DOMEventTargetHelper)
|
||||
|
||||
IDBWrapperCache::IDBWrapperCache(DOMEventTargetHelper* aOwner)
|
||||
: DOMEventTargetHelper(aOwner), mScriptOwner(nullptr) {}
|
||||
|
||||
IDBWrapperCache::IDBWrapperCache(nsPIDOMWindowInner* aOwner)
|
||||
: DOMEventTargetHelper(aOwner), mScriptOwner(nullptr) {}
|
||||
|
||||
IDBWrapperCache::~IDBWrapperCache() {
|
||||
mScriptOwner = nullptr;
|
||||
ReleaseWrapper(this);
|
||||
mozilla::DropJSObjects(this);
|
||||
}
|
||||
|
||||
void IDBWrapperCache::SetScriptOwner(JSObject* aScriptOwner) {
|
||||
MOZ_ASSERT(aScriptOwner);
|
||||
MOZ_ASSERT(JS_IsGlobalObject(aScriptOwner));
|
||||
|
||||
mScriptOwner = aScriptOwner;
|
||||
mozilla::HoldJSObjects(this);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void IDBWrapperCache::AssertIsRooted() const {
|
||||
MOZ_ASSERT(IsJSHolder(const_cast<IDBWrapperCache*>(this)),
|
||||
"Why aren't we rooted?!");
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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_idbwrappercache_h__
|
||||
#define mozilla_dom_idbwrappercache_h__
|
||||
|
||||
#include "js/RootingAPI.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsPIDOMWindowInnter;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class IDBWrapperCache : public DOMEventTargetHelper {
|
||||
JS::Heap<JSObject*> mScriptOwner;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(IDBWrapperCache,
|
||||
DOMEventTargetHelper)
|
||||
|
||||
JSObject* GetScriptOwner() const { return mScriptOwner; }
|
||||
|
||||
void SetScriptOwner(JSObject* aScriptOwner);
|
||||
|
||||
void AssertIsRooted() const
|
||||
#ifdef DEBUG
|
||||
;
|
||||
#else
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
explicit IDBWrapperCache(DOMEventTargetHelper* aOwner);
|
||||
explicit IDBWrapperCache(nsPIDOMWindowInner* aOwner);
|
||||
|
||||
virtual ~IDBWrapperCache();
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_idbwrappercache_h__
|
|
@ -101,7 +101,7 @@ using namespace mozilla::dom::indexedDB;
|
|||
|
||||
namespace {
|
||||
|
||||
NS_DEFINE_IID(kIDBPrivateRequestIID, PRIVATE_IDBREQUEST_IID);
|
||||
NS_DEFINE_IID(kIDBRequestIID, PRIVATE_IDBREQUEST_IID);
|
||||
|
||||
const uint32_t kDeleteTimeoutMs = 1000;
|
||||
|
||||
|
@ -370,7 +370,7 @@ nsresult IndexedDatabaseManager::CommonPostHandleEvent(
|
|||
|
||||
// Only mess with events that were originally targeted to an IDBRequest.
|
||||
RefPtr<IDBRequest> request;
|
||||
if (NS_FAILED(eventTarget->QueryInterface(kIDBPrivateRequestIID,
|
||||
if (NS_FAILED(eventTarget->QueryInterface(kIDBRequestIID,
|
||||
getter_AddRefs(request))) ||
|
||||
!request) {
|
||||
return NS_OK;
|
||||
|
@ -481,14 +481,9 @@ bool IndexedDatabaseManager::DefineIndexedDB(JSContext* aCx,
|
|||
MOZ_ASSERT(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL,
|
||||
"Passed object is not a global object!");
|
||||
|
||||
nsIGlobalObject* global = xpc::CurrentNativeGlobal(aCx);
|
||||
if (NS_WARN_IF(!global)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<IDBFactory> factory;
|
||||
if (NS_FAILED(
|
||||
IDBFactory::CreateForMainThreadJS(global, getter_AddRefs(factory)))) {
|
||||
if (NS_FAILED(IDBFactory::CreateForMainThreadJS(aCx, aGlobal,
|
||||
getter_AddRefs(factory)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,7 @@
|
|||
#include "xpcpublic.h"
|
||||
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/Blob.h"
|
||||
#include "mozilla/dom/BlobBinding.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/IDBObjectStoreBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "nsIDOMWindow.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -34,6 +34,7 @@ EXPORTS.mozilla.dom += [
|
|||
'IDBObjectStore.h',
|
||||
'IDBRequest.h',
|
||||
'IDBTransaction.h',
|
||||
'IDBWrapperCache.h',
|
||||
'IndexedDatabase.h',
|
||||
'IndexedDatabaseManager.h',
|
||||
]
|
||||
|
@ -63,6 +64,7 @@ UNIFIED_SOURCES += [
|
|||
'IDBObjectStore.cpp',
|
||||
'IDBRequest.cpp',
|
||||
'IDBTransaction.cpp',
|
||||
'IDBWrapperCache.cpp',
|
||||
'IndexedDatabaseManager.cpp',
|
||||
'KeyPath.cpp',
|
||||
'PermissionRequestBase.cpp',
|
||||
|
|
|
@ -395,9 +395,15 @@ already_AddRefed<IDBFactory> WorkerGlobalScope::GetIndexedDB(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
JSContext* cx = mWorkerPrivate->GetJSContext();
|
||||
MOZ_ASSERT(cx);
|
||||
|
||||
JS::Rooted<JSObject*> owningObject(cx, GetGlobalJSObject());
|
||||
MOZ_ASSERT(owningObject);
|
||||
|
||||
const PrincipalInfo& principalInfo = mWorkerPrivate->GetPrincipalInfo();
|
||||
|
||||
nsresult rv = IDBFactory::CreateForWorker(this, principalInfo,
|
||||
nsresult rv = IDBFactory::CreateForWorker(cx, owningObject, principalInfo,
|
||||
mWorkerPrivate->WindowID(),
|
||||
getter_AddRefs(indexedDB));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче