Bug 1041148 - Move HoldJSObjects call to XMLHttpRequest constructor to simplify the code. r=bz, a=lmandel
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 06 Aug 2014 15:23:33 -0700
changeset 208259 7b29fabbf26a
parent 208258 06542873b0dc
child 208260 c755d28a5266
push id3792
push userryanvm@gmail.com
push date2014-08-07 18:27 +0000
treeherdermozilla-beta@7b29fabbf26a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, lmandel
bugs1041148
milestone32.0
Bug 1041148 - Move HoldJSObjects call to XMLHttpRequest constructor to simplify the code. r=bz, a=lmandel
dom/workers/XMLHttpRequest.cpp
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -1572,16 +1572,18 @@ XMLHttpRequest::XMLHttpRequest(WorkerPri
 : mWorkerPrivate(aWorkerPrivate),
   mResponseType(XMLHttpRequestResponseType::Text), mTimeout(0),
   mRooted(false), mBackgroundRequest(false), mWithCredentials(false),
   mCanceled(false), mMozAnon(false), mMozSystem(false)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   SetIsDOMBinding();
+
+  mozilla::HoldJSObjects(this);
 }
 
 XMLHttpRequest::~XMLHttpRequest()
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   ReleaseProxy(XHRIsGoingAway);
 
@@ -2360,12 +2362,9 @@ XMLHttpRequest::UpdateState(const StateD
     JS::Rooted<JS::Value> response(mWorkerPrivate->GetJSContext(),
                                    mStateData.mResponse);
     mStateData = aStateData;
     mStateData.mResponse = response;
   }
   else {
     mStateData = aStateData;
   }
-  if (mStateData.mResponse.isGCThing()) {
-    mozilla::HoldJSObjects(this);
-  }
 }