mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1539407
- Use the correct global for DOMEventTargetHelper in IndexedDB, r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D25041 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
26437cdd14
commit
da174a4757
@ -1153,7 +1153,7 @@ void nsGlobalWindowInner::FreeInnerObjects() {
|
||||
}
|
||||
|
||||
if (mIndexedDB) {
|
||||
mIndexedDB->DisconnectFromWindow(this);
|
||||
mIndexedDB->DisconnectFromGlobal(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->DisconnectFromWindow(tmp);
|
||||
tmp->mIndexedDB->DisconnectFromGlobal(tmp);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mIndexedDB)
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocumentPrincipal)
|
||||
|
@ -522,7 +522,8 @@ void DeserializeStructuredCloneFiles(
|
||||
RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(ipcBlob);
|
||||
MOZ_ASSERT(blobImpl);
|
||||
|
||||
RefPtr<Blob> blob = Blob::Create(aDatabase->GetOwner(), blobImpl);
|
||||
RefPtr<Blob> blob =
|
||||
Blob::Create(aDatabase->GetOwnerGlobal(), blobImpl);
|
||||
|
||||
StructuredCloneFile* file = aFiles.AppendElement();
|
||||
MOZ_ASSERT(file);
|
||||
@ -610,7 +611,8 @@ void DeserializeStructuredCloneFiles(
|
||||
RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(ipcBlob);
|
||||
MOZ_ASSERT(blobImpl);
|
||||
|
||||
RefPtr<Blob> blob = Blob::Create(aDatabase->GetOwner(), blobImpl);
|
||||
RefPtr<Blob> blob =
|
||||
Blob::Create(aDatabase->GetOwnerGlobal(), blobImpl);
|
||||
|
||||
StructuredCloneFile* file = aFiles.AppendElement();
|
||||
MOZ_ASSERT(file);
|
||||
@ -1225,7 +1227,8 @@ already_AddRefed<File> ConvertActorToFile(
|
||||
RefPtr<BlobImpl> blobImplSnapshot =
|
||||
new BlobImplSnapshot(blobImpl, static_cast<IDBFileHandle*>(aFileHandle));
|
||||
|
||||
RefPtr<File> file = File::Create(mutableFile->GetOwner(), blobImplSnapshot);
|
||||
RefPtr<File> file =
|
||||
File::Create(mutableFile->GetOwnerGlobal(), blobImplSnapshot);
|
||||
return file.forget();
|
||||
}
|
||||
|
||||
@ -1677,7 +1680,8 @@ mozilla::ipc::IPCResult BackgroundFactoryRequestChild::RecvPermissionChallenge(
|
||||
}
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = mFactory->GetParentObject();
|
||||
nsCOMPtr<nsIGlobalObject> global = mFactory->GetParentObject();
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(global);
|
||||
MOZ_ASSERT(window);
|
||||
|
||||
nsCOMPtr<Element> ownerElement =
|
||||
|
@ -34,7 +34,6 @@ 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()),
|
||||
@ -55,12 +54,6 @@ 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 {
|
||||
@ -190,7 +183,6 @@ void IDBCursor::DropJSObjects() {
|
||||
return;
|
||||
}
|
||||
|
||||
mScriptOwner = nullptr;
|
||||
mRooted = false;
|
||||
|
||||
mozilla::DropJSObjects(this);
|
||||
@ -234,7 +226,7 @@ void IDBCursor::Reset() {
|
||||
mContinueCalled = false;
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* IDBCursor::GetParentObject() const {
|
||||
nsIGlobalObject* IDBCursor::GetParentObject() const {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(mTransaction);
|
||||
|
||||
@ -873,7 +865,6 @@ 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 nsPIDOMWindowInner;
|
||||
class nsIGlobalObject;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -65,8 +65,6 @@ 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;
|
||||
@ -114,7 +112,7 @@ class IDBCursor final : public nsISupports, public nsWrapperCache {
|
||||
}
|
||||
#endif
|
||||
|
||||
nsPIDOMWindowInner* GetParentObject() const;
|
||||
nsIGlobalObject* 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)
|
||||
: IDBWrapperCache(aRequest),
|
||||
: DOMEventTargetHelper(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()) {
|
||||
if (nsPIDOMWindowInner* window = aFactory->GetParentObject()) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> window =
|
||||
do_QueryInterface(aFactory->GetParentObject());
|
||||
if (window) {
|
||||
uint64_t windowId = window->WindowID();
|
||||
|
||||
RefPtr<Observer> observer = new Observer(db, windowId);
|
||||
@ -318,10 +318,6 @@ void IDBDatabase::RefreshSpec(bool aMayDelete) {
|
||||
}
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* IDBDatabase::GetParentObject() const {
|
||||
return mFactory->GetParentObject();
|
||||
}
|
||||
|
||||
const nsString& IDBDatabase::Name() const {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(mSpec);
|
||||
@ -1060,20 +1056,22 @@ void IDBDatabase::LogWarning(const char* aMessageName,
|
||||
mFactory->InnerWindowID());
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(IDBDatabase, IDBWrapperCache)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBDatabase, IDBWrapperCache)
|
||||
NS_IMPL_ADDREF_INHERITED(IDBDatabase, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBDatabase, DOMEventTargetHelper)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBDatabase)
|
||||
NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBDatabase)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBDatabase, IDBWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBDatabase,
|
||||
DOMEventTargetHelper)
|
||||
tmp->AssertIsOnOwningThread();
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFactory)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBDatabase, IDBWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBDatabase,
|
||||
DOMEventTargetHelper)
|
||||
tmp->AssertIsOnOwningThread();
|
||||
|
||||
// Don't unlink mFactory!
|
||||
@ -1085,7 +1083,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
void IDBDatabase::DisconnectFromOwner() {
|
||||
InvalidateInternal();
|
||||
IDBWrapperCache::DisconnectFromOwner();
|
||||
DOMEventTargetHelper::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 nsPIDOMWindowInner;
|
||||
class nsIGlobalObject;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -47,7 +47,7 @@ class DatabaseSpec;
|
||||
class PBackgroundIDBDatabaseFileChild;
|
||||
} // namespace indexedDB
|
||||
|
||||
class IDBDatabase final : public IDBWrapperCache {
|
||||
class IDBDatabase final : public DOMEventTargetHelper {
|
||||
typedef mozilla::dom::indexedDB::DatabaseSpec DatabaseSpec;
|
||||
typedef mozilla::dom::StorageType StorageType;
|
||||
typedef mozilla::dom::quota::PersistenceType PersistenceType;
|
||||
@ -178,8 +178,6 @@ class IDBDatabase final : public IDBWrapperCache {
|
||||
|
||||
void NoteFinishedMutableFile(IDBMutableFile* aMutableFile);
|
||||
|
||||
nsPIDOMWindowInner* GetParentObject() const;
|
||||
|
||||
already_AddRefed<DOMStringList> ObjectStoreNames() const;
|
||||
|
||||
already_AddRefed<IDBObjectStore> CreateObjectStore(
|
||||
@ -228,7 +226,7 @@ class IDBDatabase final : public IDBWrapperCache {
|
||||
const DatabaseSpec* Spec() const { return mSpec; }
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBDatabase, IDBWrapperCache)
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBDatabase, DOMEventTargetHelper)
|
||||
|
||||
// DOMEventTargetHelper
|
||||
void DisconnectFromOwner() override;
|
||||
|
@ -70,8 +70,7 @@ struct IDBFactory::PendingRequestInfo {
|
||||
};
|
||||
|
||||
IDBFactory::IDBFactory()
|
||||
: mOwningObject(nullptr),
|
||||
mBackgroundActor(nullptr),
|
||||
: mBackgroundActor(nullptr),
|
||||
mInnerWindowID(0),
|
||||
mActiveTransactionCount(0),
|
||||
mActiveDatabaseCount(0),
|
||||
@ -83,9 +82,6 @@ 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!");
|
||||
@ -143,7 +139,10 @@ nsresult IDBFactory::CreateForWindow(nsPIDOMWindowInner* aWindow,
|
||||
|
||||
RefPtr<IDBFactory> factory = new IDBFactory();
|
||||
factory->mPrincipalInfo = std::move(principalInfo);
|
||||
factory->mWindow = aWindow;
|
||||
|
||||
factory->mGlobal = do_QueryInterface(aWindow);
|
||||
MOZ_ASSERT(factory->mGlobal);
|
||||
|
||||
factory->mTabChild = TabChild::GetFrom(aWindow);
|
||||
factory->mEventTarget =
|
||||
nsGlobalWindowInner::Cast(aWindow)->EventTargetFor(TaskCategory::Other);
|
||||
@ -156,13 +155,18 @@ nsresult IDBFactory::CreateForWindow(nsPIDOMWindowInner* aWindow,
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult IDBFactory::CreateForMainThreadJS(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aOwningObject,
|
||||
nsresult IDBFactory::CreateForMainThreadJS(nsIGlobalObject* aGlobal,
|
||||
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 = nsContentUtils::ObjectPrincipal(aOwningObject);
|
||||
nsIPrincipal* principal = sop->GetPrincipal();
|
||||
MOZ_ASSERT(principal);
|
||||
bool isSystem;
|
||||
if (!AllowedForPrincipal(principal, &isSystem)) {
|
||||
@ -178,8 +182,7 @@ nsresult IDBFactory::CreateForMainThreadJS(JSContext* aCx,
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
rv = CreateForMainThreadJSInternal(aCx, aOwningObject, principalInfo,
|
||||
aFactory);
|
||||
rv = CreateForMainThreadJSInternal(aGlobal, principalInfo, aFactory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -190,18 +193,18 @@ nsresult IDBFactory::CreateForMainThreadJS(JSContext* aCx,
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult IDBFactory::CreateForWorker(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aOwningObject,
|
||||
nsresult IDBFactory::CreateForWorker(nsIGlobalObject* aGlobal,
|
||||
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 = CreateForJSInternal(aCx, aOwningObject, principalInfo,
|
||||
aInnerWindowID, aFactory);
|
||||
nsresult rv =
|
||||
CreateInternal(aGlobal, principalInfo, aInnerWindowID, aFactory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -213,9 +216,10 @@ nsresult IDBFactory::CreateForWorker(JSContext* aCx,
|
||||
|
||||
// static
|
||||
nsresult IDBFactory::CreateForMainThreadJSInternal(
|
||||
JSContext* aCx, JS::Handle<JSObject*> aOwningObject,
|
||||
nsAutoPtr<PrincipalInfo>& aPrincipalInfo, IDBFactory** aFactory) {
|
||||
nsIGlobalObject* aGlobal, nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
|
||||
IDBFactory** aFactory) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aGlobal);
|
||||
MOZ_ASSERT(aPrincipalInfo);
|
||||
|
||||
if (aPrincipalInfo->type() != PrincipalInfo::TSystemPrincipalInfo &&
|
||||
@ -230,8 +234,8 @@ nsresult IDBFactory::CreateForMainThreadJSInternal(
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
nsresult rv = CreateForJSInternal(aCx, aOwningObject, aPrincipalInfo,
|
||||
/* aInnerWindowID */ 0, aFactory);
|
||||
nsresult rv =
|
||||
CreateInternal(aGlobal, aPrincipalInfo, /* aInnerWindowID */ 0, aFactory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -240,16 +244,14 @@ nsresult IDBFactory::CreateForMainThreadJSInternal(
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult IDBFactory::CreateForJSInternal(
|
||||
JSContext* aCx, JS::Handle<JSObject*> aOwningObject,
|
||||
nsAutoPtr<PrincipalInfo>& aPrincipalInfo, uint64_t aInnerWindowID,
|
||||
IDBFactory** aFactory) {
|
||||
MOZ_ASSERT(aCx);
|
||||
MOZ_ASSERT(aOwningObject);
|
||||
nsresult IDBFactory::CreateInternal(nsIGlobalObject* aGlobal,
|
||||
nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
|
||||
uint64_t aInnerWindowID,
|
||||
IDBFactory** aFactory) {
|
||||
MOZ_ASSERT(aGlobal);
|
||||
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) {
|
||||
@ -261,8 +263,7 @@ nsresult IDBFactory::CreateForJSInternal(
|
||||
|
||||
RefPtr<IDBFactory> factory = new IDBFactory();
|
||||
factory->mPrincipalInfo = aPrincipalInfo.forget();
|
||||
factory->mOwningObject = aOwningObject;
|
||||
mozilla::HoldJSObjects(factory.get());
|
||||
factory->mGlobal = aGlobal;
|
||||
factory->mEventTarget = GetCurrentThreadEventTarget();
|
||||
factory->mInnerWindowID = aInnerWindowID;
|
||||
|
||||
@ -377,8 +378,9 @@ void IDBFactory::UpdateActiveTransactionCount(int32_t aDelta) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(aDelta > 0 || (mActiveTransactionCount + aDelta) <
|
||||
mActiveTransactionCount);
|
||||
mActiveTransactionCount += aDelta;
|
||||
if (mWindow) {
|
||||
mWindow->UpdateActiveIndexedDBTransactionCount(aDelta);
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(mGlobal);
|
||||
if (window) {
|
||||
window->UpdateActiveIndexedDBTransactionCount(aDelta);
|
||||
}
|
||||
}
|
||||
|
||||
@ -387,8 +389,10 @@ void IDBFactory::UpdateActiveDatabaseCount(int32_t aDelta) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(aDelta > 0 ||
|
||||
(mActiveDatabaseCount + aDelta) < mActiveDatabaseCount);
|
||||
mActiveDatabaseCount += aDelta;
|
||||
if (mWindow) {
|
||||
mWindow->UpdateActiveIndexedDBDatabaseCount(aDelta);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(mGlobal);
|
||||
if (window) {
|
||||
window->UpdateActiveIndexedDBDatabaseCount(aDelta);
|
||||
}
|
||||
}
|
||||
|
||||
@ -421,8 +425,9 @@ already_AddRefed<IDBOpenDBRequest> IDBFactory::Open(
|
||||
JSContext* aCx, const nsAString& aName, const IDBOpenDBOptions& aOptions,
|
||||
CallerType aCallerType, ErrorResult& aRv) {
|
||||
if (!IsChrome() && aOptions.mStorage.WasPassed()) {
|
||||
if (mWindow && mWindow->GetExtantDoc()) {
|
||||
mWindow->GetExtantDoc()->WarnOnceAbout(
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(mGlobal);
|
||||
if (window && window->GetExtantDoc()) {
|
||||
window->GetExtantDoc()->WarnOnceAbout(
|
||||
Document::eIDBOpenDBOptions_StorageType);
|
||||
} else if (!NS_IsMainThread()) {
|
||||
// The method below reports on the main thread too, so we need to make
|
||||
@ -563,8 +568,7 @@ already_AddRefed<IDBOpenDBRequest> IDBFactory::OpenInternal(
|
||||
const Optional<uint64_t>& aVersion,
|
||||
const Optional<StorageType>& aStorageType, bool aDeleting,
|
||||
CallerType aCallerType, ErrorResult& aRv) {
|
||||
MOZ_ASSERT(mWindow || mOwningObject);
|
||||
MOZ_ASSERT_IF(!mWindow, !mPrivateBrowsingMode);
|
||||
MOZ_ASSERT(mGlobal);
|
||||
|
||||
CommonFactoryRequestParams commonParams;
|
||||
|
||||
@ -724,24 +728,12 @@ already_AddRefed<IDBOpenDBRequest> IDBFactory::OpenInternal(
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
RefPtr<IDBOpenDBRequest> request =
|
||||
IDBOpenDBRequest::Create(aCx, this, mGlobal);
|
||||
if (!request) {
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
aRv.ThrowUncatchableException();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(request);
|
||||
@ -817,12 +809,12 @@ nsresult IDBFactory::InitiateRequest(IDBOpenDBRequest* aRequest,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
mWindow = nullptr;
|
||||
mGlobal = nullptr;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(IDBFactory)
|
||||
@ -836,22 +828,20 @@ NS_INTERFACE_MAP_END
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBFactory)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBFactory)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal)
|
||||
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
|
||||
tmp->mOwningObject = nullptr;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindow)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal)
|
||||
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,6 +18,7 @@
|
||||
#include "nsTArray.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsIGlobalObject;
|
||||
class nsIEventTarget;
|
||||
class nsIPrincipal;
|
||||
class nsPIDOMWindowInner;
|
||||
@ -58,10 +59,7 @@ class IDBFactory final : public nsISupports, public nsWrapperCache {
|
||||
|
||||
nsAutoPtr<PrincipalInfo> mPrincipalInfo;
|
||||
|
||||
// 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;
|
||||
nsCOMPtr<nsIGlobalObject> mGlobal;
|
||||
|
||||
// This will only be set if the factory belongs to a window in a child
|
||||
// process.
|
||||
@ -84,12 +82,10 @@ class IDBFactory final : public nsISupports, public nsWrapperCache {
|
||||
static nsresult CreateForWindow(nsPIDOMWindowInner* aWindow,
|
||||
IDBFactory** aFactory);
|
||||
|
||||
static nsresult CreateForMainThreadJS(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aOwningObject,
|
||||
static nsresult CreateForMainThreadJS(nsIGlobalObject* aGlobal,
|
||||
IDBFactory** aFactory);
|
||||
|
||||
static nsresult CreateForWorker(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aOwningObject,
|
||||
static nsresult CreateForWorker(nsIGlobalObject* aGlobal,
|
||||
const PrincipalInfo& aPrincipalInfo,
|
||||
uint64_t aInnerWindowID,
|
||||
IDBFactory** aFactory);
|
||||
@ -127,7 +123,7 @@ class IDBFactory final : public nsISupports, public nsWrapperCache {
|
||||
|
||||
void IncrementParentLoggingRequestSerialNumber();
|
||||
|
||||
nsPIDOMWindowInner* GetParentObject() const { return mWindow; }
|
||||
nsIGlobalObject* GetParentObject() const { return mGlobal; }
|
||||
|
||||
TabChild* GetTabChild() const { return mTabChild; }
|
||||
|
||||
@ -178,7 +174,7 @@ class IDBFactory final : public nsISupports, public nsWrapperCache {
|
||||
const IDBOpenDBOptions& aOptions, SystemCallerGuarantee,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void DisconnectFromWindow(nsPIDOMWindowInner* aOldWindow);
|
||||
void DisconnectFromGlobal(nsIGlobalObject* aOldGlobal);
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBFactory)
|
||||
@ -192,14 +188,13 @@ class IDBFactory final : public nsISupports, public nsWrapperCache {
|
||||
~IDBFactory();
|
||||
|
||||
static nsresult CreateForMainThreadJSInternal(
|
||||
JSContext* aCx, JS::Handle<JSObject*> aOwningObject,
|
||||
nsAutoPtr<PrincipalInfo>& aPrincipalInfo, IDBFactory** aFactory);
|
||||
nsIGlobalObject* aGlobal, nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
|
||||
IDBFactory** aFactory);
|
||||
|
||||
static nsresult CreateForJSInternal(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aOwningObject,
|
||||
nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
|
||||
uint64_t aInnerWindowID,
|
||||
IDBFactory** aFactory);
|
||||
static nsresult CreateInternal(nsIGlobalObject* aGlobal,
|
||||
nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
|
||||
uint64_t aInnerWindowID,
|
||||
IDBFactory** aFactory);
|
||||
|
||||
static nsresult AllowedForWindowInternal(nsPIDOMWindowInner* aWindow,
|
||||
nsIPrincipal** aPrincipal);
|
||||
|
@ -16,8 +16,6 @@
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
@ -112,11 +110,6 @@ 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->GetOwner()),
|
||||
: DOMRequest(aFileHandle->GetOwnerGlobal()),
|
||||
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(GetOwner()))) {
|
||||
if (NS_WARN_IF(!autoJS.Init(GetOwnerGlobal()))) {
|
||||
FireError(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
|
||||
return;
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ bool IDBIndex::IsAutoLocale() const {
|
||||
return mMetadata->autoLocale();
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* IDBIndex::GetParentObject() const {
|
||||
nsIGlobalObject* IDBIndex::GetParentObject() const {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
return mObjectStore->GetParentObject();
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "nsTArrayForwardDeclare.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsPIDOMWindowInner;
|
||||
class nsIGlobalObject;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -83,7 +83,7 @@ class IDBIndex final : public nsISupports, public nsWrapperCache {
|
||||
return mObjectStore;
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* GetParentObject() const;
|
||||
nsIGlobalObject* GetParentObject() const;
|
||||
|
||||
void GetName(nsString& aName) const { aName = Name(); }
|
||||
|
||||
|
@ -17,8 +17,6 @@
|
||||
#include "nsString.h"
|
||||
#include "nsTHashtable.h"
|
||||
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ErrorResult;
|
||||
@ -105,8 +103,6 @@ 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);
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* IDBObjectStore::GetParentObject() const {
|
||||
nsIGlobalObject* IDBObjectStore::GetParentObject() const {
|
||||
return mTransaction->GetParentObject();
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
struct JSClass;
|
||||
class nsPIDOMWindowInner;
|
||||
class nsIGlobalObject;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -137,7 +137,7 @@ class IDBObjectStore final : public nsISupports, public nsWrapperCache {
|
||||
|
||||
bool HasValidKeyPath() const;
|
||||
|
||||
nsPIDOMWindowInner* GetParentObject() const;
|
||||
nsIGlobalObject* GetParentObject() const;
|
||||
|
||||
void GetName(nsString& aName) const {
|
||||
AssertIsOnOwningThread();
|
||||
|
@ -18,6 +18,7 @@
|
||||
#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"
|
||||
@ -29,7 +30,7 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
#include "nsString.h"
|
||||
#include "ReportInternalError.h"
|
||||
|
||||
@ -49,7 +50,7 @@ NS_DEFINE_IID(kIDBRequestIID, PRIVATE_IDBREQUEST_IID);
|
||||
} // namespace
|
||||
|
||||
IDBRequest::IDBRequest(IDBDatabase* aDatabase)
|
||||
: IDBWrapperCache(aDatabase),
|
||||
: DOMEventTargetHelper(aDatabase),
|
||||
mLoggingSerialNumber(0),
|
||||
mLineNo(0),
|
||||
mColumn(0),
|
||||
@ -60,8 +61,8 @@ IDBRequest::IDBRequest(IDBDatabase* aDatabase)
|
||||
InitMembers();
|
||||
}
|
||||
|
||||
IDBRequest::IDBRequest(nsPIDOMWindowInner* aOwner)
|
||||
: IDBWrapperCache(aOwner),
|
||||
IDBRequest::IDBRequest(nsIGlobalObject* aGlobal)
|
||||
: DOMEventTargetHelper(aGlobal),
|
||||
mLoggingSerialNumber(0),
|
||||
mLineNo(0),
|
||||
mColumn(0),
|
||||
@ -69,7 +70,10 @@ IDBRequest::IDBRequest(nsPIDOMWindowInner* aOwner)
|
||||
InitMembers();
|
||||
}
|
||||
|
||||
IDBRequest::~IDBRequest() { AssertIsOnOwningThread(); }
|
||||
IDBRequest::~IDBRequest() {
|
||||
AssertIsOnOwningThread();
|
||||
mozilla::DropJSObjects(this);
|
||||
}
|
||||
|
||||
void IDBRequest::InitMembers() {
|
||||
AssertIsOnOwningThread();
|
||||
@ -94,7 +98,6 @@ 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();
|
||||
}
|
||||
@ -181,6 +184,7 @@ void IDBRequest::Reset() {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
mResultVal.setUndefined();
|
||||
|
||||
mHaveResultOrErrorCode = false;
|
||||
mError = nullptr;
|
||||
}
|
||||
@ -267,6 +271,12 @@ void IDBRequest::SetResultCallback(ResultCallback* aCallback) {
|
||||
MOZ_ASSERT(mResultVal.isUndefined());
|
||||
MOZ_ASSERT(!mError);
|
||||
|
||||
// Already disconnected from the owner.
|
||||
if (!GetOwnerGlobal()) {
|
||||
SetError(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
// See if our window is still valid.
|
||||
if (NS_WARN_IF(NS_FAILED(CheckInnerWindowCorrectness()))) {
|
||||
SetError(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
@ -274,27 +284,14 @@ void IDBRequest::SetResultCallback(ResultCallback* aCallback) {
|
||||
}
|
||||
|
||||
AutoJSAPI autoJS;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
|
||||
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;
|
||||
}
|
||||
if (!autoJS.Init(GetOwnerGlobal())) {
|
||||
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))) {
|
||||
@ -310,7 +307,9 @@ void IDBRequest::SetResultCallback(ResultCallback* aCallback) {
|
||||
}
|
||||
|
||||
mError = nullptr;
|
||||
|
||||
mResultVal = result;
|
||||
mozilla::HoldJSObjects(this);
|
||||
|
||||
mHaveResultOrErrorCode = true;
|
||||
}
|
||||
@ -328,7 +327,8 @@ DOMException* IDBRequest::GetError(ErrorResult& aRv) {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBRequest)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBRequest,
|
||||
DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceAsObjectStore)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceAsIndex)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceAsCursor)
|
||||
@ -336,8 +336,10 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mError)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBRequest,
|
||||
DOMEventTargetHelper)
|
||||
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 +347,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mError)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(IDBRequest, 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(mResultVal)
|
||||
@ -355,10 +357,10 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBRequest)
|
||||
if (aIID.Equals(kIDBRequestIID)) {
|
||||
foundInterface = this;
|
||||
} else
|
||||
NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
NS_IMPL_ADDREF_INHERITED(IDBRequest, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBRequest, DOMEventTargetHelper)
|
||||
|
||||
void IDBRequest::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
|
||||
AssertIsOnOwningThread();
|
||||
@ -368,16 +370,15 @@ void IDBRequest::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
|
||||
}
|
||||
|
||||
IDBOpenDBRequest::IDBOpenDBRequest(IDBFactory* aFactory,
|
||||
nsPIDOMWindowInner* aOwner,
|
||||
nsIGlobalObject* aGlobal,
|
||||
bool aFileHandleDisabled)
|
||||
: IDBRequest(aOwner),
|
||||
: IDBRequest(aGlobal),
|
||||
mFactory(aFactory),
|
||||
mFileHandleDisabled(aFileHandleDisabled),
|
||||
mIncreasedActiveDatabaseCount(false) {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aFactory);
|
||||
|
||||
// aOwner may be null.
|
||||
MOZ_ASSERT(aGlobal);
|
||||
}
|
||||
|
||||
IDBOpenDBRequest::~IDBOpenDBRequest() {
|
||||
@ -386,42 +387,18 @@ IDBOpenDBRequest::~IDBOpenDBRequest() {
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<IDBOpenDBRequest> IDBOpenDBRequest::CreateForWindow(
|
||||
JSContext* aCx, IDBFactory* aFactory, nsPIDOMWindowInner* aOwner,
|
||||
JS::Handle<JSObject*> aScriptOwner) {
|
||||
already_AddRefed<IDBOpenDBRequest> IDBOpenDBRequest::Create(
|
||||
JSContext* aCx, IDBFactory* aFactory, nsIGlobalObject* aGlobal) {
|
||||
MOZ_ASSERT(aFactory);
|
||||
aFactory->AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aOwner);
|
||||
MOZ_ASSERT(aScriptOwner);
|
||||
MOZ_ASSERT(aGlobal);
|
||||
|
||||
bool fileHandleDisabled = !IndexedDatabaseManager::IsFileHandleEnabled();
|
||||
|
||||
RefPtr<IDBOpenDBRequest> request =
|
||||
new IDBOpenDBRequest(aFactory, aOwner, fileHandleDisabled);
|
||||
new IDBOpenDBRequest(aFactory, aGlobal, 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/dom/IDBWrapperCache.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
} \
|
||||
}
|
||||
|
||||
class nsPIDOMWindowInner;
|
||||
class nsIGlobalObject;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -42,7 +42,7 @@ struct Nullable;
|
||||
class OwningIDBObjectStoreOrIDBIndexOrIDBCursor;
|
||||
class StrongWorkerRef;
|
||||
|
||||
class IDBRequest : public IDBWrapperCache {
|
||||
class IDBRequest : public DOMEventTargetHelper {
|
||||
protected:
|
||||
// mSourceAsObjectStore and mSourceAsIndex are exclusive and one must always
|
||||
// be set. mSourceAsCursor is sometimes set also.
|
||||
@ -128,7 +128,7 @@ class IDBRequest : public IDBWrapperCache {
|
||||
|
||||
void SetLoggingSerialNumber(uint64_t aLoggingSerialNumber);
|
||||
|
||||
nsPIDOMWindowInner* GetParentObject() const { return GetOwner(); }
|
||||
nsIGlobalObject* GetParentObject() const { return GetOwnerGlobal(); }
|
||||
|
||||
void GetResult(JS::MutableHandle<JS::Value> aResult, ErrorResult& aRv) const;
|
||||
|
||||
@ -154,7 +154,7 @@ class IDBRequest : public IDBWrapperCache {
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(IDBRequest,
|
||||
IDBWrapperCache)
|
||||
DOMEventTargetHelper)
|
||||
|
||||
// nsWrapperCache
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
@ -162,7 +162,7 @@ class IDBRequest : public IDBWrapperCache {
|
||||
|
||||
protected:
|
||||
explicit IDBRequest(IDBDatabase* aDatabase);
|
||||
explicit IDBRequest(nsPIDOMWindowInner* aOwner);
|
||||
explicit IDBRequest(nsIGlobalObject* aGlobal);
|
||||
~IDBRequest();
|
||||
|
||||
void InitMembers();
|
||||
@ -189,12 +189,9 @@ class IDBOpenDBRequest final : public IDBRequest {
|
||||
bool mIncreasedActiveDatabaseCount;
|
||||
|
||||
public:
|
||||
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);
|
||||
static already_AddRefed<IDBOpenDBRequest> Create(JSContext* aCx,
|
||||
IDBFactory* aFactory,
|
||||
nsIGlobalObject* aGlobal);
|
||||
|
||||
bool IsFileHandleDisabled() const { return mFileHandleDisabled; }
|
||||
|
||||
@ -220,7 +217,7 @@ class IDBOpenDBRequest final : public IDBRequest {
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
private:
|
||||
IDBOpenDBRequest(IDBFactory* aFactory, nsPIDOMWindowInner* aOwner,
|
||||
IDBOpenDBRequest(IDBFactory* aFactory, nsIGlobalObject* aGlobal,
|
||||
bool aFileHandleDisabled);
|
||||
|
||||
~IDBOpenDBRequest();
|
||||
|
@ -13,6 +13,7 @@
|
||||
#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"
|
||||
@ -39,7 +40,7 @@ using namespace mozilla::ipc;
|
||||
IDBTransaction::IDBTransaction(IDBDatabase* aDatabase,
|
||||
const nsTArray<nsString>& aObjectStoreNames,
|
||||
Mode aMode)
|
||||
: IDBWrapperCache(aDatabase),
|
||||
: DOMEventTargetHelper(aDatabase),
|
||||
mDatabase(aDatabase),
|
||||
mObjectStoreNames(aObjectStoreNames),
|
||||
mLoggingSerialNumber(0),
|
||||
@ -95,6 +96,8 @@ IDBTransaction::IDBTransaction(IDBDatabase* aDatabase,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
mozilla::HoldJSObjects(this);
|
||||
}
|
||||
|
||||
IDBTransaction::~IDBTransaction() {
|
||||
@ -130,6 +133,9 @@ IDBTransaction::~IDBTransaction() {
|
||||
MOZ_ASSERT(!mBackgroundActor.mNormalBackgroundActor,
|
||||
"SendDeleteMeInternal should have cleared!");
|
||||
}
|
||||
|
||||
ReleaseWrapper(this);
|
||||
mozilla::DropJSObjects(this);
|
||||
}
|
||||
|
||||
// static
|
||||
@ -151,8 +157,6 @@ already_AddRefed<IDBTransaction> IDBTransaction::CreateVersionChange(
|
||||
aOpenRequest->GetCallerLocation(transaction->mFilename, &transaction->mLineNo,
|
||||
&transaction->mColumn);
|
||||
|
||||
transaction->SetScriptOwner(aDatabase->GetScriptOwner());
|
||||
|
||||
transaction->NoteActiveTransaction();
|
||||
|
||||
transaction->mBackgroundActor.mVersionChangeBackgroundActor = aActor;
|
||||
@ -180,8 +184,6 @@ 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);
|
||||
@ -798,7 +800,7 @@ int64_t IDBTransaction::NextIndexId() {
|
||||
return mNextIndexId++;
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* IDBTransaction::GetParentObject() const {
|
||||
nsIGlobalObject* IDBTransaction::GetParentObject() const {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
return mDatabase->GetParentObject();
|
||||
@ -902,24 +904,25 @@ already_AddRefed<IDBObjectStore> IDBTransaction::ObjectStore(
|
||||
return objectStore.forget();
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(IDBTransaction, IDBWrapperCache)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBTransaction, IDBWrapperCache)
|
||||
NS_IMPL_ADDREF_INHERITED(IDBTransaction, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBTransaction, DOMEventTargetHelper)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBTransaction)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRunnable)
|
||||
NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBTransaction)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBTransaction,
|
||||
IDBWrapperCache)
|
||||
DOMEventTargetHelper)
|
||||
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, IDBWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBTransaction,
|
||||
DOMEventTargetHelper)
|
||||
// Don't unlink mDatabase!
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mError)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mObjectStores)
|
||||
|
@ -9,15 +9,13 @@
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/IDBTransactionBinding.h"
|
||||
#include "mozilla/dom/IDBWrapperCache.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ErrorResult;
|
||||
@ -44,7 +42,7 @@ class OpenCursorParams;
|
||||
class RequestParams;
|
||||
} // namespace indexedDB
|
||||
|
||||
class IDBTransaction final : public IDBWrapperCache, public nsIRunnable {
|
||||
class IDBTransaction final : public DOMEventTargetHelper, public nsIRunnable {
|
||||
friend class indexedDB::BackgroundCursorChild;
|
||||
friend class indexedDB::BackgroundRequestChild;
|
||||
|
||||
@ -230,7 +228,7 @@ class IDBTransaction final : public IDBWrapperCache, public nsIRunnable {
|
||||
return mLoggingSerialNumber;
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* GetParentObject() const;
|
||||
nsIGlobalObject* GetParentObject() const;
|
||||
|
||||
IDBTransactionMode GetMode(ErrorResult& aRv) const;
|
||||
|
||||
@ -257,7 +255,7 @@ class IDBTransaction final : public IDBWrapperCache, public nsIRunnable {
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIRUNNABLE
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBTransaction, IDBWrapperCache)
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBTransaction, DOMEventTargetHelper)
|
||||
|
||||
// nsWrapperCache
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
|
@ -1,72 +0,0 @@
|
||||
/* -*- 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
|
@ -1,50 +0,0 @@
|
||||
/* -*- 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(kIDBRequestIID, PRIVATE_IDBREQUEST_IID);
|
||||
NS_DEFINE_IID(kIDBPrivateRequestIID, 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(kIDBRequestIID,
|
||||
if (NS_FAILED(eventTarget->QueryInterface(kIDBPrivateRequestIID,
|
||||
getter_AddRefs(request))) ||
|
||||
!request) {
|
||||
return NS_OK;
|
||||
@ -481,9 +481,14 @@ 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(aCx, aGlobal,
|
||||
getter_AddRefs(factory)))) {
|
||||
if (NS_FAILED(
|
||||
IDBFactory::CreateForMainThreadJS(global, getter_AddRefs(factory)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,9 @@
|
||||
#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,7 +13,6 @@
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -34,7 +34,6 @@ EXPORTS.mozilla.dom += [
|
||||
'IDBObjectStore.h',
|
||||
'IDBRequest.h',
|
||||
'IDBTransaction.h',
|
||||
'IDBWrapperCache.h',
|
||||
'IndexedDatabase.h',
|
||||
'IndexedDatabaseManager.h',
|
||||
]
|
||||
@ -64,7 +63,6 @@ UNIFIED_SOURCES += [
|
||||
'IDBObjectStore.cpp',
|
||||
'IDBRequest.cpp',
|
||||
'IDBTransaction.cpp',
|
||||
'IDBWrapperCache.cpp',
|
||||
'IndexedDatabaseManager.cpp',
|
||||
'KeyPath.cpp',
|
||||
'PermissionRequestBase.cpp',
|
||||
|
@ -395,15 +395,9 @@ 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(cx, owningObject, principalInfo,
|
||||
nsresult rv = IDBFactory::CreateForWorker(this, principalInfo,
|
||||
mWorkerPrivate->WindowID(),
|
||||
getter_AddRefs(indexedDB));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
Loading…
Reference in New Issue
Block a user