Bug 1572872 - Return NS_ERROR_NOT_INITIALIZED if the message manager isn't initialized. r=smaug
authorAndrew McCreight <continuation@gmail.com>
Fri, 09 Aug 2019 22:35:54 +0000
changeset 487286 1815f6ac0dd2f1b60d17b2a3fe585dcd6db972e6
parent 487285 5c71a046fcda8ab0676edb99933c3e30ebc80285
child 487287 0d8abfb9664d000b6cf76a032b9b70c60a74fd87
push id92218
push useramccreight@mozilla.com
push dateSat, 10 Aug 2019 17:36:00 +0000
treeherderautoland@1815f6ac0dd2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1572872
milestone70.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 1572872 - Return NS_ERROR_NOT_INITIALIZED if the message manager isn't initialized. r=smaug If the mMessageManager field is null, then various message manager functions return NS_ERROR_NULL_POINTER, which gets printed out as NS_ERROR_ILLEGAL_VALUE, which is confusing. NS_ERROR_NOT_INITIALIZED will better indicate the problem is that that the message manager itself isn't set up correctly, rather than that the arguments are invalid. Differential Revision: https://phabricator.services.mozilla.com/D41456
dom/base/ContentProcessMessageManager.h
dom/base/MessageManagerGlobal.h
--- a/dom/base/ContentProcessMessageManager.h
+++ b/dom/base/ContentProcessMessageManager.h
@@ -67,17 +67,17 @@ class ContentProcessMessageManager : pub
   using MessageManagerGlobal::RemoveMessageListener;
   using MessageManagerGlobal::RemoveWeakMessageListener;
 
   // ContentProcessMessageManager
   void GetInitialProcessData(JSContext* aCx,
                              JS::MutableHandle<JS::Value> aInitialProcessData,
                              ErrorResult& aError) {
     if (!mMessageManager) {
-      aError.Throw(NS_ERROR_NULL_POINTER);
+      aError.Throw(NS_ERROR_NOT_INITIALIZED);
       return;
     }
     mMessageManager->GetInitialProcessData(aCx, aInitialProcessData, aError);
   }
 
   already_AddRefed<ipc::SharedMap> SharedData();
 
   NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
--- a/dom/base/MessageManagerGlobal.h
+++ b/dom/base/MessageManagerGlobal.h
@@ -18,96 +18,96 @@ namespace dom {
  */
 class MessageManagerGlobal {
  public:
   // MessageListenerManager
   void AddMessageListener(const nsAString& aMessageName,
                           MessageListener& aListener, bool aListenWhenClosed,
                           ErrorResult& aError) {
     if (!mMessageManager) {
-      aError.Throw(NS_ERROR_NULL_POINTER);
+      aError.Throw(NS_ERROR_NOT_INITIALIZED);
       return;
     }
     mMessageManager->AddMessageListener(aMessageName, aListener,
                                         aListenWhenClosed, aError);
   }
   void RemoveMessageListener(const nsAString& aMessageName,
                              MessageListener& aListener, ErrorResult& aError) {
     if (!mMessageManager) {
-      aError.Throw(NS_ERROR_NULL_POINTER);
+      aError.Throw(NS_ERROR_NOT_INITIALIZED);
       return;
     }
     mMessageManager->RemoveMessageListener(aMessageName, aListener, aError);
   }
   void AddWeakMessageListener(const nsAString& aMessageName,
                               MessageListener& aListener, ErrorResult& aError) {
     if (!mMessageManager) {
-      aError.Throw(NS_ERROR_NULL_POINTER);
+      aError.Throw(NS_ERROR_NOT_INITIALIZED);
       return;
     }
     mMessageManager->AddWeakMessageListener(aMessageName, aListener, aError);
   }
   void RemoveWeakMessageListener(const nsAString& aMessageName,
                                  MessageListener& aListener,
                                  ErrorResult& aError) {
     if (!mMessageManager) {
-      aError.Throw(NS_ERROR_NULL_POINTER);
+      aError.Throw(NS_ERROR_NOT_INITIALIZED);
       return;
     }
     mMessageManager->RemoveWeakMessageListener(aMessageName, aListener, aError);
   }
 
   // MessageSender
   void SendAsyncMessage(JSContext* aCx, const nsAString& aMessageName,
                         JS::Handle<JS::Value> aObj,
                         JS::Handle<JSObject*> aObjects,
                         nsIPrincipal* aPrincipal,
                         JS::Handle<JS::Value> aTransfers, ErrorResult& aError) {
     if (!mMessageManager) {
-      aError.Throw(NS_ERROR_NULL_POINTER);
+      aError.Throw(NS_ERROR_NOT_INITIALIZED);
       return;
     }
     mMessageManager->SendAsyncMessage(aCx, aMessageName, aObj, aObjects,
                                       aPrincipal, aTransfers, aError);
   }
   already_AddRefed<ProcessMessageManager> GetProcessMessageManager(
       mozilla::ErrorResult& aError) {
     if (!mMessageManager) {
-      aError.Throw(NS_ERROR_NULL_POINTER);
+      aError.Throw(NS_ERROR_NOT_INITIALIZED);
       return nullptr;
     }
     return mMessageManager->GetProcessMessageManager(aError);
   }
 
   void GetRemoteType(nsAString& aRemoteType, mozilla::ErrorResult& aError) {
     if (!mMessageManager) {
-      aError.Throw(NS_ERROR_NULL_POINTER);
+      aError.Throw(NS_ERROR_NOT_INITIALIZED);
       return;
     }
     mMessageManager->GetRemoteType(aRemoteType, aError);
   }
 
   // SyncMessageSender
   void SendSyncMessage(JSContext* aCx, const nsAString& aMessageName,
                        JS::Handle<JS::Value> aObj,
                        JS::Handle<JSObject*> aObjects, nsIPrincipal* aPrincipal,
                        nsTArray<JS::Value>& aResult, ErrorResult& aError) {
     if (!mMessageManager) {
-      aError.Throw(NS_ERROR_NULL_POINTER);
+      aError.Throw(NS_ERROR_NOT_INITIALIZED);
       return;
     }
     mMessageManager->SendSyncMessage(aCx, aMessageName, aObj, aObjects,
                                      aPrincipal, aResult, aError);
   }
   void SendRpcMessage(JSContext* aCx, const nsAString& aMessageName,
                       JS::Handle<JS::Value> aObj,
                       JS::Handle<JSObject*> aObjects, nsIPrincipal* aPrincipal,
                       nsTArray<JS::Value>& aResult, ErrorResult& aError) {
     if (!mMessageManager) {
-      aError.Throw(NS_ERROR_NULL_POINTER);
+      aError.Throw(NS_ERROR_NOT_INITIALIZED);
       return;
     }
     mMessageManager->SendRpcMessage(aCx, aMessageName, aObj, aObjects,
                                     aPrincipal, aResult, aError);
   }
 
   // MessageManagerGlobal
   void Dump(const nsAString& aStr);