Bug 1115214 - Fetch API: Always consume body asynchronously. r=baku
authorNikhil Marathe <nsm.nikhil@gmail.com>
Tue, 23 Dec 2014 21:47:17 -0800
changeset 250725 43843a529109eaec5d71a82098b00b150d5fc3af
parent 250724 70cab9cdea1dfa0f58c05fd08927e25e0a0838b6
child 250726 9c30db22ea97b2ae48430268c45d825bc07cec26
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1115214
milestone38.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 1115214 - Fetch API: Always consume body asynchronously. r=baku
dom/fetch/Fetch.cpp
--- a/dom/fetch/Fetch.cpp
+++ b/dom/fetch/Fetch.cpp
@@ -942,28 +942,23 @@ FetchBody<Derived>::BeginConsumeBody()
   MOZ_ASSERT(mConsumePromise);
 
   // The FetchBody is not thread-safe refcounted. We addref it here and release
   // it once the stream read is finished.
   if (!AddRefObject()) {
     return NS_ERROR_FAILURE;
   }
 
-  if (NS_IsMainThread()) {
-    BeginConsumeBodyMainThread();
-    return NS_OK;
-  } else {
-    nsRefPtr<BeginConsumeBodyRunnable<Derived>> r = new BeginConsumeBodyRunnable<Derived>(this);
-    nsresult rv = NS_DispatchToMainThread(r);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      ReleaseObject();
-      return rv;
-    }
-    return NS_OK;
+  nsCOMPtr<nsIRunnable> r = new BeginConsumeBodyRunnable<Derived>(this);
+  nsresult rv = NS_DispatchToMainThread(r);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    ReleaseObject();
+    return rv;
   }
+  return NS_OK;
 }
 
 /*
  * BeginConsumeBodyMainThread() will automatically reject the consume promise
  * and clean up on any failures, so there is no need for callers to do so,
  * reflected in a lack of error return code.
  */
 template <class Derived>