Bug 1285036 - Part 5: Consolidate the readystatechange-firing code into a function named FireReadyStateChange(). r=baku
☠☠ backed out by 8f5af40eb365 ☠ ☠
authorThomas Wisniewski <wisniewskit@gmail.com>
Thu, 07 Jul 2016 11:56:04 -0400
changeset 304158 4ae182434a6a3fc5903923a0433785288e5b9649
parent 304157 0390a7afb12deb697239490c824fba4dc82563b4
child 304159 f7174077bd9215d6ac37d53dd08641aed0c1becb
push id30414
push usercbook@mozilla.com
push dateFri, 08 Jul 2016 09:59:01 +0000
treeherdermozilla-central@45682df2d2d4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1285036
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 1285036 - Part 5: Consolidate the readystatechange-firing code into a function named FireReadyStateChange(). r=baku
dom/xhr/XMLHttpRequestMainThread.cpp
dom/xhr/XMLHttpRequestMainThread.h
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -1267,26 +1267,23 @@ XMLHttpRequestMainThread::GetLoadGroup()
   if (doc) {
     return doc->GetDocumentLoadGroup();
   }
 
   return nullptr;
 }
 
 nsresult
-XMLHttpRequestMainThread::CreateReadystatechangeEvent(nsIDOMEvent** aDOMEvent)
+XMLHttpRequestMainThread::FireReadystatechangeEvent()
 {
   RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
-  event.forget(aDOMEvent);
-
-  (*aDOMEvent)->InitEvent(kLiteralString_readystatechange, false, false);
-
+  event->InitEvent(kLiteralString_readystatechange, false, false);
   // We assume anyone who managed to call CreateReadystatechangeEvent is trusted
-  (*aDOMEvent)->SetTrusted(true);
-
+  event->SetTrusted(true);
+  DispatchDOMEvent(nullptr, event, nullptr, nullptr);
   return NS_OK;
 }
 
 void
 XMLHttpRequestMainThread::DispatchProgressEvent(DOMEventTargetHelper* aTarget,
                                                 const ProgressEventType aType,
                                                 bool aLengthComputable,
                                                 int64_t aLoaded, int64_t aTotal)
@@ -3114,21 +3111,17 @@ XMLHttpRequestMainThread::ChangeState(St
     mProgressTimerIsActive = false;
     mProgressNotifier->Cancel();
   }
 
 
   if (aBroadcast && (!mFlagSynchronous ||
                      aState == State::opened ||
                      aState == State::done)) {
-    nsCOMPtr<nsIDOMEvent> event;
-    rv = CreateReadystatechangeEvent(getter_AddRefs(event));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+    rv = FireReadystatechangeEvent();
   }
 
   return rv;
 }
 
 /////////////////////////////////////////////////////
 // nsIChannelEventSink methods:
 //
--- a/dom/xhr/XMLHttpRequestMainThread.h
+++ b/dom/xhr/XMLHttpRequestMainThread.h
@@ -515,19 +515,19 @@ public:
   }
 
   // We need a GetInterface callable from JS for chrome JS
   virtual void
   GetInterface(JSContext* aCx, nsIJSID* aIID,
                JS::MutableHandle<JS::Value> aRetval,
                ErrorResult& aRv) override;
 
-  // This creates a trusted readystatechange event, which is not cancelable and
+  // This fires a trusted readystatechange event, which is not cancelable and
   // doesn't bubble.
-  nsresult CreateReadystatechangeEvent(nsIDOMEvent** aDOMEvent);
+  nsresult FireReadystatechangeEvent();
   void DispatchProgressEvent(DOMEventTargetHelper* aTarget,
                              const ProgressEventType aType,
                              bool aLengthComputable,
                              int64_t aLoaded, int64_t aTotal);
 
   // Dispatch the "progress" event on the XHR or XHR.upload object if we've
   // received data since the last "progress" event. Also dispatches
   // "uploadprogress" as needed.