Bug 1269162 - part 4 - Move XMLHttpRequestEventTarget in separate files, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 27 Jun 2016 19:13:41 +0200
changeset 302717 e03db893b8da2247b1a5ed9aafc968ff2d874c90
parent 302716 55a63a62c0dd798ba7ea9c5ab08d49a48588a0d4
child 302718 ddb3b5ac04aff12d9b18c2504477cb5bc00abad1
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 4 - Move XMLHttpRequestEventTarget in separate files, r=smaug
dom/bindings/Bindings.conf
dom/xhr/XMLHttpRequestEventTarget.cpp
dom/xhr/XMLHttpRequestEventTarget.h
dom/xhr/XMLHttpRequestUploadWorker.cpp
dom/xhr/XMLHttpRequestUploadWorker.h
dom/xhr/XMLHttpRequestWorker.cpp
dom/xhr/XMLHttpRequestWorker.h
dom/xhr/moz.build
dom/xhr/nsXMLHttpRequest.cpp
dom/xhr/nsXMLHttpRequest.h
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1584,18 +1584,16 @@ DOMInterfaces = {
 },
 {
     'nativeType': 'mozilla::dom::workers::XMLHttpRequestWorker',
     'headerFile': 'mozilla/dom/workers/bindings/XMLHttpRequestWorker.h',
     'workers': True,
 }],
 
 'XMLHttpRequestEventTarget': {
-    'nativeType': 'nsXHREventTarget',
-    'headerFile': 'nsXMLHttpRequest.h',
     'concrete': False
 },
 
 'XMLHttpRequestUpload': [
 {
     'nativeType': 'nsXMLHttpRequestUpload',
     'headerFile': 'nsXMLHttpRequest.h'
 },
new file mode 100644
--- /dev/null
+++ b/dom/xhr/XMLHttpRequestEventTarget.cpp
@@ -0,0 +1,36 @@
+/* -*- 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 "XMLHttpRequestEventTarget.h"
+
+namespace mozilla {
+namespace dom {
+
+NS_IMPL_CYCLE_COLLECTION_CLASS(XMLHttpRequestEventTarget)
+
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(XMLHttpRequestEventTarget,
+                                                  DOMEventTargetHelper)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(XMLHttpRequestEventTarget,
+                                                DOMEventTargetHelper)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(XMLHttpRequestEventTarget)
+  NS_INTERFACE_MAP_ENTRY(nsIXMLHttpRequestEventTarget)
+NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
+
+NS_IMPL_ADDREF_INHERITED(XMLHttpRequestEventTarget, DOMEventTargetHelper)
+NS_IMPL_RELEASE_INHERITED(XMLHttpRequestEventTarget, DOMEventTargetHelper)
+
+void
+XMLHttpRequestEventTarget::DisconnectFromOwner()
+{
+  DOMEventTargetHelper::DisconnectFromOwner();
+}
+
+} // dom namespace
+} // mozilla namespace
new file mode 100644
--- /dev/null
+++ b/dom/xhr/XMLHttpRequestEventTarget.h
@@ -0,0 +1,50 @@
+/* -*- 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/. */
+
+#ifndef mozilla_dom_XMLHttpRequestEventTarget_h
+#define mozilla_dom_XMLHttpRequestEventTarget_h
+
+#include "mozilla/DOMEventTargetHelper.h"
+#include "nsIXMLHttpRequest.h"
+
+namespace mozilla {
+namespace dom {
+
+class XMLHttpRequestEventTarget : public DOMEventTargetHelper,
+                                  public nsIXMLHttpRequestEventTarget
+{
+protected:
+  explicit XMLHttpRequestEventTarget(DOMEventTargetHelper* aOwner)
+    : DOMEventTargetHelper(aOwner)
+  {}
+
+  XMLHttpRequestEventTarget()
+  {}
+
+  virtual ~XMLHttpRequestEventTarget() {}
+
+public:
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XMLHttpRequestEventTarget,
+                                           DOMEventTargetHelper)
+  NS_DECL_NSIXMLHTTPREQUESTEVENTTARGET
+  NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
+
+  IMPL_EVENT_HANDLER(loadstart)
+  IMPL_EVENT_HANDLER(progress)
+  IMPL_EVENT_HANDLER(abort)
+  IMPL_EVENT_HANDLER(error)
+  IMPL_EVENT_HANDLER(load)
+  IMPL_EVENT_HANDLER(timeout)
+  IMPL_EVENT_HANDLER(loadend)
+
+  virtual void DisconnectFromOwner() override;
+};
+
+} // dom namespace
+} // mozilla namespace
+
+#endif // mozilla_dom_XMLHttpRequestEventTarget_h
--- a/dom/xhr/XMLHttpRequestUploadWorker.cpp
+++ b/dom/xhr/XMLHttpRequestUploadWorker.cpp
@@ -16,23 +16,23 @@ XMLHttpRequestUploadWorker::XMLHttpReque
 : mXHR(aXHR)
 {
 }
 
 XMLHttpRequestUploadWorker::~XMLHttpRequestUploadWorker()
 {
 }
 
-NS_IMPL_ADDREF_INHERITED(XMLHttpRequestUploadWorker, nsXHREventTarget)
-NS_IMPL_RELEASE_INHERITED(XMLHttpRequestUploadWorker, nsXHREventTarget)
+NS_IMPL_ADDREF_INHERITED(XMLHttpRequestUploadWorker, XMLHttpRequestEventTarget)
+NS_IMPL_RELEASE_INHERITED(XMLHttpRequestUploadWorker, XMLHttpRequestEventTarget)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(XMLHttpRequestUploadWorker)
-NS_INTERFACE_MAP_END_INHERITING(nsXHREventTarget)
+NS_INTERFACE_MAP_END_INHERITING(XMLHttpRequestEventTarget)
 
-NS_IMPL_CYCLE_COLLECTION_INHERITED(XMLHttpRequestUploadWorker, nsXHREventTarget,
+NS_IMPL_CYCLE_COLLECTION_INHERITED(XMLHttpRequestUploadWorker, XMLHttpRequestEventTarget,
                                    mXHR)
 
 JSObject*
 XMLHttpRequestUploadWorker::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return XMLHttpRequestUploadBinding_workers::Wrap(aCx, this, aGivenProto);
 }
 
--- a/dom/xhr/XMLHttpRequestUploadWorker.h
+++ b/dom/xhr/XMLHttpRequestUploadWorker.h
@@ -2,38 +2,38 @@
 /* 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/. */
 
 #ifndef mozilla_dom_workers_xmlhttprequestupload_h__
 #define mozilla_dom_workers_xmlhttprequestupload_h__
 
-#include "nsXMLHttpRequest.h"
+#include "mozilla/dom/XMLHttpRequestEventTarget.h"
 
 BEGIN_WORKERS_NAMESPACE
 
 class XMLHttpRequestWorker;
 
-class XMLHttpRequestUploadWorker final : public nsXHREventTarget
+class XMLHttpRequestUploadWorker final : public XMLHttpRequestEventTarget
 {
   RefPtr<XMLHttpRequestWorker> mXHR;
 
   explicit XMLHttpRequestUploadWorker(XMLHttpRequestWorker* aXHR);
 
   ~XMLHttpRequestUploadWorker();
 
 public:
   virtual JSObject*
   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   static already_AddRefed<XMLHttpRequestUploadWorker>
   Create(XMLHttpRequestWorker* aXHR);
 
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XMLHttpRequestUploadWorker, nsXHREventTarget)
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XMLHttpRequestUploadWorker, XMLHttpRequestEventTarget)
 
   NS_DECL_ISUPPORTS_INHERITED
 
   nsISupports*
   GetParentObject() const
   {
     // There's only one global on a worker, so we don't need to specify.
     return nullptr;
--- a/dom/xhr/XMLHttpRequestWorker.cpp
+++ b/dom/xhr/XMLHttpRequestWorker.cpp
@@ -1347,17 +1347,17 @@ EventRunnable::WorkerRun(JSContext* aCx,
   }
 
   JS::Rooted<JSString*> type(aCx,
     JS_NewUCStringCopyN(aCx, mType.get(), mType.Length()));
   if (!type) {
     return false;
   }
 
-  nsXHREventTarget* target;
+  XMLHttpRequestEventTarget* target;
   if (mUploadEvent) {
     target = xhr->GetUploadObjectNoCreate();
   }
   else {
     target = xhr;
   }
 
   MOZ_ASSERT(target);
@@ -1576,38 +1576,38 @@ XMLHttpRequestWorker::~XMLHttpRequestWor
 
   ReleaseProxy(XHRIsGoingAway);
 
   MOZ_ASSERT(!mRooted);
 
   mozilla::DropJSObjects(this);
 }
 
-NS_IMPL_ADDREF_INHERITED(XMLHttpRequestWorker, nsXHREventTarget)
-NS_IMPL_RELEASE_INHERITED(XMLHttpRequestWorker, nsXHREventTarget)
+NS_IMPL_ADDREF_INHERITED(XMLHttpRequestWorker, XMLHttpRequestEventTarget)
+NS_IMPL_RELEASE_INHERITED(XMLHttpRequestWorker, XMLHttpRequestEventTarget)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(XMLHttpRequestWorker)
-NS_INTERFACE_MAP_END_INHERITING(nsXHREventTarget)
+NS_INTERFACE_MAP_END_INHERITING(XMLHttpRequestEventTarget)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(XMLHttpRequestWorker)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(XMLHttpRequestWorker,
-                                                  nsXHREventTarget)
+                                                  XMLHttpRequestEventTarget)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mUpload)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(XMLHttpRequestWorker,
-                                                nsXHREventTarget)
+                                                XMLHttpRequestEventTarget)
   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(XMLHttpRequestWorker,
-                                               nsXHREventTarget)
+                                               XMLHttpRequestEventTarget)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mStateData.mResponse)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 JSObject*
 XMLHttpRequestWorker::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return XMLHttpRequestBinding_workers::Wrap(aCx, this, aGivenProto);
 }
--- a/dom/xhr/XMLHttpRequestWorker.h
+++ b/dom/xhr/XMLHttpRequestWorker.h
@@ -24,17 +24,17 @@ class Blob;
 
 BEGIN_WORKERS_NAMESPACE
 
 class Proxy;
 class SendRunnable;
 class XMLHttpRequestUploadWorker;
 class WorkerPrivate;
 
-class XMLHttpRequestWorker final : public nsXHREventTarget,
+class XMLHttpRequestWorker final : public XMLHttpRequestEventTarget,
                                    public WorkerHolder
 {
 public:
   struct StateData
   {
     nsString mResponseText;
     nsString mResponseURL;
     uint32_t mStatus;
@@ -72,17 +72,17 @@ private:
   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(XMLHttpRequestWorker,
-                                                         nsXHREventTarget)
+                                                         XMLHttpRequestEventTarget)
 
   nsISupports*
   GetParentObject() const
   {
     // There's only one global on a worker, so we don't need to specify.
     return nullptr;
   }
 
--- a/dom/xhr/moz.build
+++ b/dom/xhr/moz.build
@@ -11,22 +11,27 @@ XPIDL_SOURCES += [
 XPIDL_MODULE = 'dom_xhr'
 
 # Stuff needed for the bindings, not really public though.
 EXPORTS.mozilla.dom.workers.bindings += [
     'XMLHttpRequestUploadWorker.h',
     'XMLHttpRequestWorker.h',
 ]
 
+EXPORTS.mozilla.dom += [
+    'XMLHttpRequestEventTarget.h',
+]
+
 EXPORTS += [
     'nsXMLHttpRequest.h',
 ]
 
 UNIFIED_SOURCES += [
     'nsXMLHttpRequest.cpp',
+    'XMLHttpRequestEventTarget.cpp',
     'XMLHttpRequestUploadWorker.cpp',
     'XMLHttpRequestWorker.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '/dom/base',
     '/dom/workers',
     '/netwerk/base',
--- a/dom/xhr/nsXMLHttpRequest.cpp
+++ b/dom/xhr/nsXMLHttpRequest.cpp
@@ -175,47 +175,22 @@ static void AddLoadFlags(nsIRequest *req
   nsLoadFlags flags;
   request->GetLoadFlags(&flags);
   flags |= newFlags;
   request->SetLoadFlags(flags);
 }
 
 /////////////////////////////////////////////
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsXHREventTarget)
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXHREventTarget,
-                                                  DOMEventTargetHelper)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXHREventTarget,
-                                                DOMEventTargetHelper)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsXHREventTarget)
-  NS_INTERFACE_MAP_ENTRY(nsIXMLHttpRequestEventTarget)
-NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
-
-NS_IMPL_ADDREF_INHERITED(nsXHREventTarget, DOMEventTargetHelper)
-NS_IMPL_RELEASE_INHERITED(nsXHREventTarget, DOMEventTargetHelper)
-
-void
-nsXHREventTarget::DisconnectFromOwner()
-{
-  DOMEventTargetHelper::DisconnectFromOwner();
-}
-
-/////////////////////////////////////////////
-
 NS_INTERFACE_MAP_BEGIN(nsXMLHttpRequestUpload)
   NS_INTERFACE_MAP_ENTRY(nsIXMLHttpRequestUpload)
-NS_INTERFACE_MAP_END_INHERITING(nsXHREventTarget)
-
-NS_IMPL_ADDREF_INHERITED(nsXMLHttpRequestUpload, nsXHREventTarget)
-NS_IMPL_RELEASE_INHERITED(nsXMLHttpRequestUpload, nsXHREventTarget)
+NS_INTERFACE_MAP_END_INHERITING(XMLHttpRequestEventTarget)
+
+NS_IMPL_ADDREF_INHERITED(nsXMLHttpRequestUpload, XMLHttpRequestEventTarget)
+NS_IMPL_RELEASE_INHERITED(nsXMLHttpRequestUpload, XMLHttpRequestEventTarget)
 
 /* virtual */ JSObject*
 nsXMLHttpRequestUpload::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return XMLHttpRequestUploadBinding::Wrap(aCx, this, aGivenProto);
 }
 
 /////////////////////////////////////////////
@@ -397,17 +372,17 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_
     IsBlackAndDoesNotNeedTracing(static_cast<DOMEventTargetHelper*>(tmp));
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_END
 
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(nsXMLHttpRequest)
   return tmp->IsBlack();
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXMLHttpRequest,
-                                                  nsXHREventTarget)
+                                                  XMLHttpRequestEventTarget)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContext)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChannel)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mResponseXML)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mXMLParserStreamListener)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mResponseBlob)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDOMBlob)
@@ -415,17 +390,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChannelEventSink)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mProgressEventSink)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mUpload)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXMLHttpRequest,
-                                                nsXHREventTarget)
+                                                XMLHttpRequestEventTarget)
   tmp->mResultArrayBuffer = nullptr;
   tmp->mArrayBufferBuilder.reset();
   tmp->mResultJSON.setUndefined();
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mContext)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mChannel)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mResponseXML)
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mXMLParserStreamListener)
@@ -436,44 +411,44 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_IN
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mChannelEventSink)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mProgressEventSink)
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mUpload)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(nsXMLHttpRequest,
-                                               nsXHREventTarget)
+                                               XMLHttpRequestEventTarget)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mResultArrayBuffer)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mResultJSON)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 // QueryInterface implementation for nsXMLHttpRequest
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsXMLHttpRequest)
   NS_INTERFACE_MAP_ENTRY(nsIXMLHttpRequest)
   NS_INTERFACE_MAP_ENTRY(nsIJSXMLHttpRequest)
   NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
   NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
   NS_INTERFACE_MAP_ENTRY(nsIChannelEventSink)
   NS_INTERFACE_MAP_ENTRY(nsIProgressEventSink)
   NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
   NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
   NS_INTERFACE_MAP_ENTRY(nsISizeOfEventTarget)
-NS_INTERFACE_MAP_END_INHERITING(nsXHREventTarget)
-
-NS_IMPL_ADDREF_INHERITED(nsXMLHttpRequest, nsXHREventTarget)
-NS_IMPL_RELEASE_INHERITED(nsXMLHttpRequest, nsXHREventTarget)
+NS_INTERFACE_MAP_END_INHERITING(XMLHttpRequestEventTarget)
+
+NS_IMPL_ADDREF_INHERITED(nsXMLHttpRequest, XMLHttpRequestEventTarget)
+NS_IMPL_RELEASE_INHERITED(nsXMLHttpRequest, XMLHttpRequestEventTarget)
 
 NS_IMPL_EVENT_HANDLER(nsXMLHttpRequest, readystatechange)
 
 void
 nsXMLHttpRequest::DisconnectFromOwner()
 {
-  nsXHREventTarget::DisconnectFromOwner();
+  XMLHttpRequestEventTarget::DisconnectFromOwner();
   Abort();
 }
 
 size_t
 nsXMLHttpRequest::SizeOfEventTargetIncludingThis(
   MallocSizeOf aMallocSizeOf) const
 {
   size_t n = aMallocSizeOf(this);
--- a/dom/xhr/nsXMLHttpRequest.h
+++ b/dom/xhr/nsXMLHttpRequest.h
@@ -31,16 +31,17 @@
 #include "nsIInputStream.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/NotNull.h"
 #include "mozilla/dom/TypedArray.h"
 #include "mozilla/dom/XMLHttpRequestBinding.h"
+#include "mozilla/dom/XMLHttpRequestEventTarget.h"
 
 #ifdef Status
 /* Xlib headers insist on this for some reason... Nuke it because
    it'll override our member name */
 #undef Status
 #endif
 
 class nsIJARChannel;
@@ -104,66 +105,28 @@ public:
 
 protected:
   static bool areOverlappingRegions(const uint8_t* aStart1, uint32_t aLength1,
                                     const uint8_t* aStart2, uint32_t aLength2);
 };
 
 } // namespace mozilla
 
-class nsXHREventTarget : public mozilla::DOMEventTargetHelper,
-                         public nsIXMLHttpRequestEventTarget
-{
-protected:
-  explicit nsXHREventTarget(mozilla::DOMEventTargetHelper* aOwner)
-    : mozilla::DOMEventTargetHelper(aOwner)
-  {
-  }
-
-  nsXHREventTarget()
-  {
-  }
-
-  virtual ~nsXHREventTarget() {}
-
-public:
-  typedef mozilla::dom::XMLHttpRequestResponseType
-          XMLHttpRequestResponseType;
-  typedef mozilla::ErrorResult
-          ErrorResult;
-
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXHREventTarget,
-                                           mozilla::DOMEventTargetHelper)
-  NS_DECL_NSIXMLHTTPREQUESTEVENTTARGET
-  NS_REALLY_FORWARD_NSIDOMEVENTTARGET(mozilla::DOMEventTargetHelper)
-
-  IMPL_EVENT_HANDLER(loadstart)
-  IMPL_EVENT_HANDLER(progress)
-  IMPL_EVENT_HANDLER(abort)
-  IMPL_EVENT_HANDLER(error)
-  IMPL_EVENT_HANDLER(load)
-  IMPL_EVENT_HANDLER(timeout)
-  IMPL_EVENT_HANDLER(loadend)
-
-  virtual void DisconnectFromOwner() override;
-};
-
-class nsXMLHttpRequestUpload final : public nsXHREventTarget,
+class nsXMLHttpRequestUpload final : public mozilla::dom::XMLHttpRequestEventTarget,
                                      public nsIXMLHttpRequestUpload
 {
 public:
   explicit nsXMLHttpRequestUpload(mozilla::DOMEventTargetHelper* aOwner)
-    : nsXHREventTarget(aOwner)
+    : XMLHttpRequestEventTarget(aOwner)
   {
   }
 
   NS_DECL_ISUPPORTS_INHERITED
-  NS_FORWARD_NSIXMLHTTPREQUESTEVENTTARGET(nsXHREventTarget::)
-  NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsXHREventTarget)
+  NS_FORWARD_NSIXMLHTTPREQUESTEVENTTARGET(XMLHttpRequestEventTarget::)
+  NS_REALLY_FORWARD_NSIDOMEVENTTARGET(mozilla::dom::XMLHttpRequestEventTarget)
   NS_DECL_NSIXMLHTTPREQUESTUPLOAD
 
   virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
   nsISupports* GetParentObject()
   {
     return GetOwner();
   }
 
@@ -175,17 +138,17 @@ public:
 private:
   virtual ~nsXMLHttpRequestUpload() {}
 };
 
 class nsXMLHttpRequestXPCOMifier;
 
 // Make sure that any non-DOM interfaces added here are also added to
 // nsXMLHttpRequestXPCOMifier.
-class nsXMLHttpRequest final : public nsXHREventTarget,
+class nsXMLHttpRequest final : public mozilla::dom::XMLHttpRequestEventTarget,
                                public nsIXMLHttpRequest,
                                public nsIJSXMLHttpRequest,
                                public nsIStreamListener,
                                public nsIChannelEventSink,
                                public nsIProgressEventSink,
                                public nsIInterfaceRequestor,
                                public nsSupportsWeakReference,
                                public nsITimerCallback,
@@ -205,17 +168,17 @@ public:
   {
     return GetOwner();
   }
 
   // The WebIDL constructors.
   static already_AddRefed<nsXMLHttpRequest>
   Constructor(const mozilla::dom::GlobalObject& aGlobal,
               const mozilla::dom::MozXMLHttpRequestParameters& aParams,
-              ErrorResult& aRv)
+              mozilla::ErrorResult& aRv)
   {
     nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
     nsCOMPtr<nsIScriptObjectPrincipal> principal =
       do_QueryInterface(aGlobal.GetAsSupports());
     if (!global || ! principal) {
       aRv.Throw(NS_ERROR_FAILURE);
       return nullptr;
     }
@@ -224,17 +187,17 @@ public:
     req->Construct(principal->GetPrincipal(), global);
     req->InitParameters(aParams.mMozAnon, aParams.mMozSystem);
     return req.forget();
   }
 
   static already_AddRefed<nsXMLHttpRequest>
   Constructor(const mozilla::dom::GlobalObject& aGlobal,
               const nsAString& ignored,
-              ErrorResult& aRv)
+              mozilla::ErrorResult& aRv)
   {
     // Pretend like someone passed null, so we can pick up the default values
     mozilla::dom::MozXMLHttpRequestParameters params;
     if (!params.Init(aGlobal.Context(), JS::NullHandleValue)) {
       aRv.Throw(NS_ERROR_UNEXPECTED);
       return nullptr;
     }
 
@@ -263,17 +226,17 @@ public:
     mIsSystem = aSystem;
   }
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIXMLHttpRequest
   NS_DECL_NSIXMLHTTPREQUEST
 
-  NS_FORWARD_NSIXMLHTTPREQUESTEVENTTARGET(nsXHREventTarget::)
+  NS_FORWARD_NSIXMLHTTPREQUESTEVENTTARGET(mozilla::dom::XMLHttpRequestEventTarget::)
 
   // nsIStreamListener
   NS_DECL_NSISTREAMLISTENER
 
   // nsIRequestObserver
   NS_DECL_NSIREQUESTOBSERVER
 
   // nsIChannelEventSink
@@ -287,56 +250,57 @@ public:
 
   // nsITimerCallback
   NS_DECL_NSITIMERCALLBACK
 
   // nsISizeOfEventTarget
   virtual size_t
     SizeOfEventTargetIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
 
-  NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsXHREventTarget)
+  NS_REALLY_FORWARD_NSIDOMEVENTTARGET(mozilla::dom::XMLHttpRequestEventTarget)
 
 #ifdef DEBUG
   void StaticAssertions();
 #endif
 
   // event handler
   IMPL_EVENT_HANDLER(readystatechange)
 
   // states
   uint16_t ReadyState();
 
   // request
-  void Open(const nsACString& aMethod, const nsAString& aUrl, ErrorResult& aRv)
+  void Open(const nsACString& aMethod, const nsAString& aUrl,
+            mozilla::ErrorResult& aRv)
   {
     Open(aMethod, aUrl, true,
          mozilla::dom::Optional<nsAString>(),
          mozilla::dom::Optional<nsAString>(),
          aRv);
   }
   void Open(const nsACString& aMethod, const nsAString& aUrl, bool aAsync,
             const mozilla::dom::Optional<nsAString>& aUser,
             const mozilla::dom::Optional<nsAString>& aPassword,
-            ErrorResult& aRv)
+            mozilla::ErrorResult& aRv)
   {
     aRv = Open(aMethod, NS_ConvertUTF16toUTF8(aUrl),
                aAsync, aUser, aPassword);
   }
   void SetRequestHeader(const nsACString& aHeader, const nsACString& aValue,
-                        ErrorResult& aRv)
+                        mozilla::ErrorResult& aRv)
   {
     aRv = SetRequestHeader(aHeader, aValue);
   }
   uint32_t Timeout()
   {
     return mTimeoutMilliseconds;
   }
-  void SetTimeout(uint32_t aTimeout, ErrorResult& aRv);
+  void SetTimeout(uint32_t aTimeout, mozilla::ErrorResult& aRv);
   bool WithCredentials();
-  void SetWithCredentials(bool aWithCredentials, ErrorResult& aRv);
+  void SetWithCredentials(bool aWithCredentials, mozilla::ErrorResult& aRv);
   nsXMLHttpRequestUpload* Upload();
 
 private:
   virtual ~nsXMLHttpRequest();
 
   class RequestBody
   {
   public:
@@ -429,55 +393,56 @@ private:
   bool IsDeniedCrossSiteCORSRequest();
 
   // Tell our channel what network interface ID we were told to use.
   // If it's an HTTP channel and we were told to use a non-default
   // interface ID.
   void PopulateNetworkInterfaceId();
 
 public:
-  void Send(JSContext* /*aCx*/, ErrorResult& aRv)
+  void Send(JSContext* /*aCx*/, mozilla::ErrorResult& aRv)
   {
     aRv = Send(Nullable<RequestBody>());
   }
   void Send(JSContext* /*aCx*/,
             const mozilla::dom::ArrayBuffer& aArrayBuffer,
-            ErrorResult& aRv)
+            mozilla::ErrorResult& aRv)
   {
     aRv = Send(RequestBody(&aArrayBuffer));
   }
   void Send(JSContext* /*aCx*/,
             const mozilla::dom::ArrayBufferView& aArrayBufferView,
-            ErrorResult& aRv)
+            mozilla::ErrorResult& aRv)
   {
     aRv = Send(RequestBody(&aArrayBufferView));
   }
-  void Send(JSContext* /*aCx*/, mozilla::dom::Blob& aBlob, ErrorResult& aRv)
+  void Send(JSContext* /*aCx*/, mozilla::dom::Blob& aBlob,
+            mozilla::ErrorResult& aRv)
   {
     aRv = Send(RequestBody(aBlob));
   }
-  void Send(JSContext* /*aCx*/, nsIDocument& aDoc, ErrorResult& aRv)
+  void Send(JSContext* /*aCx*/, nsIDocument& aDoc, mozilla::ErrorResult& aRv)
   {
     aRv = Send(RequestBody(&aDoc));
   }
-  void Send(JSContext* aCx, const nsAString& aString, ErrorResult& aRv)
+  void Send(JSContext* aCx, const nsAString& aString, mozilla::ErrorResult& aRv)
   {
     if (DOMStringIsNull(aString)) {
       Send(aCx, aRv);
     }
     else {
       aRv = Send(RequestBody(aString));
     }
   }
   void Send(JSContext* /*aCx*/, mozilla::dom::FormData& aFormData,
-            ErrorResult& aRv)
+            mozilla::ErrorResult& aRv)
   {
     aRv = Send(RequestBody(aFormData));
   }
-  void Send(JSContext* aCx, nsIInputStream* aStream, ErrorResult& aRv)
+  void Send(JSContext* aCx, nsIInputStream* aStream, mozilla::ErrorResult& aRv)
   {
     NS_ASSERTION(aStream, "Null should go to string version");
     nsCOMPtr<nsIXPConnectWrappedJS> wjs = do_QueryInterface(aStream);
     if (wjs) {
       JSObject* data = wjs->GetJSObject();
       if (!data) {
         aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
         return;
@@ -497,43 +462,44 @@ public:
 
   void Abort();
 
   // response
   void GetResponseURL(nsAString& aUrl);
   uint32_t Status();
   void GetStatusText(nsCString& aStatusText);
   void GetResponseHeader(const nsACString& aHeader, nsACString& aResult,
-                         ErrorResult& aRv);
+                         mozilla::ErrorResult& aRv);
   void GetResponseHeader(const nsAString& aHeader, nsString& aResult,
-                         ErrorResult& aRv)
+                         mozilla::ErrorResult& aRv)
   {
     nsCString result;
     GetResponseHeader(NS_ConvertUTF16toUTF8(aHeader), result, aRv);
     if (result.IsVoid()) {
       aResult.SetIsVoid(true);
     }
     else {
       // The result value should be inflated:
       CopyASCIItoUTF16(result, aResult);
     }
   }
   void GetAllResponseHeaders(nsCString& aResponseHeaders);
   bool IsSafeHeader(const nsACString& aHeaderName,
                     mozilla::NotNull<nsIHttpChannel*> aHttpChannel) const;
-  void OverrideMimeType(const nsAString& aMimeType, ErrorResult& aRv);
-  XMLHttpRequestResponseType ResponseType()
+  void OverrideMimeType(const nsAString& aMimeType, mozilla::ErrorResult& aRv);
+  mozilla::dom::XMLHttpRequestResponseType ResponseType()
   {
-    return XMLHttpRequestResponseType(mResponseType);
+    return mozilla::dom::XMLHttpRequestResponseType(mResponseType);
   }
-  void SetResponseType(XMLHttpRequestResponseType aType, ErrorResult& aRv);
+  void SetResponseType(mozilla::dom::XMLHttpRequestResponseType aType,
+                       mozilla::ErrorResult& aRv);
   void GetResponse(JSContext* aCx, JS::MutableHandle<JS::Value> aResponse,
-                   ErrorResult& aRv);
-  void GetResponseText(nsString& aResponseText, ErrorResult& aRv);
-  nsIDocument* GetResponseXML(ErrorResult& aRv);
+                   mozilla::ErrorResult& aRv);
+  void GetResponseText(nsString& aResponseText, mozilla::ErrorResult& aRv);
+  nsIDocument* GetResponseXML(mozilla::ErrorResult& aRv);
 
   bool MozBackgroundRequest();
   void SetMozBackgroundRequest(bool aMozBackgroundRequest, nsresult& aRv);
 
   bool MozAnon();
   bool MozSystem();
 
   nsIChannel* GetChannel()
@@ -548,17 +514,18 @@ public:
 
   void SetNetworkInterfaceId(const nsACString& aId)
   {
     mNetworkInterfaceId = aId;
   }
 
   // We need a GetInterface callable from JS for chrome JS
   void GetInterface(JSContext* aCx, nsIJSID* aIID,
-                    JS::MutableHandle<JS::Value> aRetval, ErrorResult& aRv);
+                    JS::MutableHandle<JS::Value> aRetval,
+                    mozilla::ErrorResult& aRv);
 
   // This creates a trusted readystatechange event, which is not cancelable and
   // doesn't bubble.
   nsresult CreateReadystatechangeEvent(nsIDOMEvent** aDOMEvent);
   void DispatchProgressEvent(mozilla::DOMEventTargetHelper* aTarget,
                              const nsAString& aType,
                              bool aLengthComputable,
                              int64_t aLoaded, int64_t aTotal);
@@ -574,17 +541,17 @@ public:
   nsresult init(nsIPrincipal* principal,
                 nsIScriptContext* scriptContext,
                 nsPIDOMWindowInner* globalObject,
                 nsIURI* baseURI);
 
   void SetRequestObserver(nsIRequestObserver* aObserver);
 
   NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_INHERITED(nsXMLHttpRequest,
-                                                                   nsXHREventTarget)
+                                                                   mozilla::dom::XMLHttpRequestEventTarget)
   bool AllowUploadProgress();
   void RootJSResultObjects();
 
   virtual void DisconnectFromOwner() override;
 
   static void SetDontWarnAboutSyncXHR(bool aVal)
   {
     sDontWarnAboutSyncXHR = aVal;
@@ -598,17 +565,17 @@ protected:
   nsresult AppendToResponseText(const char * aBuffer, uint32_t aBufferLen);
   static NS_METHOD StreamReaderFunc(nsIInputStream* in,
                 void* closure,
                 const char* fromRawSegment,
                 uint32_t toOffset,
                 uint32_t count,
                 uint32_t *writeCount);
   nsresult CreateResponseParsedJSON(JSContext* aCx);
-  void CreatePartialBlob(ErrorResult& aRv);
+  void CreatePartialBlob(mozilla::ErrorResult& aRv);
   bool CreateDOMBlob(nsIRequest *request);
   // Change the state of the object with this. The broadcast argument
   // determines if the onreadystatechange listener should be called.
   nsresult ChangeState(uint32_t aState, bool aBroadcast = true);
   already_AddRefed<nsILoadGroup> GetLoadGroup() const;
   nsIURI *GetBaseURI();
 
   already_AddRefed<nsIHttpChannel> GetCurrentHttpChannel();
@@ -686,17 +653,18 @@ protected:
     XML_HTTP_RESPONSE_TYPE_DOCUMENT,
     XML_HTTP_RESPONSE_TYPE_JSON,
     XML_HTTP_RESPONSE_TYPE_TEXT,
     XML_HTTP_RESPONSE_TYPE_CHUNKED_TEXT,
     XML_HTTP_RESPONSE_TYPE_CHUNKED_ARRAYBUFFER,
     XML_HTTP_RESPONSE_TYPE_MOZ_BLOB
   };
 
-  void SetResponseType(nsXMLHttpRequest::ResponseTypeEnum aType, ErrorResult& aRv);
+  void SetResponseType(nsXMLHttpRequest::ResponseTypeEnum aType,
+                       mozilla::ErrorResult& aRv);
 
   ResponseTypeEnum mResponseType;
 
   // It is either a cached blob-response from the last call to GetResponse,
   // but is also explicitly set in OnStopRequest.
   RefPtr<mozilla::dom::Blob> mResponseBlob;
   // Non-null only when we are able to get a os-file representation of the
   // response, i.e. when loading from a file.