Bug 1285036 - Part 5: Consolidate the readystatechange-firing code into a function named FireReadyStateChange(). r=baku
authorThomas Wisniewski <wisniewskit@gmail.com>
Fri, 08 Jul 2016 12:50:48 -0400
changeset 304468 d4fc0549bed0fdefdf98d33f3ac54468235fbfad
parent 304467 18a736ed2156f9715d2e2b5725279c2bafc64d8b
child 304469 21cd5236715f0b23658968189cfbeac1d1bf21b6
push id30426
push usercbook@mozilla.com
push dateMon, 11 Jul 2016 14:21:30 +0000
treeherdermozilla-central@214884d507ee [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)
@@ -3113,21 +3110,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.