Bug 889193 - Remove DOMRequest::mRooted. r=smaug a=bajaj
authorAndrew McCreight <amccreight@mozilla.com>
Wed, 14 Aug 2013 11:29:20 -0700
changeset 153791 a68ce4ee08ed4e4cbe44f671cac6b215dc3a602f
parent 153790 660eabee781165f0eaf3a6c1b65cf7c148453776
child 153792 194d916fb4609d736021b587d35010a97a5a7220
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, bajaj
bugs889193
milestone25.0a2
Bug 889193 - Remove DOMRequest::mRooted. r=smaug a=bajaj
dom/base/DOMCursor.cpp
dom/base/DOMCursor.h
dom/base/DOMRequest.cpp
dom/base/DOMRequest.h
dom/devicestorage/nsDeviceStorage.cpp
--- a/dom/base/DOMCursor.cpp
+++ b/dom/base/DOMCursor.cpp
@@ -16,35 +16,30 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED_1(DOM
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DOMCursor)
   NS_INTERFACE_MAP_ENTRY(nsIDOMDOMCursor)
 NS_INTERFACE_MAP_END_INHERITING(DOMRequest)
 
 NS_IMPL_ADDREF_INHERITED(DOMCursor, DOMRequest)
 NS_IMPL_RELEASE_INHERITED(DOMCursor, DOMRequest)
 
-NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(DOMCursor, DOMRequest)
-NS_IMPL_CYCLE_COLLECTION_TRACE_END
-
 DOMCursor::DOMCursor(nsIDOMWindow* aWindow, nsICursorContinueCallback* aCallback)
   : DOMRequest(aWindow)
   , mCallback(aCallback)
   , mFinished(false)
 {
 }
 
 void
 DOMCursor::Reset()
 {
   MOZ_ASSERT(!mFinished);
 
   // Reset the request state so we can FireSuccess() again.
-  if (mRooted) {
-    UnrootResultVal();
-  }
+  mResult = JSVAL_VOID;
   mDone = false;
 }
 
 void
 DOMCursor::FireDone()
 {
   Reset();
   mFinished = true;
--- a/dom/base/DOMCursor.h
+++ b/dom/base/DOMCursor.h
@@ -17,18 +17,18 @@ namespace mozilla {
 namespace dom {
 
 class DOMCursor : public DOMRequest
                 , public nsIDOMDOMCursor
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMDOMCURSOR
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(DOMCursor,
-                                                         DOMRequest)
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DOMCursor,
+                                           DOMRequest)
 
   DOMCursor(nsIDOMWindow* aWindow, nsICursorContinueCallback *aCallback);
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   bool Done() const
   {
--- a/dom/base/DOMRequest.cpp
+++ b/dom/base/DOMRequest.cpp
@@ -18,28 +18,26 @@
 using mozilla::dom::DOMRequest;
 using mozilla::dom::DOMRequestService;
 using mozilla::dom::DOMCursor;
 using mozilla::AutoPushJSContext;
 
 DOMRequest::DOMRequest(nsIDOMWindow* aWindow)
   : mResult(JSVAL_VOID)
   , mDone(false)
-  , mRooted(false)
 {
   SetIsDOMBinding();
   Init(aWindow);
 }
 
 // We need this constructor for dom::Activity that inherits from DOMRequest
 // but has no window available from the constructor.
 DOMRequest::DOMRequest()
   : mResult(JSVAL_VOID)
   , mDone(false)
-  , mRooted(false)
 {
   SetIsDOMBinding();
 }
 
 void
 DOMRequest::Init(nsIDOMWindow* aWindow)
 {
   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aWindow);
@@ -51,20 +49,18 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(DOMReques
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DOMRequest,
                                                   nsDOMEventTargetHelper)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mError)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DOMRequest,
                                                 nsDOMEventTargetHelper)
-  if (tmp->mRooted) {
-    tmp->UnrootResultVal();
-  }
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mError)
+  tmp->mResult = JSVAL_VOID;
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(DOMRequest,
                                                nsDOMEventTargetHelper)
   // Don't need NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER because
   // nsDOMEventTargetHelper does it for us.
   NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mResult)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
@@ -191,31 +187,20 @@ DOMRequest::FireEvent(const nsAString& a
 
   bool dummy;
   DispatchEvent(event, &dummy);
 }
 
 void
 DOMRequest::RootResultVal()
 {
-  NS_ASSERTION(!mRooted, "Don't call me if already rooted!");
   nsXPCOMCycleCollectionParticipant *participant;
   CallQueryInterface(this, &participant);
   nsContentUtils::HoldJSObjects(NS_CYCLE_COLLECTION_UPCAST(this, DOMRequest),
                                 participant);
-  mRooted = true;
-}
-
-void
-DOMRequest::UnrootResultVal()
-{
-  NS_ASSERTION(mRooted, "Don't call me if not rooted!");
-  mResult = JSVAL_VOID;
-  NS_DROP_JS_OBJECTS(this, DOMRequest);
-  mRooted = false;
 }
 
 NS_IMPL_ISUPPORTS1(DOMRequestService, nsIDOMRequestService)
 
 NS_IMETHODIMP
 DOMRequestService::CreateRequest(nsIDOMWindow* aWindow,
                                  nsIDOMDOMRequest** aRequest)
 {
--- a/dom/base/DOMRequest.h
+++ b/dom/base/DOMRequest.h
@@ -20,17 +20,16 @@ namespace dom {
 
 class DOMRequest : public nsDOMEventTargetHelper,
                    public nsIDOMDOMRequest
 {
 protected:
   JS::Heap<JS::Value> mResult;
   nsCOMPtr<nsISupports> mError;
   bool mDone;
-  bool mRooted;
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMDOMREQUEST
   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
 
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(DOMRequest,
                                                          nsDOMEventTargetHelper)
@@ -74,26 +73,24 @@ public:
   void FireError(nsresult aError);
   void FireDetailedError(nsISupports* aError);
 
   DOMRequest(nsIDOMWindow* aWindow);
   DOMRequest();
 
   virtual ~DOMRequest()
   {
-    if (mRooted) {
-      UnrootResultVal();
-    }
+    mResult = JSVAL_VOID;
+    NS_DROP_JS_OBJECTS(this, DOMRequest);
   }
 
 protected:
   void FireEvent(const nsAString& aType, bool aBubble, bool aCancelable);
 
   void RootResultVal();
-  void UnrootResultVal();
 
   void Init(nsIDOMWindow* aWindow);
 };
 
 class DOMRequestService MOZ_FINAL : public nsIDOMRequestService
 {
 public:
   NS_DECL_ISUPPORTS
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -1721,23 +1721,21 @@ nsDOMDeviceStorageCursor::Allow()
 void
 nsDOMDeviceStorageCursor::Continue(ErrorResult& aRv)
 {
   if (!mOkToCallContinue) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return;
   }
 
-  if (mRooted) {
-    // We call onsuccess multiple times. clear the last
-    // rooted result.
+  if (mResult != JSVAL_VOID) {
+    // We call onsuccess multiple times. Clear the last
+    // result.
     mResult = JSVAL_VOID;
-    NS_DROP_JS_OBJECTS(this, nsDOMDeviceStorageCursor);
     mDone = false;
-    mRooted = false;
   }
 
   nsCOMPtr<ContinueCursorEvent> event = new ContinueCursorEvent(this);
   event->Continue();
 
   mOkToCallContinue = false;
 }