Bug 1323949 - Use MOZ_MUST_USE in netwerk/protocol/websocket r=valentin
authorWei-Cheng Pan <wpan@mozilla.com>
Wed, 23 Nov 2016 18:00:42 +0800
changeset 375018 60dcbc3c90267f6bd083c6a43be48a744d103b2c
parent 375017 b172f492f29ff072fe0c16b5d21856222f65bdd7
child 375019 6587e676b76d68462cacdb567e4c39fff1057194
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1323949
milestone53.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 1323949 - Use MOZ_MUST_USE in netwerk/protocol/websocket r=valentin MozReview-Commit-ID: 6lNrHbDIUez
dom/base/WebSocket.cpp
dom/flyweb/FlyWebPublishedServer.cpp
netwerk/base/nsNetUtil.h
netwerk/protocol/websocket/WebSocketChannel.cpp
netwerk/protocol/websocket/WebSocketChannel.h
netwerk/protocol/websocket/WebSocketChannelChild.cpp
netwerk/protocol/websocket/WebSocketChannelChild.h
netwerk/protocol/websocket/WebSocketChannelParent.cpp
netwerk/protocol/websocket/WebSocketEventListenerParent.cpp
netwerk/protocol/websocket/nsITransportProvider.idl
netwerk/protocol/websocket/nsIWebSocketChannel.idl
netwerk/protocol/websocket/nsIWebSocketEventService.idl
netwerk/protocol/websocket/nsIWebSocketListener.idl
--- a/dom/base/WebSocket.cpp
+++ b/dom/base/WebSocket.cpp
@@ -404,17 +404,20 @@ public:
                           const nsACString& aReasonString)
     : mChannel(aChannel)
     , mReasonCode(aReasonCode)
     , mReasonString(aReasonString)
   {}
 
   NS_IMETHOD Run() override
   {
-    mChannel->Close(mReasonCode, mReasonString);
+    nsresult rv = mChannel->Close(mReasonCode, mReasonString);
+    if (NS_FAILED(rv)) {
+      NS_WARNING("Failed to dispatch the close message");
+    }
     return NS_OK;
   }
 
 private:
   nsCOMPtr<nsIWebSocketChannel> mChannel;
   uint16_t mReasonCode;
   nsCString mReasonString;
 };
@@ -753,20 +756,22 @@ WebSocketImpl::OnStart(nsISupports* aCon
   // Attempt to kill "ghost" websocket: but usually too early for check to fail
   nsresult rv = mWebSocket->CheckInnerWindowCorrectness();
   if (NS_FAILED(rv)) {
     CloseConnection(nsIWebSocketChannel::CLOSE_GOING_AWAY);
     return rv;
   }
 
   if (!mRequestedProtocolList.IsEmpty()) {
-    mChannel->GetProtocol(mWebSocket->mEstablishedProtocol);
+    rv = mChannel->GetProtocol(mWebSocket->mEstablishedProtocol);
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
   }
 
-  mChannel->GetExtensions(mWebSocket->mEstablishedExtensions);
+  rv = mChannel->GetExtensions(mWebSocket->mEstablishedExtensions);
+  MOZ_ASSERT(NS_SUCCEEDED(rv));
   UpdateURI();
 
   mWebSocket->SetReadyState(WebSocket::OPEN);
 
   mService->WebSocketOpened(mChannel->Serial(),mInnerWindowID,
                             mWebSocket->mEffectiveURL,
                             mWebSocket->mEstablishedProtocol,
                             mWebSocket->mEstablishedExtensions);
@@ -1851,21 +1856,22 @@ WebSocketImpl::InitializeConnection(nsIP
   mOriginDocument = nullptr;
 
 
   // The TriggeringPrincipal for websockets must always be a script.
   // Let's make sure that the doc's principal (if a doc exists)
   // and aPrincipal are same origin.
   MOZ_ASSERT(!doc || doc->NodePrincipal()->Equals(aPrincipal));
 
-  wsChannel->InitLoadInfo(doc ? doc->AsDOMNode() : nullptr,
-                          doc ? doc->NodePrincipal() : aPrincipal,
-                          aPrincipal,
-                          nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
-                          nsIContentPolicy::TYPE_WEBSOCKET);
+  rv = wsChannel->InitLoadInfo(doc ? doc->AsDOMNode() : nullptr,
+                               doc ? doc->NodePrincipal() : aPrincipal,
+                               aPrincipal,
+                               nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
+                               nsIContentPolicy::TYPE_WEBSOCKET);
+  MOZ_ASSERT(NS_SUCCEEDED(rv));
 
   if (!mRequestedProtocolList.IsEmpty()) {
     rv = wsChannel->SetProtocol(mRequestedProtocolList);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   nsCOMPtr<nsIThreadRetargetableRequest> rr = do_QueryInterface(wsChannel);
   NS_ENSURE_TRUE(rr, NS_ERROR_FAILURE);
--- a/dom/flyweb/FlyWebPublishedServer.cpp
+++ b/dom/flyweb/FlyWebPublishedServer.cpp
@@ -632,17 +632,18 @@ FlyWebPublishedServerParent::RecvWebSock
 
   ErrorResult result;
   nsCOMPtr<nsITransportProvider> providerServer =
     mPublishedServer->OnWebSocketAcceptInternal(request, protocol, result);
   if (result.Failed()) {
     return IPC_FAIL_NO_REASON(this);
   }
 
-  providerServer->SetListener(providerIPC);
+  DebugOnly<nsresult> rv = providerServer->SetListener(providerIPC);
+  MOZ_ASSERT(NS_SUCCEEDED(rv));
 
   return IPC_OK();
 }
 
 void
 FlyWebPublishedServerParent::ActorDestroy(ActorDestroyReason aWhy)
 {
   LOG_I("FlyWebPublishedServerParent::ActorDestroy(%p)", this);
--- a/netwerk/base/nsNetUtil.h
+++ b/netwerk/base/nsNetUtil.h
@@ -11,16 +11,17 @@
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsILoadGroup.h"
 #include "nsINetUtil.h"
 #include "nsIRequest.h"
 #include "nsILoadInfo.h"
 #include "nsIIOService.h"
 #include "mozilla/Services.h"
+#include "mozilla/Unused.h"
 #include "nsNetCID.h"
 #include "nsServiceManagerUtils.h"
 
 class nsIURI;
 class nsIPrincipal;
 class nsIAsyncStreamCopier;
 class nsIAuthPrompt;
 class nsIAuthPrompt2;
@@ -593,23 +594,23 @@ template <class T> inline void
 NS_QueryNotificationCallbacks(T            *channel,
                               const nsIID  &iid,
                               void        **result)
 {
     NS_PRECONDITION(channel, "null channel");
     *result = nullptr;
 
     nsCOMPtr<nsIInterfaceRequestor> cbs;
-    channel->GetNotificationCallbacks(getter_AddRefs(cbs));
+    mozilla::Unused << channel->GetNotificationCallbacks(getter_AddRefs(cbs));
     if (cbs)
         cbs->GetInterface(iid, result);
     if (!*result) {
         // try load group's notification callbacks...
         nsCOMPtr<nsILoadGroup> loadGroup;
-        channel->GetLoadGroup(getter_AddRefs(loadGroup));
+        mozilla::Unused << channel->GetLoadGroup(getter_AddRefs(loadGroup));
         if (loadGroup) {
             loadGroup->GetNotificationCallbacks(getter_AddRefs(cbs));
             if (cbs)
                 cbs->GetInterface(iid, result);
         }
     }
 }
 
--- a/netwerk/protocol/websocket/WebSocketChannel.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannel.cpp
@@ -590,22 +590,27 @@ public:
       mData(aData),
       mLen(aLen) {}
 
   NS_IMETHOD Run() override
   {
     MOZ_ASSERT(mChannel->IsOnTargetThread());
 
     if (mListenerMT) {
+      nsresult rv;
       if (mLen < 0) {
-        mListenerMT->mListener->OnMessageAvailable(mListenerMT->mContext,
-                                                   mData);
+        rv = mListenerMT->mListener->OnMessageAvailable(mListenerMT->mContext,
+                                                        mData);
       } else {
-        mListenerMT->mListener->OnBinaryMessageAvailable(mListenerMT->mContext,
-                                                         mData);
+        rv = mListenerMT->mListener->OnBinaryMessageAvailable(mListenerMT->mContext,
+                                                              mData);
+      }
+      if (NS_FAILED(rv)) {
+        LOG(("OnMessageAvailable or OnBinaryMessageAvailable "
+             "failed with 0x%08x", rv));
       }
     }
 
     return NS_OK;
   }
 
 private:
   ~CallOnMessageAvailable() {}
@@ -633,17 +638,21 @@ public:
       mReason(aReason)
   {}
 
   NS_IMETHOD Run() override
   {
     MOZ_ASSERT(mChannel->IsOnTargetThread());
 
     if (mListenerMT) {
-      mListenerMT->mListener->OnStop(mListenerMT->mContext, mReason);
+      nsresult rv = mListenerMT->mListener->OnStop(mListenerMT->mContext, mReason);
+      if (NS_FAILED(rv)) {
+        LOG(("WebSocketChannel::CallOnStop "
+             "OnStop failed (%08x)\n", rv));
+      }
       mChannel->mListenerMT = nullptr;
     }
 
     return NS_OK;
   }
 
 private:
   ~CallOnStop() {}
@@ -671,18 +680,23 @@ public:
       mCode(aCode),
       mReason(aReason) {}
 
   NS_IMETHOD Run() override
   {
     MOZ_ASSERT(mChannel->IsOnTargetThread());
 
     if (mListenerMT) {
-      mListenerMT->mListener->OnServerClose(mListenerMT->mContext, mCode,
-                                            mReason);
+      nsresult rv =
+        mListenerMT->mListener->OnServerClose(mListenerMT->mContext, mCode,
+                                              mReason);
+      if (NS_FAILED(rv)) {
+        LOG(("WebSocketChannel::CallOnServerClose "
+             "OnServerClose failed (%08x)\n", rv));
+      }
     }
     return NS_OK;
   }
 
 private:
   ~CallOnServerClose() {}
 
   RefPtr<WebSocketChannel> mChannel;
@@ -706,17 +720,20 @@ public:
       mSize(aSize) {}
 
   NS_IMETHOD Run() override
   {
     MOZ_ASSERT(mChannel->IsOnTargetThread());
 
     LOG(("WebSocketChannel::CallAcknowledge: Size %u\n", mSize));
     if (mListenerMT) {
-      mListenerMT->mListener->OnAcknowledge(mListenerMT->mContext, mSize);
+      nsresult rv = mListenerMT->mListener->OnAcknowledge(mListenerMT->mContext, mSize);
+      if (NS_FAILED(rv)) {
+        LOG(("WebSocketChannel::CallAcknowledge: Acknowledge failed (%08x)\n", rv));
+      }
     }
     return NS_OK;
   }
 
 private:
   ~CallAcknowledge() {}
 
   RefPtr<WebSocketChannel> mChannel;
@@ -1247,17 +1264,20 @@ WebSocketChannel::Observe(nsISupports *s
         LOG(("WebSocket: early object, no ping needed"));
       } else {
         // Next we check mDataStarted, which we need to do on mTargetThread.
         if (!IsOnTargetThread()) {
           mTargetThread->Dispatch(
             NewRunnableMethod(this, &WebSocketChannel::OnNetworkChanged),
             NS_DISPATCH_NORMAL);
         } else {
-          OnNetworkChanged();
+          nsresult rv = OnNetworkChanged();
+          if (NS_FAILED(rv)) {
+            LOG(("WebSocket: OnNetworkChanged failed (%08x)", rv));
+          }
         }
       }
     }
   }
 
   return NS_OK;
 }
 
@@ -2925,17 +2945,21 @@ WebSocketChannel::StartWebsocketData()
       return rv;
     }
   }
 
   LOG(("WebSocketChannel::StartWebsocketData Notifying Listener %p",
        mListenerMT ? mListenerMT->mListener.get() : nullptr));
 
   if (mListenerMT) {
-    mListenerMT->mListener->OnStart(mListenerMT->mContext);
+    rv = mListenerMT->mListener->OnStart(mListenerMT->mContext);
+    if (NS_FAILED(rv)) {
+      LOG(("WebSocketChannel::StartWebsocketData "
+           "mListenerMT->mListener->OnStart() failed with error 0x%08x", rv));
+    }
   }
 
   return NS_OK;
 }
 
 nsresult
 WebSocketChannel::StartPinging()
 {
@@ -3370,17 +3394,18 @@ WebSocketChannel::AsyncOpen(nsIURI *aURI
   mOriginalURI = aURI;
   mURI = mOriginalURI;
   mOrigin = aOrigin;
 
   if (mIsServerSide) {
     //IncrementSessionCount();
     mWasOpened = 1;
     mListenerMT = new ListenerAndContextContainer(aListener, aContext);
-    mServerTransportProvider->SetListener(this);
+    rv = mServerTransportProvider->SetListener(this);
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
     mServerTransportProvider = nullptr;
 
     return NS_OK;
   }
 
   mURI->GetHostPort(mHost);
 
   mRandomGenerator =
--- a/netwerk/protocol/websocket/WebSocketChannel.h
+++ b/netwerk/protocol/websocket/WebSocketChannel.h
@@ -47,17 +47,17 @@ class OutboundEnqueuer;
 class nsWSAdmissionManager;
 class PMCECompression;
 class CallOnMessageAvailable;
 class CallOnStop;
 class CallOnServerClose;
 class CallAcknowledge;
 class WebSocketEventService;
 
-extern nsresult
+extern MOZ_MUST_USE nsresult
 CalculateWebSocketHashedSecret(const nsACString& aKey, nsACString& aHash);
 extern void
 ProcessServerWebSocketExtensions(const nsACString& aExtensions,
                                  nsACString& aNegotiatedExtensions);
 
 // Used to enforce "1 connecting websocket per host" rule, and reconnect delays
 enum wsConnectingState {
   NOT_CONNECTING = 0,     // Not yet (or no longer) trying to open connection
@@ -137,55 +137,56 @@ private:
   friend class nsWSAdmissionManager;
   friend class FailDelayManager;
   friend class CallOnMessageAvailable;
   friend class CallOnStop;
   friend class CallOnServerClose;
   friend class CallAcknowledge;
 
   // Common send code for binary + text msgs
-  nsresult SendMsgCommon(const nsACString *aMsg, bool isBinary,
-                         uint32_t length, nsIInputStream *aStream = nullptr);
+  MOZ_MUST_USE nsresult SendMsgCommon(const nsACString *aMsg, bool isBinary,
+                                      uint32_t length,
+                                      nsIInputStream *aStream = nullptr);
 
   void EnqueueOutgoingMessage(nsDeque &aQueue, OutboundMessage *aMsg);
 
   void PrimeNewOutgoingMessage();
   void DeleteCurrentOutGoingMessage();
   void GeneratePong(uint8_t *payload, uint32_t len);
   void GeneratePing();
 
-  nsresult OnNetworkChanged();
-  nsresult StartPinging();
+  MOZ_MUST_USE nsresult OnNetworkChanged();
+  MOZ_MUST_USE nsresult StartPinging();
 
   void     BeginOpen(bool aCalledFromAdmissionManager);
   void     BeginOpenInternal();
-  nsresult HandleExtensions();
-  nsresult SetupRequest();
-  nsresult ApplyForAdmission();
-  nsresult DoAdmissionDNS();
-  nsresult StartWebsocketData();
+  MOZ_MUST_USE nsresult HandleExtensions();
+  MOZ_MUST_USE nsresult SetupRequest();
+  MOZ_MUST_USE nsresult ApplyForAdmission();
+  MOZ_MUST_USE nsresult DoAdmissionDNS();
+  MOZ_MUST_USE nsresult StartWebsocketData();
   uint16_t ResultToCloseCode(nsresult resultCode);
   void     ReportConnectionTelemetry();
 
   void StopSession(nsresult reason);
   void AbortSession(nsresult reason);
   void ReleaseSession();
   void CleanupConnection();
   void IncrementSessionCount();
   void DecrementSessionCount();
 
   void EnsureHdrOut(uint32_t size);
 
   static void ApplyMask(uint32_t mask, uint8_t *data, uint64_t len);
 
   bool     IsPersistentFramePtr();
-  nsresult ProcessInput(uint8_t *buffer, uint32_t count);
-  bool UpdateReadBuffer(uint8_t *buffer, uint32_t count,
-                        uint32_t accumulatedFragments,
-                        uint32_t *available);
+  MOZ_MUST_USE nsresult ProcessInput(uint8_t *buffer, uint32_t count);
+  MOZ_MUST_USE bool UpdateReadBuffer(uint8_t *buffer, uint32_t count,
+                                     uint32_t accumulatedFragments,
+                                     uint32_t *available);
 
   inline void ResetPingTimer()
   {
     mPingOutstanding = 0;
     if (mPingTimer) {
       if (!mPingInterval) {
         // The timer was created by forced ping and regular pinging is disabled,
         // so cancel and null out mPingTimer.
--- a/netwerk/protocol/websocket/WebSocketChannelChild.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannelChild.cpp
@@ -231,17 +231,21 @@ WebSocketChannelChild::OnStart(const nsC
   LOG(("WebSocketChannelChild::RecvOnStart() %p\n", this));
   SetProtocol(aProtocol);
   mNegotiatedExtensions = aExtensions;
   mEffectiveURL = aEffectiveURL;
   mEncrypted = aEncrypted;
 
   if (mListenerMT) {
     AutoEventEnqueuer ensureSerialDispatch(mEventQ);
-    mListenerMT->mListener->OnStart(mListenerMT->mContext);
+    nsresult rv = mListenerMT->mListener->OnStart(mListenerMT->mContext);
+    if (NS_FAILED(rv)) {
+      LOG(("WebSocketChannelChild::OnStart "
+           "mListenerMT->mListener->OnStart() failed with error 0x%08x", rv));
+    }
   }
 }
 
 class StopEvent : public ChannelEvent
 {
  public:
   StopEvent(WebSocketChannelChild* aChild,
             const nsresult& aStatusCode)
@@ -269,17 +273,22 @@ WebSocketChannelChild::RecvOnStop(const 
 }
 
 void
 WebSocketChannelChild::OnStop(const nsresult& aStatusCode)
 {
   LOG(("WebSocketChannelChild::RecvOnStop() %p\n", this));
   if (mListenerMT) {
     AutoEventEnqueuer ensureSerialDispatch(mEventQ);
-    mListenerMT->mListener->OnStop(mListenerMT->mContext, aStatusCode);
+    nsresult rv =
+      mListenerMT->mListener->OnStop(mListenerMT->mContext, aStatusCode);
+    if (NS_FAILED(rv)) {
+      LOG(("WebSocketChannel::OnStop "
+           "mListenerMT->mListener->OnStop() failed with error 0x%08x", rv));
+    }
   }
 }
 
 class MessageEvent : public ChannelEvent
 {
  public:
   MessageEvent(WebSocketChannelChild* aChild,
                const nsCString& aMessage,
@@ -314,17 +323,23 @@ WebSocketChannelChild::RecvOnMessageAvai
 }
 
 void
 WebSocketChannelChild::OnMessageAvailable(const nsCString& aMsg)
 {
   LOG(("WebSocketChannelChild::RecvOnMessageAvailable() %p\n", this));
   if (mListenerMT) {
     AutoEventEnqueuer ensureSerialDispatch(mEventQ);
-    mListenerMT->mListener->OnMessageAvailable(mListenerMT->mContext, aMsg);
+    nsresult rv =
+      mListenerMT->mListener->OnMessageAvailable(mListenerMT->mContext, aMsg);
+    if (NS_FAILED(rv)) {
+      LOG(("WebSocketChannelChild::OnMessageAvailable "
+           "mListenerMT->mListener->OnMessageAvailable() "
+           "failed with error 0x%08x", rv));
+    }
   }
 }
 
 mozilla::ipc::IPCResult
 WebSocketChannelChild::RecvOnBinaryMessageAvailable(const nsCString& aMsg)
 {
   mEventQ->RunOrEnqueue(
     new EventTargetDispatcher(new MessageEvent(this, aMsg, true),
@@ -334,18 +349,24 @@ WebSocketChannelChild::RecvOnBinaryMessa
 }
 
 void
 WebSocketChannelChild::OnBinaryMessageAvailable(const nsCString& aMsg)
 {
   LOG(("WebSocketChannelChild::RecvOnBinaryMessageAvailable() %p\n", this));
   if (mListenerMT) {
     AutoEventEnqueuer ensureSerialDispatch(mEventQ);
-    mListenerMT->mListener->OnBinaryMessageAvailable(mListenerMT->mContext,
-                                                     aMsg);
+    nsresult rv =
+      mListenerMT->mListener->OnBinaryMessageAvailable(mListenerMT->mContext,
+                                                       aMsg);
+    if (NS_FAILED(rv)) {
+      LOG(("WebSocketChannelChild::OnBinaryMessageAvailable "
+           "mListenerMT->mListener->OnBinaryMessageAvailable() "
+           "failed with error 0x%08x", rv));
+    }
   }
 }
 
 class AcknowledgeEvent : public ChannelEvent
 {
  public:
   AcknowledgeEvent(WebSocketChannelChild* aChild,
                    const uint32_t& aSize)
@@ -373,17 +394,23 @@ WebSocketChannelChild::RecvOnAcknowledge
 }
 
 void
 WebSocketChannelChild::OnAcknowledge(const uint32_t& aSize)
 {
   LOG(("WebSocketChannelChild::RecvOnAcknowledge() %p\n", this));
   if (mListenerMT) {
     AutoEventEnqueuer ensureSerialDispatch(mEventQ);
-    mListenerMT->mListener->OnAcknowledge(mListenerMT->mContext, aSize);
+    nsresult rv =
+      mListenerMT->mListener->OnAcknowledge(mListenerMT->mContext, aSize);
+    if (NS_FAILED(rv)) {
+      LOG(("WebSocketChannel::OnAcknowledge "
+           "mListenerMT->mListener->OnAcknowledge() "
+           "failed with error 0x%08x", rv));
+    }
   }
 }
 
 class ServerCloseEvent : public ChannelEvent
 {
  public:
   ServerCloseEvent(WebSocketChannelChild* aChild,
                    const uint16_t aCode,
@@ -416,18 +443,20 @@ WebSocketChannelChild::RecvOnServerClose
 
 void
 WebSocketChannelChild::OnServerClose(const uint16_t& aCode,
                                      const nsCString& aReason)
 {
   LOG(("WebSocketChannelChild::RecvOnServerClose() %p\n", this));
   if (mListenerMT) {
     AutoEventEnqueuer ensureSerialDispatch(mEventQ);
-    mListenerMT->mListener->OnServerClose(mListenerMT->mContext, aCode,
-                                          aReason);
+    DebugOnly<nsresult> rv =
+      mListenerMT->mListener->OnServerClose(mListenerMT->mContext, aCode,
+                                            aReason);
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
   }
 }
 
 NS_IMETHODIMP
 WebSocketChannelChild::AsyncOpen(nsIURI *aURI,
                                  const nsACString &aOrigin,
                                  uint64_t aInnerWindowID,
                                  nsIWebSocketListener *aListener,
@@ -636,17 +665,21 @@ public:
     , mLength(aLength)
   {
     MOZ_RELEASE_ASSERT(!NS_IsMainThread());
     MOZ_ASSERT(aChild);
   }
   NS_IMETHOD Run() override
   {
     MOZ_ASSERT(NS_IsMainThread());
-    mChild->SendBinaryStream(mStream, mLength);
+    nsresult rv = mChild->SendBinaryStream(mStream, mLength);
+    if (NS_FAILED(rv)) {
+      LOG(("WebSocketChannelChild::BinaryStreamEvent %p "
+           "SendBinaryStream failed (%08x)\n", this, rv));
+    }
     return NS_OK;
   }
 private:
   RefPtr<WebSocketChannelChild>      mChild;
   nsAutoPtr<OptionalInputStreamParams> mStream;
   uint32_t                             mLength;
 };
 
--- a/netwerk/protocol/websocket/WebSocketChannelChild.h
+++ b/netwerk/protocol/websocket/WebSocketChannelChild.h
@@ -31,17 +31,17 @@ class WebSocketChannelChild final : publ
   NS_IMETHOD AsyncOpen(nsIURI *aURI, const nsACString &aOrigin,
                        uint64_t aInnerWindowID,
                        nsIWebSocketListener *aListener,
                        nsISupports *aContext) override;
   NS_IMETHOD Close(uint16_t code, const nsACString & reason) override;
   NS_IMETHOD SendMsg(const nsACString &aMsg) override;
   NS_IMETHOD SendBinaryMsg(const nsACString &aMsg) override;
   NS_IMETHOD SendBinaryStream(nsIInputStream *aStream, uint32_t aLength) override;
-  nsresult SendBinaryStream(OptionalInputStreamParams *aStream, uint32_t aLength);
+  MOZ_MUST_USE nsresult SendBinaryStream(OptionalInputStreamParams *aStream, uint32_t aLength);
   NS_IMETHOD GetSecurityInfo(nsISupports **aSecurityInfo) override;
 
   void AddIPDLReference();
   void ReleaseIPDLReference();
 
   // Off main thread URI access.
   void GetEffectiveURL(nsAString& aEffectiveURL) const override;
   bool IsEncrypted() const override;
--- a/netwerk/protocol/websocket/WebSocketChannelParent.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannelParent.cpp
@@ -124,21 +124,23 @@ WebSocketChannelParent::RecvAsyncOpen(co
       goto fail;
     }
   }
 
   // only use ping values from child if they were overridden by client code.
   if (aClientSetPingInterval) {
     // IDL allows setting in seconds, so must be multiple of 1000 ms
     MOZ_ASSERT(aPingInterval >= 1000 && !(aPingInterval % 1000));
-    mChannel->SetPingInterval(aPingInterval / 1000);
+    DebugOnly<nsresult> rv = mChannel->SetPingInterval(aPingInterval / 1000);
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
   }
   if (aClientSetPingTimeout) {
     MOZ_ASSERT(aPingTimeout >= 1000 && !(aPingTimeout % 1000));
-    mChannel->SetPingTimeout(aPingTimeout / 1000);
+    DebugOnly<nsresult> rv = mChannel->SetPingTimeout(aPingTimeout / 1000);
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
   }
 
   rv = mChannel->AsyncOpen(uri, aOrigin, aInnerWindowID, this, nullptr);
   if (NS_FAILED(rv))
     goto fail;
 
   return IPC_OK();
 
@@ -208,18 +210,20 @@ WebSocketChannelParent::RecvSendBinarySt
 NS_IMETHODIMP
 WebSocketChannelParent::OnStart(nsISupports *aContext)
 {
   LOG(("WebSocketChannelParent::OnStart() %p\n", this));
   nsAutoCString protocol, extensions;
   nsString effectiveURL;
   bool encrypted = false;
   if (mChannel) {
-    mChannel->GetProtocol(protocol);
-    mChannel->GetExtensions(extensions);
+    DebugOnly<nsresult> rv = mChannel->GetProtocol(protocol);
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
+    rv = mChannel->GetExtensions(extensions);
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
 
     RefPtr<WebSocketChannel> channel;
     channel = static_cast<WebSocketChannel*>(mChannel.get());
     MOZ_ASSERT(channel);
 
     channel->GetEffectiveURL(effectiveURL);
     encrypted = channel->IsEncrypted();
   }
--- a/netwerk/protocol/websocket/WebSocketEventListenerParent.cpp
+++ b/netwerk/protocol/websocket/WebSocketEventListenerParent.cpp
@@ -18,17 +18,18 @@ NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(WebSocketEventListenerParent)
 NS_IMPL_RELEASE(WebSocketEventListenerParent)
 
 WebSocketEventListenerParent::WebSocketEventListenerParent(uint64_t aInnerWindowID)
   : mService(WebSocketEventService::GetOrCreate())
   , mInnerWindowID(aInnerWindowID)
 {
-  mService->AddListener(mInnerWindowID, this);
+  DebugOnly<nsresult> rv = mService->AddListener(mInnerWindowID, this);
+  MOZ_ASSERT(NS_SUCCEEDED(rv));
 }
 
 WebSocketEventListenerParent::~WebSocketEventListenerParent()
 {
   MOZ_ASSERT(!mService);
 }
 
 mozilla::ipc::IPCResult
@@ -47,17 +48,18 @@ WebSocketEventListenerParent::ActorDestr
 {
   UnregisterListener();
 }
 
 void
 WebSocketEventListenerParent::UnregisterListener()
 {
   if (mService) {
-    mService->RemoveListener(mInnerWindowID, this);
+    DebugOnly<nsresult> rv = mService->RemoveListener(mInnerWindowID, this);
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
     mService = nullptr;
   }
 }
 
 NS_IMETHODIMP
 WebSocketEventListenerParent::WebSocketCreated(uint32_t aWebSocketSerialID,
                                                const nsAString& aURI,
                                                const nsACString& aProtocols)
--- a/netwerk/protocol/websocket/nsITransportProvider.idl
+++ b/netwerk/protocol/websocket/nsITransportProvider.idl
@@ -22,15 +22,15 @@ class PTransportProviderChild;
  * An interface which can be used to asynchronously request a nsITransport
  * together with the input and output streams that go together with it.
  */
 [scriptable, uuid(6fcec704-cfd2-46ef-a394-a64d5cb1475c)]
 interface nsITransportProvider : nsISupports
 {
     // This must not be called in a child process since transport
     // objects are not accessible there. Call getIPCChild instead.
-    void setListener(in nsIHttpUpgradeListener listener);
+    [must_use] void setListener(in nsIHttpUpgradeListener listener);
 
     // This must be implemented by nsITransportProvider objects running
     // in the child process. It must return null when called in the parent
     // process.
-    [noscript] PTransportProviderChild getIPCChild();
+    [noscript, must_use] PTransportProviderChild getIPCChild();
 };
--- a/netwerk/protocol/websocket/nsIWebSocketChannel.idl
+++ b/netwerk/protocol/websocket/nsIWebSocketChannel.idl
@@ -27,53 +27,53 @@ interface nsITransportProvider;
 interface nsIWebSocketChannel : nsISupports
 {
     /**
      * The original URI used to construct the protocol connection. This is used
      * in the case of a redirect or URI "resolution" (e.g. resolving a
      * resource: URI to a file: URI) so that the original pre-redirect
      * URI can still be obtained.  This is never null.
      */
-    readonly attribute nsIURI originalURI;
+    [must_use] readonly attribute nsIURI originalURI;
 
     /**
      * The readonly URI corresponding to the protocol connection after any
      * redirections are completed.
      */
-    readonly attribute nsIURI URI;
+    [must_use] readonly attribute nsIURI URI;
 
     /**
      * The notification callbacks for authorization, etc..
      */
-    attribute nsIInterfaceRequestor notificationCallbacks;
+    [must_use] attribute nsIInterfaceRequestor notificationCallbacks;
 
     /**
      * Transport-level security information (if any)
      */
-    readonly attribute nsISupports securityInfo;
+    [must_use] readonly attribute nsISupports securityInfo;
 
     /**
      * The load group of of the websocket
      */
-    attribute nsILoadGroup loadGroup;
+    [must_use] attribute nsILoadGroup loadGroup;
 
     /**
      * The load info of the websocket
      */
-    attribute nsILoadInfo loadInfo;
+    [must_use] attribute nsILoadInfo loadInfo;
 
     /**
      * Sec-Websocket-Protocol value
      */
-    attribute ACString protocol;
+    [must_use] attribute ACString protocol;
 
     /**
      * Sec-Websocket-Extensions response header value
      */
-    readonly attribute ACString extensions;
+    [must_use] readonly attribute ACString extensions;
 
     /**
      * Init the WebSocketChannel with LoadInfo arguments.
      * @param aLoadingNode
      * @param aLoadingPrincipal
      * @param aTriggeringPrincipal
      * @param aSecurityFlags
      * @param aContentPolicyType
@@ -83,21 +83,21 @@ interface nsIWebSocketChannel : nsISuppo
      *
      * Keep in mind that URIs coming from a webpage should *never* use the
      * systemPrincipal as the loadingPrincipal.
      *
      * Please note, if you provide both a loadingNode and a loadingPrincipal,
      * then loadingPrincipal must be equal to loadingNode->NodePrincipal().
      * But less error prone is to just supply a loadingNode.
      */
-     void initLoadInfo(in nsIDOMNode aLoadingNode,
-                       in nsIPrincipal aLoadingPrincipal,
-                       in nsIPrincipal aTriggeringPrincipal,
-                       in unsigned long aSecurityFlags,
-                       in unsigned long aContentPolicyType);
+     [must_use] void initLoadInfo(in nsIDOMNode aLoadingNode,
+                                  in nsIPrincipal aLoadingPrincipal,
+                                  in nsIPrincipal aTriggeringPrincipal,
+                                  in unsigned long aSecurityFlags,
+                                  in unsigned long aContentPolicyType);
 
     /**
      * Asynchronously open the websocket connection.  Received messages are fed
      * to the socket listener as they arrive.  The socket listener's methods
      * are called on the thread that calls asyncOpen and are not called until
      * after asyncOpen returns.  If asyncOpen returns successfully, the
      * protocol implementation promises to call at least onStop on the listener.
      *
@@ -105,32 +105,32 @@ interface nsIWebSocketChannel : nsISuppo
      * websocket connection is reopened.
      *
      * @param aURI the uri of the websocket protocol - may be redirected
      * @param aOrigin the uri of the originating resource
      * @param aInnerWindowID the inner window ID
      * @param aListener the nsIWebSocketListener implementation
      * @param aContext an opaque parameter forwarded to aListener's methods
      */
-    void asyncOpen(in nsIURI aURI,
-                   in ACString aOrigin,
-                   in unsigned long long aInnerWindowID,
-                   in nsIWebSocketListener aListener,
-                   in nsISupports aContext);
+    [must_use] void asyncOpen(in nsIURI aURI,
+                              in ACString aOrigin,
+                              in unsigned long long aInnerWindowID,
+                              in nsIWebSocketListener aListener,
+                              in nsISupports aContext);
 
     /*
      * Close the websocket connection for writing - no more calls to sendMsg
      * or sendBinaryMsg should be made after calling this. The listener object
      * may receive more messages if a server close has not yet been received.
      *
      * @param aCode the websocket closing handshake close code. Set to 0 if
      *        you are not providing a code.
      * @param aReason the websocket closing handshake close reason
      */
-    void close(in unsigned short aCode, in AUTF8String aReason);
+    [must_use] void close(in unsigned short aCode, in AUTF8String aReason);
     
     // section 7.4.1 defines these close codes
     const unsigned short CLOSE_NORMAL               = 1000;
     const unsigned short CLOSE_GOING_AWAY           = 1001;
     const unsigned short CLOSE_PROTOCOL_ERROR       = 1002;
     const unsigned short CLOSE_UNSUPPORTED_DATATYPE = 1003;
     //  code 1004 is reserved
     const unsigned short CLOSE_NO_STATUS            = 1005;
@@ -147,69 +147,69 @@ interface nsIWebSocketChannel : nsISuppo
     // To be used if TLS handshake failed (ex: server certificate unverifiable)
     const unsigned short CLOSE_TLS_FAILED           = 1015;
 
     /**
      * Use to send text message down the connection to WebSocket peer.
      *
      * @param aMsg the utf8 string to send
      */
-    void sendMsg(in AUTF8String aMsg);
+    [must_use] void sendMsg(in AUTF8String aMsg);
 
     /**
      * Use to send binary message down the connection to WebSocket peer.
      *
      * @param aMsg the data to send
      */
-    void sendBinaryMsg(in ACString aMsg);
+    [must_use] void sendBinaryMsg(in ACString aMsg);
 
     /** 
      * Use to send a binary stream (Blob) to Websocket peer.
      *
      * @param aStream The input stream to be sent.  
      */
-    void sendBinaryStream(in nsIInputStream aStream, 
-                          in unsigned long length);
+    [must_use] void sendBinaryStream(in nsIInputStream aStream, 
+                                     in unsigned long length);
 
     /**
      * This value determines how often (in seconds) websocket keepalive
      * pings are sent.  If set to 0 (the default), no pings are ever sent.
      *
      * This value can currently only be set before asyncOpen is called, else 
      * NS_ERROR_IN_PROGRESS is thrown.
      *
      * Be careful using this setting: ping traffic can consume lots of power and
      * bandwidth over time.
      */
-    attribute unsigned long pingInterval;
+    [must_use] attribute unsigned long pingInterval;
 
     /**
      * This value determines how long (in seconds) the websocket waits for
      * the server to reply to a ping that has been sent before considering the
      * connection broken.
      *
      * This value can currently only be set before asyncOpen is called, else 
      * NS_ERROR_IN_PROGRESS is thrown.
      */
-    attribute unsigned long pingTimeout;
+    [must_use] attribute unsigned long pingTimeout;
 
     /**
      * Unique ID for this channel. It's not readonly because when the channel is
      * created via IPC, the serial number is received from the child process.
      */
-    attribute unsigned long serial;
+    [must_use] attribute unsigned long serial;
 
     /**
      * Set a nsITransportProvider and negotated extensions to be used by this
      * channel. Calling this function also means that this channel will
      * implement the server-side part of a websocket connection rather than the
      * client-side part.
      */
-    void setServerParameters(in nsITransportProvider aProvider,
-                             in ACString aNegotiatedExtensions);
+    [must_use] void setServerParameters(in nsITransportProvider aProvider,
+                                        in ACString aNegotiatedExtensions);
 
 %{C++
     inline uint32_t Serial()
     {
       uint32_t serial;
       nsresult rv = GetSerial(&serial);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return 0;
--- a/netwerk/protocol/websocket/nsIWebSocketEventService.idl
+++ b/netwerk/protocol/websocket/nsIWebSocketEventService.idl
@@ -4,76 +4,76 @@
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "domstubs.idl"
 #include "nsISupports.idl"
 
 [scriptable, builtinclass, uuid(6714a6be-2265-4f73-a988-d78a12416037)]
 interface nsIWebSocketFrame : nsISupports
 {
-  readonly attribute DOMHighResTimeStamp timeStamp;
+  [must_use] readonly attribute DOMHighResTimeStamp timeStamp;
 
-  readonly attribute boolean finBit;
+  [must_use] readonly attribute boolean finBit;
 
-  readonly attribute boolean rsvBit1;
-  readonly attribute boolean rsvBit2;
-  readonly attribute boolean rsvBit3;
+  [must_use] readonly attribute boolean rsvBit1;
+  [must_use] readonly attribute boolean rsvBit2;
+  [must_use] readonly attribute boolean rsvBit3;
 
-  readonly attribute unsigned short opCode;
+  [must_use] readonly attribute unsigned short opCode;
 
-  readonly attribute boolean maskBit;
+  [must_use] readonly attribute boolean maskBit;
 
-  readonly attribute unsigned long mask;
+  [must_use] readonly attribute unsigned long mask;
 
-  readonly attribute ACString payload;
+  [must_use] readonly attribute ACString payload;
 
   // Non-Control opCode values:
   const unsigned short OPCODE_CONTINUATION = 0x0;
   const unsigned short OPCODE_TEXT         = 0x1;
   const unsigned short OPCODE_BINARY       = 0x2;
 
   // Control opCode values:
   const unsigned short OPCODE_CLOSE        = 0x8;
   const unsigned short OPCODE_PING         = 0x9;
   const unsigned short OPCODE_PONG         = 0xA;
 };
 
 [scriptable, uuid(e7c005ab-e694-489b-b741-96db43ffb16f)]
 interface nsIWebSocketEventListener : nsISupports
 {
-  void webSocketCreated(in unsigned long aWebSocketSerialID,
-                        in AString aURI,
-                        in ACString aProtocols);
+  [must_use] void webSocketCreated(in unsigned long aWebSocketSerialID,
+                                   in AString aURI,
+                                   in ACString aProtocols);
 
-  void webSocketOpened(in unsigned long aWebSocketSerialID,
-                       in AString aEffectiveURI,
-                       in ACString aProtocols,
-                       in ACString aExtensions);
+  [must_use] void webSocketOpened(in unsigned long aWebSocketSerialID,
+                                  in AString aEffectiveURI,
+                                  in ACString aProtocols,
+                                  in ACString aExtensions);
 
   const unsigned short TYPE_STRING      = 0x0;
   const unsigned short TYPE_BLOB        = 0x1;
   const unsigned short TYPE_ARRAYBUFFER = 0x2;
 
-  void webSocketMessageAvailable(in unsigned long aWebSocketSerialID,
-                                 in ACString aMessage,
-                                 in unsigned short aType);
+  [must_use] void webSocketMessageAvailable(in unsigned long aWebSocketSerialID,
+                                            in ACString aMessage,
+                                            in unsigned short aType);
 
-  void webSocketClosed(in unsigned long aWebSocketSerialID,
-                       in boolean aWasClean,
-                       in unsigned short aCode,
-                       in AString aReason);
+  [must_use] void webSocketClosed(in unsigned long aWebSocketSerialID,
+                                  in boolean aWasClean,
+                                  in unsigned short aCode,
+                                  in AString aReason);
 
-  void frameReceived(in unsigned long aWebSocketSerialID,
-                     in nsIWebSocketFrame aFrame);
+  [must_use] void frameReceived(in unsigned long aWebSocketSerialID,
+                                in nsIWebSocketFrame aFrame);
 
-  void frameSent(in unsigned long aWebSocketSerialID,
-                 in nsIWebSocketFrame aFrame);
+  [must_use] void frameSent(in unsigned long aWebSocketSerialID,
+                            in nsIWebSocketFrame aFrame);
 };
 
 [scriptable, builtinclass, uuid(b89d1b90-2cf3-4d8f-ac21-5aedfb25c760)]
 interface nsIWebSocketEventService : nsISupports
 {
-  void addListener(in unsigned long long aInnerWindowID,
-                   in nsIWebSocketEventListener aListener);
+  [must_use] void addListener(in unsigned long long aInnerWindowID,
+                              in nsIWebSocketEventListener aListener);
 
-  void removeListener(in unsigned long long aInnerWindowID,
-                      in nsIWebSocketEventListener aListener);
+  [must_use] void removeListener(in unsigned long long aInnerWindowID,
+                                 in nsIWebSocketEventListener aListener);
 };
--- a/netwerk/protocol/websocket/nsIWebSocketListener.idl
+++ b/netwerk/protocol/websocket/nsIWebSocketListener.idl
@@ -19,72 +19,72 @@ interface nsIWebSocketListener : nsISupp
      * Unlike most other networking channels (which use nsIRequestObserver
      * instead of this class), we do not guarantee that OnStart is always
      * called: OnStop is called without calling this function if errors occur
      * during connection setup.  If the websocket connection is successful,
      * OnStart will be called before any other calls to this API.
      *
      * @param aContext user defined context
      */
-    void onStart(in nsISupports aContext);
+    [must_use] void onStart(in nsISupports aContext);
 
     /**
      * Called to signify the completion of the message stream.
      * OnStop is the final notification the listener will receive and it
      * completes the WebSocket connection: after it returns the
      * nsIWebSocketChannel will release its reference to the listener.
      * 
      * Note: this event can be received in error cases even if
      * nsIWebSocketChannel::Close() has not been called.
      *
      * @param aContext user defined context
      * @param aStatusCode reason for stopping (NS_OK if completed successfully)
      */
-    void onStop(in nsISupports aContext,
-                in nsresult aStatusCode);
+    [must_use] void onStop(in nsISupports aContext,
+                           in nsresult aStatusCode);
 
     /**
      * Called to deliver text message.
      *
      * @param aContext user defined context
      * @param aMsg the message data
      */
-    void onMessageAvailable(in nsISupports aContext,
-                            in AUTF8String aMsg);
+    [must_use] void onMessageAvailable(in nsISupports aContext,
+                                       in AUTF8String aMsg);
 
     /**
      * Called to deliver binary message.
      *
      * @param aContext user defined context
      * @param aMsg the message data
      */
-    void onBinaryMessageAvailable(in nsISupports aContext,
-                                  in ACString aMsg);
+    [must_use] void onBinaryMessageAvailable(in nsISupports aContext,
+                                             in ACString aMsg);
 
     /**
      * Called to acknowledge message sent via sendMsg() or sendBinaryMsg.
      *
      * @param aContext user defined context
      * @param aSize number of bytes placed in OS send buffer
      */
-    void onAcknowledge(in nsISupports aContext, in uint32_t aSize);
+    [must_use] void onAcknowledge(in nsISupports aContext, in uint32_t aSize);
 
     /**
      * Called to inform receipt of WebSocket Close message from server.
      * In the case of errors onStop() can be called without ever
      * receiving server close.
      *
      * No additional messages through onMessageAvailable(),
      * onBinaryMessageAvailable() or onAcknowledge() will be delievered
      * to the listener after onServerClose(), though outgoing messages can still
      * be sent through the nsIWebSocketChannel connection.
      *
      * @param aContext user defined context
      * @param aCode the websocket closing handshake close code.
      * @param aReason the websocket closing handshake close reason
-
      */
-    void onServerClose(in nsISupports aContext, in unsigned short aCode,
-                       in AUTF8String aReason);
+    [must_use] void onServerClose(in nsISupports aContext,
+                                  in unsigned short aCode,
+                                  in AUTF8String aReason);
     
 };