From ed667ac9664be575553e9ff37ffda3fed350fd32 Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Wed, 5 Sep 2012 20:47:57 +0300 Subject: [PATCH] Bug 787961 - Remove mDocument from WorkerPrivate, r=bent --HG-- extra : rebase_source : 6f2560f658e365b89bb602d498b082cf84bdaef9 --- dom/workers/WorkerPrivate.cpp | 15 ++++++--------- dom/workers/WorkerPrivate.h | 17 ++++------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index b46de927a77..74a158cc5ba 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -1892,8 +1892,7 @@ WorkerPrivateParent::WorkerPrivateParent( nsCOMPtr& aWindow, nsCOMPtr& aScriptContext, nsCOMPtr& aBaseURI, - nsCOMPtr& aPrincipal, - nsCOMPtr& aDocument) + nsCOMPtr& aPrincipal) : EventTarget(aParent ? aCx : NULL), mMutex("WorkerPrivateParent Mutex"), mCondVar(mMutex, "WorkerPrivateParent CondVar"), mJSObject(aObject), mParent(aParent), mParentJSContext(aParentJSContext), @@ -1914,7 +1913,6 @@ WorkerPrivateParent::WorkerPrivateParent( mScriptNotify = do_QueryInterface(mScriptContext); mBaseURI.swap(aBaseURI); mPrincipal.swap(aPrincipal); - mDocument.swap(aDocument); if (aParent) { aParent->AssertIsOnWorkerThread(); @@ -2221,7 +2219,6 @@ WorkerPrivateParent::ForgetMainThreadObjects( SwapToISupportsArray(mBaseURI, aDoomed); SwapToISupportsArray(mScriptURI, aDoomed); SwapToISupportsArray(mPrincipal, aDoomed); - SwapToISupportsArray(mDocument, aDoomed); mMainThreadObjectsForgotten = true; } @@ -2278,7 +2275,8 @@ uint64_t WorkerPrivateParent::GetInnerWindowId() { AssertIsOnMainThread(); - return mDocument ? mDocument->InnerWindowID() : 0; + NS_ASSERTION(!mWindow || mWindow->IsInnerWindow(), "Outer window?"); + return mWindow ? mWindow->WindowID() : 0; } template @@ -2454,12 +2452,11 @@ WorkerPrivate::WorkerPrivate(JSContext* aCx, JSObject* aObject, nsCOMPtr& aWindow, nsCOMPtr& aParentScriptContext, nsCOMPtr& aBaseURI, - nsCOMPtr& aPrincipal, - nsCOMPtr& aDocument) + nsCOMPtr& aPrincipal) : WorkerPrivateParent(aCx, aObject, aParent, aParentJSContext, aScriptURL, aIsChromeWorker, aDomain, aWindow, aParentScriptContext, aBaseURI, - aPrincipal, aDocument), + aPrincipal), mJSContext(nullptr), mErrorHandlerRecursionCount(0), mNextTimeoutId(1), mStatus(Pending), mSuspended(false), mTimerRunning(false), mRunningExpiredTimeouts(false), mCloseHandlerStarted(false), @@ -2648,7 +2645,7 @@ WorkerPrivate::Create(JSContext* aCx, JSObject* aObj, WorkerPrivate* aParent, nsRefPtr worker = new WorkerPrivate(aCx, aObj, aParent, parentContext, scriptURL, aIsChromeWorker, domain, window, scriptContext, baseURI, - principal, document); + principal); worker->SetIsDOMBinding(); worker->SetWrapper(aObj); diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h index a1699c73dd9..7f58e51ea88 100644 --- a/dom/workers/WorkerPrivate.h +++ b/dom/workers/WorkerPrivate.h @@ -11,6 +11,7 @@ #include "nsIRunnable.h" #include "nsIThread.h" #include "nsIThreadInternal.h" +#include "nsPIDOMWindow.h" #include "jsapi.h" #include "mozilla/CondVar.h" @@ -181,7 +182,6 @@ private: nsCOMPtr mBaseURI; nsCOMPtr mScriptURI; nsCOMPtr mPrincipal; - nsCOMPtr mDocument; // Only used for top level workers. nsTArray > mQueuedRunnables; @@ -204,8 +204,7 @@ protected: nsCOMPtr& aWindow, nsCOMPtr& aScriptContext, nsCOMPtr& aBaseURI, - nsCOMPtr& aPrincipal, - nsCOMPtr& aDocument); + nsCOMPtr& aPrincipal); ~WorkerPrivateParent(); @@ -426,14 +425,7 @@ public: GetDocument() const { AssertIsOnMainThread(); - return mDocument; - } - - void - SetDocument(nsIDocument* aDocument) - { - AssertIsOnMainThread(); - mDocument = aDocument; + return mWindow ? mWindow->GetExtantDoc() : nullptr; } nsPIDOMWindow* @@ -727,8 +719,7 @@ private: bool aIsChromeWorker, const nsACString& aDomain, nsCOMPtr& aWindow, nsCOMPtr& aScriptContext, - nsCOMPtr& aBaseURI, nsCOMPtr& aPrincipal, - nsCOMPtr& aDocument); + nsCOMPtr& aBaseURI, nsCOMPtr& aPrincipal); bool Dispatch(WorkerRunnable* aEvent, EventQueue* aQueue);