Bug 1014466 - Part 2: Allow setting responseType after abort() or new open(). r=khuey
☠☠ backed out by 701627f5212d ☠ ☠
authorShian-Yow Wu <swu@mozilla.com>
Fri, 06 Jun 2014 12:17:54 +0800
changeset 207313 355e895f7ae9cf81a85514a25404a04ae3303be9
parent 207312 b85f5ec213926ad06398d2c59cf199f8373e16f1
child 207314 87ed776cbacdf3f6a684a563134a9eed0afa787a
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