Bug 1269162 - part 1 - Move XHR in workers to XMLHttpRequestWorker, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 27 Jun 2016 19:13:40 +0200
changeset 302714 1e12af97993d0c98ce029bf35b23b19bac0434ca
parent 302713 5f93302810d063dae0f3f2c243008986027a90fe
child 302715 c01653e7ad7c25b718e9245e6495ef8c1d8822dc
push id78843
push useramarchesini@mozilla.com
push dateMon, 27 Jun 2016 17:15:05 +0000
treeherdermozilla-inbound@9f1e2864e569 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1269162
milestone50.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 1269162 - part 1 - Move XHR in workers to XMLHttpRequestWorker, r=smaug
dom/bindings/Bindings.conf
dom/workers/XMLHttpRequest.cpp
dom/workers/XMLHttpRequest.h
dom/workers/XMLHttpRequestUpload.cpp
dom/workers/XMLHttpRequestUpload.h
dom/workers/XMLHttpRequestWorker.cpp
dom/workers/XMLHttpRequestWorker.h
dom/workers/moz.build
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1578,16 +1578,18 @@ DOMInterfaces = {
 },
 
 'XMLHttpRequest': [
 {
     'nativeType': 'nsXMLHttpRequest',
     'implicitJSContext': [ 'send'],
 },
 {
+    'nativeType': 'mozilla::dom::workers::XMLHttpRequestWorker',
+    'headerFile': 'mozilla/dom/workers/bindings/XMLHttpRequestWorker.h',
     'workers': True,
 }],
 
 'XMLHttpRequestEventTarget': {
     'nativeType': 'nsXHREventTarget',
     'headerFile': 'nsXMLHttpRequest.h',
     'concrete': False
 },
--- a/dom/workers/XMLHttpRequestUpload.cpp
+++ b/dom/workers/XMLHttpRequestUpload.cpp
@@ -1,23 +1,23 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "XMLHttpRequestUpload.h"
 
-#include "XMLHttpRequest.h"
+#include "XMLHttpRequestWorker.h"
 
 #include "mozilla/dom/XMLHttpRequestUploadBinding.h"
 
 USING_WORKERS_NAMESPACE
 
-XMLHttpRequestUpload::XMLHttpRequestUpload(XMLHttpRequest* aXHR)
+XMLHttpRequestUpload::XMLHttpRequestUpload(XMLHttpRequestWorker* aXHR)
 : mXHR(aXHR)
 {
 }
 
 XMLHttpRequestUpload::~XMLHttpRequestUpload()
 {
 }
 
@@ -33,13 +33,13 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(XMLHt
 JSObject*
 XMLHttpRequestUpload::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return XMLHttpRequestUploadBinding_workers::Wrap(aCx, this, aGivenProto);
 }
 
 // static
 already_AddRefed<XMLHttpRequestUpload>
-XMLHttpRequestUpload::Create(XMLHttpRequest* aXHR)
+XMLHttpRequestUpload::Create(XMLHttpRequestWorker* aXHR)
 {
   RefPtr<XMLHttpRequestUpload> upload = new XMLHttpRequestUpload(aXHR);
   return upload.forget();
 }
--- a/dom/workers/XMLHttpRequestUpload.h
+++ b/dom/workers/XMLHttpRequestUpload.h
@@ -6,32 +6,32 @@
 
 #ifndef mozilla_dom_workers_xmlhttprequestupload_h__
 #define mozilla_dom_workers_xmlhttprequestupload_h__
 
 #include "nsXMLHttpRequest.h"
 
 BEGIN_WORKERS_NAMESPACE
 
-class XMLHttpRequest;
+class XMLHttpRequestWorker;
 
 class XMLHttpRequestUpload final : public nsXHREventTarget
 {
-  RefPtr<XMLHttpRequest> mXHR;
+  RefPtr<XMLHttpRequestWorker> mXHR;
 
-  explicit XMLHttpRequestUpload(XMLHttpRequest* aXHR);
+  explicit XMLHttpRequestUpload(XMLHttpRequestWorker* aXHR);
 
   ~XMLHttpRequestUpload();
 
 public:
   virtual JSObject*
   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   static already_AddRefed<XMLHttpRequestUpload>
-  Create(XMLHttpRequest* aXHR);
+  Create(XMLHttpRequestWorker* aXHR);
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XMLHttpRequestUpload, nsXHREventTarget)
 
   NS_DECL_ISUPPORTS_INHERITED
 
   nsISupports*
   GetParentObject() const
   {
rename from dom/workers/XMLHttpRequest.cpp
rename to dom/workers/XMLHttpRequestWorker.cpp
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequestWorker.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "XMLHttpRequest.h"
+#include "XMLHttpRequestWorker.h"
 
 #include "nsIDOMEvent.h"
 #include "nsIDOMEventListener.h"
 #include "nsIRunnable.h"
 #include "nsIXMLHttpRequest.h"
 #include "nsIXPConnect.h"
 
 #include "jsfriendapi.h"
@@ -37,19 +37,19 @@
 #include "mozilla/UniquePtr.h"
 
 using namespace mozilla;
 
 using namespace mozilla::dom;
 USING_WORKERS_NAMESPACE
 
 /* static */ void
-XMLHttpRequest::StateData::trace(JSTracer *aTrc)
+XMLHttpRequestWorker::StateData::trace(JSTracer *aTrc)
 {
-    JS::TraceEdge(aTrc, &mResponse, "XMLHttpRequest::StateData::mResponse");
+    JS::TraceEdge(aTrc, &mResponse, "XMLHttpRequestWorker::StateData::mResponse");
 }
 
 /**
  *  XMLHttpRequest in workers
  *
  *  XHR in workers is implemented by proxying calls/events/etc between the
  *  worker thread and an nsXMLHttpRequest on the main thread.  The glue
  *  object here is the Proxy, which lives on both threads.  All other objects
@@ -92,17 +92,17 @@ XMLHttpRequest::StateData::trace(JSTrace
 
 BEGIN_WORKERS_NAMESPACE
 
 class Proxy final : public nsIDOMEventListener
 {
 public:
   // Read on multiple threads.
   WorkerPrivate* mWorkerPrivate;
-  XMLHttpRequest* mXMLHttpRequestPrivate;
+  XMLHttpRequestWorker* mXMLHttpRequestPrivate;
 
   // XHR Params:
   bool mMozAnon;
   bool mMozSystem;
 
   // Only touched on the main thread.
   RefPtr<nsXMLHttpRequest> mXHR;
   nsCOMPtr<nsIXMLHttpRequestUpload> mXHRUpload;
@@ -128,17 +128,17 @@ public:
 
   // Only touched on the main thread.
   bool mUploadEventListenersAttached;
   bool mMainThreadSeenLoadStart;
   bool mInOpen;
   bool mArrayBufferResponseWasTransferred;
 
 public:
-  Proxy(XMLHttpRequest* aXHRPrivate, bool aMozAnon, bool aMozSystem)
+  Proxy(XMLHttpRequestWorker* aXHRPrivate, bool aMozAnon, bool aMozSystem)
   : mWorkerPrivate(nullptr), mXMLHttpRequestPrivate(aXHRPrivate),
     mMozAnon(aMozAnon), mMozSystem(aMozSystem),
     mInnerEventStreamId(0), mInnerChannelId(0), mOutstandingSendCount(0),
     mOuterEventStreamId(0), mOuterChannelId(0), mOpenCount(0), mLastLoaded(0),
     mLastTotal(0), mLastUploadLoaded(0), mLastUploadTotal(0), mIsSyncXHR(false),
     mLastLengthComputable(false), mLastUploadLengthComputable(false),
     mSeenLoadStart(false), mSeenUploadLoadStart(false),
     mUploadEventListenersAttached(false), mMainThreadSeenLoadStart(false),
@@ -351,21 +351,21 @@ protected:
   }
 
   virtual ~MainThreadProxyRunnable()
   { }
 };
 
 class XHRUnpinRunnable final : public MainThreadWorkerControlRunnable
 {
-  XMLHttpRequest* mXMLHttpRequestPrivate;
+  XMLHttpRequestWorker* mXMLHttpRequestPrivate;
 
 public:
   XHRUnpinRunnable(WorkerPrivate* aWorkerPrivate,
-                   XMLHttpRequest* aXHRPrivate)
+                   XMLHttpRequestWorker* aXHRPrivate)
   : MainThreadWorkerControlRunnable(aWorkerPrivate),
     mXMLHttpRequestPrivate(aXHRPrivate)
   {
     MOZ_ASSERT(aXHRPrivate);
   }
 
 private:
   ~XHRUnpinRunnable()
@@ -412,29 +412,29 @@ private:
 };
 
 class LoadStartDetectionRunnable final : public Runnable,
                                          public nsIDOMEventListener
 {
   WorkerPrivate* mWorkerPrivate;
   RefPtr<Proxy> mProxy;
   RefPtr<nsXMLHttpRequest> mXHR;
-  XMLHttpRequest* mXMLHttpRequestPrivate;
+  XMLHttpRequestWorker* mXMLHttpRequestPrivate;
   nsString mEventType;
   uint32_t mChannelId;
   bool mReceivedLoadStart;
 
   class ProxyCompleteRunnable final : public MainThreadProxyRunnable
   {
-    XMLHttpRequest* mXMLHttpRequestPrivate;
+    XMLHttpRequestWorker* mXMLHttpRequestPrivate;
     uint32_t mChannelId;
 
   public:
     ProxyCompleteRunnable(WorkerPrivate* aWorkerPrivate, Proxy* aProxy,
-                          XMLHttpRequest* aXHRPrivate, uint32_t aChannelId)
+                          XMLHttpRequestWorker* aXHRPrivate, uint32_t aChannelId)
     : MainThreadProxyRunnable(aWorkerPrivate, aProxy),
       mXMLHttpRequestPrivate(aXHRPrivate), mChannelId(aChannelId)
     { }
 
   private:
     ~ProxyCompleteRunnable()
     { }
 
@@ -463,17 +463,17 @@ class LoadStartDetectionRunnable final :
       // This must run!
       nsresult rv = MainThreadProxyRunnable::Cancel();
       nsresult rv2 = Run();
       return NS_FAILED(rv) ? rv : rv2;
     }
   };
 
 public:
-  LoadStartDetectionRunnable(Proxy* aProxy, XMLHttpRequest* aXHRPrivate)
+  LoadStartDetectionRunnable(Proxy* aProxy, XMLHttpRequestWorker* aXHRPrivate)
   : mWorkerPrivate(aProxy->mWorkerPrivate), mProxy(aProxy), mXHR(aProxy->mXHR),
     mXMLHttpRequestPrivate(aXHRPrivate), mChannelId(mProxy->mInnerChannelId),
     mReceivedLoadStart(false)
   {
     AssertIsOnMainThread();
     mEventType.AssignWithConversion(sEventStrings[STRING_loadstart]);
   }
 
@@ -851,20 +851,20 @@ private:
     ErrorResult aRv;
     mProxy->mXHR->OverrideMimeType(mMimeType, aRv);
     return aRv.StealNSResult();
   }
 };
 
 class AutoUnpinXHR
 {
-  XMLHttpRequest* mXMLHttpRequestPrivate;
+  XMLHttpRequestWorker* mXMLHttpRequestPrivate;
 
 public:
-  explicit AutoUnpinXHR(XMLHttpRequest* aXMLHttpRequestPrivate)
+  explicit AutoUnpinXHR(XMLHttpRequestWorker* aXMLHttpRequestPrivate)
   : mXMLHttpRequestPrivate(aXMLHttpRequestPrivate)
   {
     MOZ_ASSERT(aXMLHttpRequestPrivate);
   }
 
   ~AutoUnpinXHR()
   {
     if (mXMLHttpRequestPrivate) {
@@ -1287,17 +1287,17 @@ EventRunnable::WorkerRun(JSContext* aCx,
     }
     else {
       mProxy->mLastLengthComputable = mLengthComputable;
       mProxy->mLastLoaded = mLoaded;
       mProxy->mLastTotal = mTotal;
     }
   }
 
-  JS::Rooted<UniquePtr<XMLHttpRequest::StateData>> state(aCx, new XMLHttpRequest::StateData());
+  JS::Rooted<UniquePtr<XMLHttpRequestWorker::StateData>> state(aCx, new XMLHttpRequestWorker::StateData());
 
   state->mResponseTextResult = mResponseTextResult;
   state->mResponseText = mResponseText;
 
   if (NS_SUCCEEDED(mResponseTextResult)) {
     MOZ_ASSERT(mResponse.isUndefined() || mResponse.isNull());
     state->mResponseResult = mResponseTextResult;
     state->mResponse = mResponse;
@@ -1334,17 +1334,17 @@ EventRunnable::WorkerRun(JSContext* aCx,
   state->mStatus = mStatus;
 
   state->mStatusText = mStatusText;
 
   state->mReadyState = mReadyState;
 
   state->mResponseURL = mResponseURL;
 
-  XMLHttpRequest* xhr = mProxy->mXMLHttpRequestPrivate;
+  XMLHttpRequestWorker* xhr = mProxy->mXMLHttpRequestPrivate;
   xhr->UpdateState(*state.get(), mUseCachedArrayBufferResponse);
 
   if (mUploadEvent && !xhr->GetUploadObjectNoCreate()) {
     return true;
   }
 
   JS::Rooted<JSString*> type(aCx,
     JS_NewUCStringCopyN(aCx, mType.get(), mType.Length()));
@@ -1554,96 +1554,96 @@ SendRunnable::RunOnMainThread()
         MOZ_ASSERT(false, "This should never fail!");
       }
     }
   }
 
   return rv;
 }
 
-XMLHttpRequest::XMLHttpRequest(WorkerPrivate* aWorkerPrivate)
+XMLHttpRequestWorker::XMLHttpRequestWorker(WorkerPrivate* aWorkerPrivate)
 : mWorkerPrivate(aWorkerPrivate),
   mResponseType(XMLHttpRequestResponseType::Text), mTimeout(0),
   mRooted(false), mBackgroundRequest(false), mWithCredentials(false),
   mCanceled(false), mMozAnon(false), mMozSystem(false)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   mozilla::HoldJSObjects(this);
 }
 
-XMLHttpRequest::~XMLHttpRequest()
+XMLHttpRequestWorker::~XMLHttpRequestWorker()
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   ReleaseProxy(XHRIsGoingAway);
 
   MOZ_ASSERT(!mRooted);
 
   mozilla::DropJSObjects(this);
 }
 
-NS_IMPL_ADDREF_INHERITED(XMLHttpRequest, nsXHREventTarget)
-NS_IMPL_RELEASE_INHERITED(XMLHttpRequest, nsXHREventTarget)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(XMLHttpRequest)
+NS_IMPL_ADDREF_INHERITED(XMLHttpRequestWorker, nsXHREventTarget)
+NS_IMPL_RELEASE_INHERITED(XMLHttpRequestWorker, nsXHREventTarget)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(XMLHttpRequestWorker)
 NS_INTERFACE_MAP_END_INHERITING(nsXHREventTarget)
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(XMLHttpRequest)
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(XMLHttpRequest,
+NS_IMPL_CYCLE_COLLECTION_CLASS(XMLHttpRequestWorker)
+
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(XMLHttpRequestWorker,
                                                   nsXHREventTarget)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mUpload)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(XMLHttpRequest,
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(XMLHttpRequestWorker,
                                                 nsXHREventTarget)
   tmp->ReleaseProxy(XHRIsGoingAway);
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mUpload)
   tmp->mStateData.mResponse.setUndefined();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
-NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(XMLHttpRequest,
+NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(XMLHttpRequestWorker,
                                                nsXHREventTarget)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mStateData.mResponse)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 JSObject*
-XMLHttpRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
+XMLHttpRequestWorker::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return XMLHttpRequestBinding_workers::Wrap(aCx, this, aGivenProto);
 }
 
 // static
-already_AddRefed<XMLHttpRequest>
-XMLHttpRequest::Constructor(const GlobalObject& aGlobal,
-                            const MozXMLHttpRequestParameters& aParams,
-                            ErrorResult& aRv)
+already_AddRefed<XMLHttpRequestWorker>
+XMLHttpRequestWorker::Constructor(const GlobalObject& aGlobal,
+                                  const MozXMLHttpRequestParameters& aParams,
+                                  ErrorResult& aRv)
 {
   JSContext* cx = aGlobal.Context();
   WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
   MOZ_ASSERT(workerPrivate);
 
   Telemetry::Accumulate(Telemetry::XHR_IN_WORKER, 1);
 
-  RefPtr<XMLHttpRequest> xhr = new XMLHttpRequest(workerPrivate);
+  RefPtr<XMLHttpRequestWorker> xhr = new XMLHttpRequestWorker(workerPrivate);
 
   if (workerPrivate->XHRParamsAllowed()) {
     if (aParams.mMozSystem)
       xhr->mMozAnon = true;
     else
       xhr->mMozAnon = aParams.mMozAnon;
     xhr->mMozSystem = aParams.mMozSystem;
   }
 
   return xhr.forget();
 }
 
 void
-XMLHttpRequest::ReleaseProxy(ReleaseType aType)
+XMLHttpRequestWorker::ReleaseProxy(ReleaseType aType)
 {
   // Can't assert that we're on the worker thread here because mWorkerPrivate
   // may be gone.
 
   if (mProxy) {
     if (aType == XHRIsGoingAway) {
       // We're in a GC finalizer, so we can't do a sync call here (and we don't
       // need to).
@@ -1672,17 +1672,17 @@ XMLHttpRequest::ReleaseProxy(ReleaseType
       if (forAssertionsOnly.Failed()) {
         NS_ERROR("Failed to dispatch teardown runnable!");
       }
     }
   }
 }
 
 void
-XMLHttpRequest::MaybePin(ErrorResult& aRv)
+XMLHttpRequestWorker::MaybePin(ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mRooted) {
     return;
   }
 
   if (!HoldWorker(mWorkerPrivate)) {
@@ -1691,17 +1691,17 @@ XMLHttpRequest::MaybePin(ErrorResult& aR
   }
 
   NS_ADDREF_THIS();
 
   mRooted = true;
 }
 
 void
-XMLHttpRequest::MaybeDispatchPrematureAbortEvents(ErrorResult& aRv)
+XMLHttpRequestWorker::MaybeDispatchPrematureAbortEvents(ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
   MOZ_ASSERT(mProxy);
 
   // Only send readystatechange event when state changed.
   bool isStateChanged = false;
   if (mStateData.mReadyState != 4) {
     isStateChanged = true;
@@ -1746,20 +1746,20 @@ XMLHttpRequest::MaybeDispatchPrematureAb
       return;
     }
 
     mProxy->mSeenLoadStart = false;
   }
 }
 
 void
-XMLHttpRequest::DispatchPrematureAbortEvent(EventTarget* aTarget,
-                                            const nsAString& aEventType,
-                                            bool aUploadTarget,
-                                            ErrorResult& aRv)
+XMLHttpRequestWorker::DispatchPrematureAbortEvent(EventTarget* aTarget,
+                                                  const nsAString& aEventType,
+                                                  bool aUploadTarget,
+                                                  ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
   MOZ_ASSERT(aTarget);
 
   if (!mProxy) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
@@ -1792,32 +1792,32 @@ XMLHttpRequest::DispatchPrematureAbortEv
   }
 
   event->SetTrusted(true);
 
   aTarget->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
 }
 
 void
-XMLHttpRequest::Unpin()
+XMLHttpRequestWorker::Unpin()
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   MOZ_ASSERT(mRooted, "Mismatched calls to Unpin!");
 
   ReleaseWorker();
 
   mRooted = false;
 
   NS_RELEASE_THIS();
 }
 
 void
-XMLHttpRequest::SendInternal(SendRunnable* aRunnable,
-                             ErrorResult& aRv)
+XMLHttpRequestWorker::SendInternal(SendRunnable* aRunnable,
+                                   ErrorResult& aRv)
 {
   MOZ_ASSERT(aRunnable);
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   // No send() calls when open is running.
   if (mProxy->mOpenCount) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
@@ -1869,32 +1869,32 @@ XMLHttpRequest::SendInternal(SendRunnabl
   // for it will come from ProxyCompleteRunnable and that always passes true for
   // the second arg.
   if (!autoSyncLoop->Run() && !aRv.Failed()) {
     aRv.Throw(NS_ERROR_FAILURE);
   }
 }
 
 bool
-XMLHttpRequest::Notify(Status aStatus)
+XMLHttpRequestWorker::Notify(Status aStatus)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (aStatus >= Canceling && !mCanceled) {
     mCanceled = true;
     ReleaseProxy(WorkerIsGoingAway);
   }
 
   return true;
 }
 
 void
-XMLHttpRequest::Open(const nsACString& aMethod, const nsAString& aUrl,
-                     bool aAsync, const Optional<nsAString>& aUser,
-                     const Optional<nsAString>& aPassword, ErrorResult& aRv)
+XMLHttpRequestWorker::Open(const nsACString& aMethod, const nsAString& aUrl,
+                           bool aAsync, const Optional<nsAString>& aUser,
+                           const Optional<nsAString>& aPassword, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
     aRv.ThrowUncatchableException();
     return;
   }
 
@@ -1931,18 +1931,18 @@ XMLHttpRequest::Open(const nsACString& a
     return;
   }
 
   --mProxy->mOpenCount;
   mProxy->mIsSyncXHR = !aAsync;
 }
 
 void
-XMLHttpRequest::SetRequestHeader(const nsACString& aHeader,
-                                 const nsACString& aValue, ErrorResult& aRv)
+XMLHttpRequestWorker::SetRequestHeader(const nsACString& aHeader,
+                                       const nsACString& aValue, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
     aRv.ThrowUncatchableException();
     return;
   }
 
@@ -1952,17 +1952,17 @@ XMLHttpRequest::SetRequestHeader(const n
   }
 
   RefPtr<SetRequestHeaderRunnable> runnable =
     new SetRequestHeaderRunnable(mWorkerPrivate, mProxy, aHeader, aValue);
   runnable->Dispatch(aRv);
 }
 
 void
-XMLHttpRequest::SetTimeout(uint32_t aTimeout, ErrorResult& aRv)
+XMLHttpRequestWorker::SetTimeout(uint32_t aTimeout, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
     aRv.ThrowUncatchableException();
     return;
   }
 
@@ -1975,17 +1975,17 @@ XMLHttpRequest::SetTimeout(uint32_t aTim
   }
 
   RefPtr<SetTimeoutRunnable> runnable =
     new SetTimeoutRunnable(mWorkerPrivate, mProxy, aTimeout);
   runnable->Dispatch(aRv);
 }
 
 void
-XMLHttpRequest::SetWithCredentials(bool aWithCredentials, ErrorResult& aRv)
+XMLHttpRequestWorker::SetWithCredentials(bool aWithCredentials, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
     aRv.ThrowUncatchableException();
     return;
   }
 
@@ -1998,18 +1998,18 @@ XMLHttpRequest::SetWithCredentials(bool 
   }
 
   RefPtr<SetWithCredentialsRunnable> runnable =
     new SetWithCredentialsRunnable(mWorkerPrivate, mProxy, aWithCredentials);
   runnable->Dispatch(aRv);
 }
 
 void
-XMLHttpRequest::SetMozBackgroundRequest(bool aBackgroundRequest,
-                                        ErrorResult& aRv)
+XMLHttpRequestWorker::SetMozBackgroundRequest(bool aBackgroundRequest,
+                                              ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
     aRv.ThrowUncatchableException();
     return;
   }
 
@@ -2023,17 +2023,17 @@ XMLHttpRequest::SetMozBackgroundRequest(
 
   RefPtr<SetBackgroundRequestRunnable> runnable =
     new SetBackgroundRequestRunnable(mWorkerPrivate, mProxy,
                                      aBackgroundRequest);
   runnable->Dispatch(aRv);
 }
 
 XMLHttpRequestUpload*
-XMLHttpRequest::GetUpload(ErrorResult& aRv)
+XMLHttpRequestWorker::GetUpload(ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
     aRv.ThrowUncatchableException();
     return nullptr;
   }
 
@@ -2045,17 +2045,17 @@ XMLHttpRequest::GetUpload(ErrorResult& a
       return nullptr;
     }
   }
 
   return mUpload;
 }
 
 void
-XMLHttpRequest::Send(ErrorResult& aRv)
+XMLHttpRequestWorker::Send(ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
     aRv.ThrowUncatchableException();
     return;
   }
 
@@ -2067,17 +2067,17 @@ XMLHttpRequest::Send(ErrorResult& aRv)
   RefPtr<SendRunnable> sendRunnable =
     new SendRunnable(mWorkerPrivate, mProxy, NullString());
 
   // Nothing to clone.
   SendInternal(sendRunnable, aRv);
 }
 
 void
-XMLHttpRequest::Send(const nsAString& aBody, ErrorResult& aRv)
+XMLHttpRequestWorker::Send(const nsAString& aBody, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
     aRv.ThrowUncatchableException();
     return;
   }
 
@@ -2089,17 +2089,17 @@ XMLHttpRequest::Send(const nsAString& aB
   RefPtr<SendRunnable> sendRunnable =
     new SendRunnable(mWorkerPrivate, mProxy, aBody);
 
   // Nothing to clone.
   SendInternal(sendRunnable, aRv);
 }
 
 void
-XMLHttpRequest::Send(JS::Handle<JSObject*> aBody, ErrorResult& aRv)
+XMLHttpRequestWorker::Send(JS::Handle<JSObject*> aBody, ErrorResult& aRv)
 {
   JSContext* cx = mWorkerPrivate->GetJSContext();
 
   MOZ_ASSERT(aBody);
 
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
@@ -2133,17 +2133,17 @@ XMLHttpRequest::Send(JS::Handle<JSObject
   if (NS_WARN_IF(aRv.Failed())) {
     return;
   }
 
   SendInternal(sendRunnable, aRv);
 }
 
 void
-XMLHttpRequest::Send(Blob& aBody, ErrorResult& aRv)
+XMLHttpRequestWorker::Send(Blob& aBody, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
   JSContext* cx = mWorkerPrivate->GetJSContext();
 
   if (mCanceled) {
     aRv.ThrowUncatchableException();
     return;
   }
@@ -2174,17 +2174,17 @@ XMLHttpRequest::Send(Blob& aBody, ErrorR
   if (NS_WARN_IF(aRv.Failed())) {
     return;
   }
 
   SendInternal(sendRunnable, aRv);
 }
 
 void
-XMLHttpRequest::Send(FormData& aBody, ErrorResult& aRv)
+XMLHttpRequestWorker::Send(FormData& aBody, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
   JSContext* cx = mWorkerPrivate->GetJSContext();
 
   if (mCanceled) {
     aRv.ThrowUncatchableException();
     return;
   }
@@ -2207,37 +2207,37 @@ XMLHttpRequest::Send(FormData& aBody, Er
   if (NS_WARN_IF(aRv.Failed())) {
     return;
   }
 
   SendInternal(sendRunnable, aRv);
 }
 
 void
-XMLHttpRequest::Send(const ArrayBuffer& aBody, ErrorResult& aRv)
+XMLHttpRequestWorker::Send(const ArrayBuffer& aBody, ErrorResult& aRv)
 {
   JS::Rooted<JSObject*> obj(mWorkerPrivate->GetJSContext(), aBody.Obj());
   return Send(obj, aRv);
 }
 
 void
-XMLHttpRequest::Send(const ArrayBufferView& aBody, ErrorResult& aRv)
+XMLHttpRequestWorker::Send(const ArrayBufferView& aBody, ErrorResult& aRv)
 {
   if (JS_IsTypedArrayObject(aBody.Obj()) &&
       JS_GetTypedArraySharedness(aBody.Obj())) {
     // Throw if the object is mapping shared memory (must opt in).
     aRv.ThrowTypeError<MSG_TYPEDARRAY_IS_SHARED>(NS_LITERAL_STRING("Argument of XMLHttpRequest.send"));
     return;
   }
   JS::Rooted<JSObject*> obj(mWorkerPrivate->GetJSContext(), aBody.Obj());
   return Send(obj, aRv);
 }
 
 void
-XMLHttpRequest::Abort(ErrorResult& aRv)
+XMLHttpRequestWorker::Abort(ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
     aRv.ThrowUncatchableException();
     return;
   }
 
@@ -2258,18 +2258,18 @@ XMLHttpRequest::Abort(ErrorResult& aRv)
 
   mProxy->mOuterEventStreamId++;
 
   RefPtr<AbortRunnable> runnable = new AbortRunnable(mWorkerPrivate, mProxy);
   runnable->Dispatch(aRv);
 }
 
 void
-XMLHttpRequest::GetResponseHeader(const nsACString& aHeader,
-                                  nsACString& aResponseHeader, ErrorResult& aRv)
+XMLHttpRequestWorker::GetResponseHeader(const nsACString& aHeader,
+                                        nsACString& aResponseHeader, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
     aRv.ThrowUncatchableException();
     return;
   }
 
@@ -2285,18 +2285,18 @@ XMLHttpRequest::GetResponseHeader(const 
   runnable->Dispatch(aRv);
   if (aRv.Failed()) {
     return;
   }
   aResponseHeader = responseHeader;
 }
 
 void
-XMLHttpRequest::GetAllResponseHeaders(nsACString& aResponseHeaders,
-                                      ErrorResult& aRv)
+XMLHttpRequestWorker::GetAllResponseHeaders(nsACString& aResponseHeaders,
+                                            ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
     aRv.ThrowUncatchableException();
     return;
   }
 
@@ -2312,17 +2312,17 @@ XMLHttpRequest::GetAllResponseHeaders(ns
   if (aRv.Failed()) {
     return;
   }
 
   aResponseHeaders = responseHeaders;
 }
 
 void
-XMLHttpRequest::OverrideMimeType(const nsAString& aMimeType, ErrorResult& aRv)
+XMLHttpRequestWorker::OverrideMimeType(const nsAString& aMimeType, ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
     aRv.ThrowUncatchableException();
     return;
   }
 
@@ -2339,18 +2339,18 @@ XMLHttpRequest::OverrideMimeType(const n
   }
 
   RefPtr<OverrideMimeTypeRunnable> runnable =
     new OverrideMimeTypeRunnable(mWorkerPrivate, mProxy, aMimeType);
   runnable->Dispatch(aRv);
 }
 
 void
-XMLHttpRequest::SetResponseType(XMLHttpRequestResponseType aResponseType,
-                                ErrorResult& aRv)
+XMLHttpRequestWorker::SetResponseType(XMLHttpRequestResponseType aResponseType,
+                                      ErrorResult& aRv)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (mCanceled) {
     aRv.ThrowUncatchableException();
     return;
   }
 
@@ -2386,19 +2386,19 @@ XMLHttpRequest::SetResponseType(XMLHttpR
 
   nsString acceptedResponseTypeString;
   runnable->GetResponseType(acceptedResponseTypeString);
 
   mResponseType = ConvertStringToResponseType(acceptedResponseTypeString);
 }
 
 void
-XMLHttpRequest::GetResponse(JSContext* /* unused */,
-                            JS::MutableHandle<JS::Value> aResponse,
-                            ErrorResult& aRv)
+XMLHttpRequestWorker::GetResponse(JSContext* /* unused */,
+                                  JS::MutableHandle<JS::Value> aResponse,
+                                  ErrorResult& aRv)
 {
   if (NS_SUCCEEDED(mStateData.mResponseTextResult) &&
       mStateData.mResponse.isUndefined()) {
     MOZ_ASSERT(NS_SUCCEEDED(mStateData.mResponseResult));
 
     if (mStateData.mResponseText.IsEmpty()) {
       mStateData.mResponse =
         JS_GetEmptyStringValue(mWorkerPrivate->GetJSContext());
@@ -2418,25 +2418,25 @@ XMLHttpRequest::GetResponse(JSContext* /
   }
 
   JS::ExposeValueToActiveJS(mStateData.mResponse);
   aRv = mStateData.mResponseResult;
   aResponse.set(mStateData.mResponse);
 }
 
 void
-XMLHttpRequest::GetResponseText(nsAString& aResponseText, ErrorResult& aRv)
+XMLHttpRequestWorker::GetResponseText(nsAString& aResponseText, ErrorResult& aRv)
 {
   aRv = mStateData.mResponseTextResult;
   aResponseText = mStateData.mResponseText;
 }
 
 void
-XMLHttpRequest::UpdateState(const StateData& aStateData,
-                            bool aUseCachedArrayBufferResponse)
+XMLHttpRequestWorker::UpdateState(const StateData& aStateData,
+                                  bool aUseCachedArrayBufferResponse)
 {
   if (aUseCachedArrayBufferResponse) {
     MOZ_ASSERT(mStateData.mResponse.isObject() &&
                JS_IsArrayBufferObject(&mStateData.mResponse.toObject()));
 
     JS::Rooted<JS::Value> response(mWorkerPrivate->GetJSContext(),
                                    mStateData.mResponse);
     mStateData = aStateData;
rename from dom/workers/XMLHttpRequest.h
rename to dom/workers/XMLHttpRequestWorker.h
--- a/dom/workers/XMLHttpRequest.h
+++ b/dom/workers/XMLHttpRequestWorker.h
@@ -24,18 +24,18 @@ class Blob;
 
 BEGIN_WORKERS_NAMESPACE
 
 class Proxy;
 class SendRunnable;
 class XMLHttpRequestUpload;
 class WorkerPrivate;
 
-class XMLHttpRequest final: public nsXHREventTarget,
-                            public WorkerHolder
+class XMLHttpRequestWorker final : public nsXHREventTarget,
+                                   public WorkerHolder
 {
 public:
   struct StateData
   {
     nsString mResponseText;
     nsString mResponseURL;
     uint32_t mStatus;
     nsCString mStatusText;
@@ -71,32 +71,32 @@ private:
   bool mMozAnon;
   bool mMozSystem;
 
 public:
   virtual JSObject*
   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(XMLHttpRequest,
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(XMLHttpRequestWorker,
                                                          nsXHREventTarget)
 
   nsISupports*
   GetParentObject() const
   {
     // There's only one global on a worker, so we don't need to specify.
     return nullptr;
   }
 
-  static already_AddRefed<XMLHttpRequest>
+  static already_AddRefed<XMLHttpRequestWorker>
   Constructor(const GlobalObject& aGlobal,
               const MozXMLHttpRequestParameters& aParams,
               ErrorResult& aRv);
 
-  static already_AddRefed<XMLHttpRequest>
+  static already_AddRefed<XMLHttpRequestWorker>
   Constructor(const GlobalObject& aGlobal, const nsAString& ignored,
               ErrorResult& aRv)
   {
     // Pretend like someone passed null, so we can pick up the default values
     MozXMLHttpRequestParameters params;
     if (!params.Init(aGlobal.Context(), JS::NullHandleValue)) {
       aRv.Throw(NS_ERROR_UNEXPECTED);
       return nullptr;
@@ -267,18 +267,18 @@ public:
 
   bool
   SendInProgress() const
   {
     return mRooted;
   }
 
 private:
-  explicit XMLHttpRequest(WorkerPrivate* aWorkerPrivate);
-  ~XMLHttpRequest();
+  explicit XMLHttpRequestWorker(WorkerPrivate* aWorkerPrivate);
+  ~XMLHttpRequestWorker();
 
   enum ReleaseType { Default, XHRIsGoingAway, WorkerIsGoingAway };
 
   void
   ReleaseProxy(ReleaseType aType = Default);
 
   void
   MaybePin(ErrorResult& aRv);
--- a/dom/workers/moz.build
+++ b/dom/workers/moz.build
@@ -34,18 +34,18 @@ EXPORTS.mozilla.dom.workers += [
 EXPORTS.mozilla.dom.workers.bindings += [
     'ServiceWorker.h',
     'ServiceWorkerClient.h',
     'ServiceWorkerClients.h',
     'ServiceWorkerWindowClient.h',
     'SharedWorker.h',
     'URL.h',
     'WorkerHolder.h',
-    'XMLHttpRequest.h',
     'XMLHttpRequestUpload.h',
+    'XMLHttpRequestWorker.h',
 ]
 
 XPIDL_MODULE = 'dom_workers'
 
 XPIDL_SOURCES += [
     'nsIWorkerDebugger.idl',
     'nsIWorkerDebuggerManager.idl',
 ]
@@ -84,18 +84,18 @@ UNIFIED_SOURCES += [
     'WorkerDebuggerManager.cpp',
     'WorkerHolder.cpp',
     'WorkerLocation.cpp',
     'WorkerNavigator.cpp',
     'WorkerPrivate.cpp',
     'WorkerRunnable.cpp',
     'WorkerScope.cpp',
     'WorkerThread.cpp',
-    'XMLHttpRequest.cpp',
     'XMLHttpRequestUpload.cpp',
+    'XMLHttpRequestWorker.cpp',
 ]
 
 IPDL_SOURCES += [
     'PServiceWorkerManager.ipdl',
     'ServiceWorkerRegistrarTypes.ipdlh',
 ]
 
 LOCAL_INCLUDES += [