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 236744 43843a529109eaec5d71a82098b00b150d5fc3af
parent 236743 70cab9cdea1dfa0f58c05fd08927e25e0a0838b6
child 236745 9c30db22ea97b2ae48430268c45d825bc07cec26
push id411
push usermartin.thomson@gmail.com
push dateWed, 14 Jan 2015 00:17:02 +0000
reviewersbaku
bugs1115214
milestone38.0a1
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>