Bug 1014466 - Part 2: Allow setting responseType after abort() or new open(). r=khuey
authorShian-Yow Wu <swu@mozilla.com>
Fri, 06 Jun 2014 12:12:15 +0100
changeset 207390 5d3e9e9171bbd3d82ec9b75bb95b20c38f49e35a
parent 207389 3c0151397b51eb5dad7a30e1aa0ede4fb726c055
child 207391 94137dfc452001c2cf9b05c3893d102d3a2c88c5
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1014466
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1014466 - Part 2: Allow setting responseType after abort() or new open(). r=khuey
dom/workers/XMLHttpRequest.cpp
dom/workers/XMLHttpRequest.h
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -274,17 +274,19 @@ public:
 
 private:
   ~XHRUnpinRunnable()
   { }
 
   bool
   WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
   {
-    mXMLHttpRequestPrivate->Unpin();
+    if (mXMLHttpRequestPrivate->SendInProgress()) {
+      mXMLHttpRequestPrivate->Unpin();
+    }
 
     return true;
   }
 };
 
 class AsyncTeardownRunnable MOZ_FINAL : public nsRunnable
 {
   nsRefPtr<Proxy> mProxy;
@@ -348,17 +350,19 @@ class LoadStartDetectionRunnable MOZ_FIN
         // Threads raced, this event is now obsolete.
         return true;
       }
 
       if (mSyncLoopTarget) {
         aWorkerPrivate->StopSyncLoop(mSyncLoopTarget, true);
       }
 
-      mXMLHttpRequestPrivate->Unpin();
+      if (mXMLHttpRequestPrivate->SendInProgress()) {
+        mXMLHttpRequestPrivate->Unpin();
+      }
 
       return true;
     }
 
     NS_IMETHOD
     Cancel() MOZ_OVERRIDE
     {
       // This must run!
@@ -1711,16 +1715,20 @@ XMLHttpRequest::MaybeDispatchPrematureAb
     DispatchPrematureAbortEvent(this, NS_LITERAL_STRING("loadend"), false,
                                 aRv);
     if (aRv.Failed()) {
       return;
     }
 
     mProxy->mSeenLoadStart = false;
   }
+
+  if (mRooted) {
+    Unpin();
+  }
 }
 
 void
 XMLHttpRequest::DispatchPrematureAbortEvent(EventTarget* aTarget,
                                             const nsAString& aEventType,
                                             bool aUploadTarget,
                                             ErrorResult& aRv)
 {
--- a/dom/workers/XMLHttpRequest.h
+++ b/dom/workers/XMLHttpRequest.h
@@ -259,16 +259,22 @@ public:
     return mMozAnon;
   }
 
   bool MozSystem() const
   {
     return mMozSystem;
   }
 
+  bool
+  SendInProgress() const
+  {
+    return mRooted;
+  }
+
 private:
   XMLHttpRequest(WorkerPrivate* aWorkerPrivate);
   ~XMLHttpRequest();
 
   enum ReleaseType { Default, XHRIsGoingAway, WorkerIsGoingAway };
 
   void
   ReleaseProxy(ReleaseType aType = Default);
@@ -279,22 +285,16 @@ private:
   void
   MaybeDispatchPrematureAbortEvents(ErrorResult& aRv);
 
   void
   DispatchPrematureAbortEvent(EventTarget* aTarget,
                               const nsAString& aEventType, bool aUploadTarget,
                               ErrorResult& aRv);
 
-  bool
-  SendInProgress() const
-  {
-    return mRooted;
-  }
-
   void
   SendInternal(const nsAString& aStringBody,
                JSAutoStructuredCloneBuffer&& aBody,
                nsTArray<nsCOMPtr<nsISupports> >& aClonedObjects,
                ErrorResult& aRv);
 };
 
 END_WORKERS_NAMESPACE