Bug 1224596 part 4. Switch WebSocket to using the new WorkerMainThreadRunnable::Dispatch signature. r=khuey
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 24 Nov 2015 00:04:20 -0500
changeset 295569 01b94e9f414ec7d5bc30a713f5fda98477e7f00f
parent 295568 33b34208ab03fd5b593b379d7298cb43cc1782af
child 295570 7c72aa605302ecb43b3acd1aebc2cf585aa5ba71
push id8824
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:18:56 +0000
treeherdermozilla-aurora@e2031358e2a6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1224596
milestone45.0a1
Bug 1224596 part 4. Switch WebSocket to using the new WorkerMainThreadRunnable::Dispatch signature. r=khuey
dom/base/WebSocket.cpp
--- a/dom/base/WebSocket.cpp
+++ b/dom/base/WebSocket.cpp
@@ -331,17 +331,23 @@ WebSocketImpl::PrintErrorOnConsole(const
   // This method must run on the main thread.
 
   if (!NS_IsMainThread()) {
     MOZ_ASSERT(mWorkerPrivate);
 
     RefPtr<PrintErrorOnConsoleRunnable> runnable =
       new PrintErrorOnConsoleRunnable(this, aBundleURI, aError, aFormatStrings,
                                       aFormatStringsLen);
-    runnable->Dispatch(mWorkerPrivate->GetJSContext());
+    ErrorResult rv;
+    runnable->Dispatch(rv);
+    // XXXbz this seems totally broken.  We should be propagating this out, but
+    // none of our callers really propagate anything usefully.  Come to think of
+    // it, why is this a syncrunnable anyway?  Can't this be a fire-and-forget
+    // runnable??
+    rv.SuppressException();
     return;
   }
 
   nsresult rv;
   nsCOMPtr<nsIStringBundleService> bundleService =
     do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS_VOID(rv);
 
@@ -612,17 +618,21 @@ WebSocketImpl::Disconnect()
   // DisconnectInternal touches observers and nsILoadGroup and it must run on
   // the main thread.
 
   if (NS_IsMainThread()) {
     DisconnectInternal();
   } else {
     RefPtr<DisconnectInternalRunnable> runnable =
       new DisconnectInternalRunnable(this);
-    runnable->Dispatch(mWorkerPrivate->GetJSContext());
+    ErrorResult rv;
+    runnable->Dispatch(rv);
+    // XXXbz this seems totally broken.  We should be propagating this out, but
+    // where to, exactly?
+    rv.SuppressException();
   }
 
   // DontKeepAliveAnyMore() can release the object. So hold a reference to this
   // until the end of the method.
   RefPtr<WebSocketImpl> kungfuDeathGrip = this;
 
   NS_ReleaseOnMainThread(mChannel);
   NS_ReleaseOnMainThread(static_cast<nsIWebSocketEventService*>(mService.forget().take()));
@@ -1254,17 +1264,17 @@ WebSocket::Constructor(const GlobalObjec
                                     &column)) {
       NS_WARNING("Failed to get line number and filename in workers.");
     }
 
     RefPtr<InitRunnable> runnable =
       new InitRunnable(webSocket->mImpl, aUrl, protocolArray,
                        nsAutoCString(file.get()), lineno, column, aRv,
                        &connectionFailed);
-    runnable->Dispatch(aGlobal.Context());
+    runnable->Dispatch(aRv);
   }
 
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   // It can be that we have been already disconnected because the WebSocket is
   // gone away while we where initializing the webSocket.
@@ -1334,17 +1344,17 @@ WebSocket::Constructor(const GlobalObjec
     if (topWindow) {
       windowID = topWindow->WindowID();
     }
 
     webSocket->mImpl->AsyncOpen(principal, windowID, aRv);
   } else {
     RefPtr<AsyncOpenRunnable> runnable =
       new AsyncOpenRunnable(webSocket->mImpl, aRv);
-    runnable->Dispatch(aGlobal.Context());
+    runnable->Dispatch(aRv);
   }
 
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   // It can be that we have been already disconnected because the WebSocket is
   // gone away while we where initializing the webSocket.