Bug 1115214 - Fetch API: Always consume body asynchronously. r=baku
--- 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>