Bug 1224596 part 3. Make some WebSocket(Impl) methods whose return value is totally ignored void. r=khuey
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 24 Nov 2015 00:04:20 -0500
changeset 295568 33b34208ab03fd5b593b379d7298cb43cc1782af
parent 295567 706147f947c3a46d25936869dbe8425937597a97
child 295569 01b94e9f414ec7d5bc30a713f5fda98477e7f00f
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 3. Make some WebSocket(Impl) methods whose return value is totally ignored void. r=khuey
dom/base/WebSocket.cpp
--- a/dom/base/WebSocket.cpp
+++ b/dom/base/WebSocket.cpp
@@ -133,24 +133,24 @@ public:
   nsresult ParseURL(const nsAString& aURL);
   nsresult InitializeConnection(nsIPrincipal* aPrincipal);
 
   // These methods when called can release the WebSocket object
   void FailConnection(uint16_t reasonCode,
                       const nsACString& aReasonString = EmptyCString());
   nsresult CloseConnection(uint16_t reasonCode,
                            const nsACString& aReasonString = EmptyCString());
-  nsresult Disconnect();
+  void Disconnect();
   void DisconnectInternal();
 
   nsresult ConsoleError();
-  nsresult PrintErrorOnConsole(const char* aBundleURI,
-                               const char16_t* aError,
-                               const char16_t** aFormatStrings,
-                               uint32_t aFormatStringsLen);
+  void PrintErrorOnConsole(const char* aBundleURI,
+                           const char16_t* aError,
+                           const char16_t** aFormatStrings,
+                           uint32_t aFormatStringsLen);
 
   nsresult DoOnMessageAvailable(const nsACString& aMsg,
                                 bool isBinary);
 
   // ConnectionCloseEvents: 'error' event if needed, then 'close' event.
   // - These must not be dispatched while we are still within an incoming call
   //   from JS (ex: close()).  Set 'sync' to false in that case to dispatch in a
   //   separate new event.
@@ -296,111 +296,102 @@ public:
                               const char16_t** aFormatStrings,
                               uint32_t aFormatStringsLen)
     : WorkerMainThreadRunnable(aImpl->mWorkerPrivate)
     , mImpl(aImpl)
     , mBundleURI(aBundleURI)
     , mError(aError)
     , mFormatStrings(aFormatStrings)
     , mFormatStringsLen(aFormatStringsLen)
-    , mRv(NS_ERROR_FAILURE)
   { }
 
   bool MainThreadRun() override
   {
-    mRv = mImpl->PrintErrorOnConsole(mBundleURI, mError, mFormatStrings,
-                                     mFormatStringsLen);
+    mImpl->PrintErrorOnConsole(mBundleURI, mError, mFormatStrings,
+                               mFormatStringsLen);
     return true;
   }
 
-  nsresult ErrorCode() const
-  {
-    return mRv;
-  }
-
 private:
   // Raw pointer because this runnable is sync.
   WebSocketImpl* mImpl;
 
   const char* mBundleURI;
   const char16_t* mError;
   const char16_t** mFormatStrings;
   uint32_t mFormatStringsLen;
-  nsresult mRv;
 };
 
 } // namespace
 
-nsresult
+void
 WebSocketImpl::PrintErrorOnConsole(const char *aBundleURI,
                                    const char16_t *aError,
                                    const char16_t **aFormatStrings,
                                    uint32_t aFormatStringsLen)
 {
   // 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());
-    return runnable->ErrorCode();
+    return;
   }
 
   nsresult rv;
   nsCOMPtr<nsIStringBundleService> bundleService =
     do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  NS_ENSURE_SUCCESS_VOID(rv);
 
   nsCOMPtr<nsIStringBundle> strBundle;
   rv = bundleService->CreateBundle(aBundleURI, getter_AddRefs(strBundle));
-  NS_ENSURE_SUCCESS(rv, rv);
+  NS_ENSURE_SUCCESS_VOID(rv);
 
   nsCOMPtr<nsIConsoleService> console(
     do_GetService(NS_CONSOLESERVICE_CONTRACTID, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  NS_ENSURE_SUCCESS_VOID(rv);
 
   nsCOMPtr<nsIScriptError> errorObject(
     do_CreateInstance(NS_SCRIPTERROR_CONTRACTID, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  NS_ENSURE_SUCCESS_VOID(rv);
 
   // Localize the error message
   nsXPIDLString message;
   if (aFormatStrings) {
     rv = strBundle->FormatStringFromName(aError, aFormatStrings,
                                          aFormatStringsLen,
                                          getter_Copies(message));
   } else {
     rv = strBundle->GetStringFromName(aError, getter_Copies(message));
   }
-  NS_ENSURE_SUCCESS(rv, rv);
+  NS_ENSURE_SUCCESS_VOID(rv);
 
   if (mInnerWindowID) {
     rv = errorObject->InitWithWindowID(message,
                                        NS_ConvertUTF8toUTF16(mScriptFile),
                                        EmptyString(), mScriptLine,
                                        mScriptColumn,
                                        nsIScriptError::errorFlag, "Web Socket",
                                        mInnerWindowID);
   } else {
     rv = errorObject->Init(message,
                            NS_ConvertUTF8toUTF16(mScriptFile),
                            EmptyString(), mScriptLine, mScriptColumn,
                            nsIScriptError::errorFlag, "Web Socket");
   }
 
-  NS_ENSURE_SUCCESS(rv, rv);
+  NS_ENSURE_SUCCESS_VOID(rv);
 
   // print the error message directly to the JS console
   rv = console->LogMessage(errorObject);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return NS_OK;
+  NS_ENSURE_SUCCESS_VOID(rv);
 }
 
 namespace {
 
 class CancelWebSocketRunnable final : public nsRunnable
 {
 public:
   CancelWebSocketRunnable(nsIWebSocketChannel* aChannel, uint16_t aReasonCode,
@@ -598,21 +589,21 @@ public:
 
 private:
   // A raw pointer because this runnable is sync.
   WebSocketImpl* mImpl;
 };
 
 } // namespace
 
-nsresult
+void
 WebSocketImpl::Disconnect()
 {
   if (mDisconnectingOrDisconnected) {
-    return NS_OK;
+    return;
   }
 
   AssertIsOnTargetThread();
 
   // Disconnect can be called from some control event (such as Notify() of
   // WorkerFeature). This will be schedulated before any other sync/async
   // runnable. In order to prevent some double Disconnect() calls, we use this
   // boolean.
@@ -640,18 +631,16 @@ WebSocketImpl::Disconnect()
   mWebSocket->mImpl = nullptr;
 
   if (mWorkerPrivate && mWorkerFeature) {
     UnregisterFeature();
   }
 
   // We want to release the WebSocket in the correct thread.
   mWebSocket = nullptr;
-
-  return NS_OK;
 }
 
 void
 WebSocketImpl::DisconnectInternal()
 {
   AssertIsOnMainThread();
 
   nsCOMPtr<nsILoadGroup> loadGroup = do_QueryReferent(mWeakLoadGroup);