Bug 1323946 - Use MOZ_MUST_USE for netwerk/protocol/res r=valentin
authorWei-Cheng Pan <wpan@mozilla.com>
Fri, 04 Nov 2016 18:13:13 +0800
changeset 327001 c28b3afaa5cd081a073ff2ae933548f9350ed862
parent 327000 6d89952994fb85d75b3766d19ce6428455e96b5c
child 327002 0a552cd5a5a3063acf1c13d0a71f49fcd5d06807
push id85073
push usercbook@mozilla.com
push dateThu, 22 Dec 2016 15:25:55 +0000
treeherdermozilla-inbound@5bc831655dec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1323946
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 1323946 - Use MOZ_MUST_USE for netwerk/protocol/res r=valentin MozReview-Commit-ID: 7tcOml6jKdj
chrome/nsChromeRegistryChrome.cpp
layout/style/nsLayoutStylesheetCache.cpp
netwerk/protocol/res/ExtensionProtocolHandler.h
netwerk/protocol/res/SubstitutingProtocolHandler.h
netwerk/protocol/res/nsISubstitutingProtocolHandler.idl
netwerk/protocol/res/nsResProtocolHandler.h
--- a/chrome/nsChromeRegistryChrome.cpp
+++ b/chrome/nsChromeRegistryChrome.cpp
@@ -982,10 +982,15 @@ nsChromeRegistryChrome::ManifestResource
 
   if (!CanLoadResource(resolved)) {
     LogMessageWithContext(cx.GetManifestURI(), lineno, nsIScriptError::warningFlag,
                           "Warning: cannot register non-local URI '%s' as a resource.",
                           uri);
     return;
   }
 
-  rph->SetSubstitution(host, resolved);
+  rv = rph->SetSubstitution(host, resolved);
+  if (NS_FAILED(rv)) {
+    LogMessageWithContext(cx.GetManifestURI(), lineno, nsIScriptError::warningFlag,
+                          "Warning: cannot set substitution for '%s'.",
+                          uri);
+  }
 }
--- a/layout/style/nsLayoutStylesheetCache.cpp
+++ b/layout/style/nsLayoutStylesheetCache.cpp
@@ -594,17 +594,20 @@ AnnotateCrashReport(nsIURI* aURI)
       if (ph) {
         handler = do_QueryInterface(ph);
       }
     }
     if (!handler) {
       annotation.AppendLiteral("(ResolveURI failed)\n");
     } else {
       nsAutoCString resolvedSpec;
-      handler->ResolveURI(aURI, resolvedSpec);
+      nsresult rv = handler->ResolveURI(aURI, resolvedSpec);
+      if (NS_FAILED(rv)) {
+        annotation.AppendPrintf("(ResolveURI failed with 0x%08x)\n", rv);
+      }
       annotation.Append(NS_ConvertUTF8toUTF16(resolvedSpec));
       annotation.Append('\n');
     }
   } else if (scheme.EqualsLiteral("chrome")) {
     annotation.AppendLiteral("Real location: ");
     nsCOMPtr<nsIChromeRegistry> reg =
       mozilla::services::GetChromeRegistryService();
     if (!reg) {
--- a/netwerk/protocol/res/ExtensionProtocolHandler.h
+++ b/netwerk/protocol/res/ExtensionProtocolHandler.h
@@ -23,20 +23,22 @@ public:
   NS_FORWARD_NSIPROTOCOLHANDLER(SubstitutingProtocolHandler::)
   NS_FORWARD_NSISUBSTITUTINGPROTOCOLHANDLER(SubstitutingProtocolHandler::)
 
   ExtensionProtocolHandler() : SubstitutingProtocolHandler("moz-extension") {}
 
 protected:
   ~ExtensionProtocolHandler() {}
 
-  bool ResolveSpecialCases(const nsACString& aHost,
-                           const nsACString& aPath,
-                           const nsACString& aPathname,
-                           nsACString& aResult) override;
+  MOZ_MUST_USE bool ResolveSpecialCases(const nsACString& aHost,
+                                        const nsACString& aPath,
+                                        const nsACString& aPathname,
+                                        nsACString& aResult) override;
 
-  virtual nsresult SubstituteChannel(nsIURI* uri, nsILoadInfo* aLoadInfo, nsIChannel** result) override;
+  virtual MOZ_MUST_USE nsresult SubstituteChannel(nsIURI* uri,
+                                                  nsILoadInfo* aLoadInfo,
+                                                  nsIChannel** result) override;
 };
 
 } // namespace net
 } // namespace mozilla
 
 #endif /* ExtensionProtocolHandler_h___ */
--- a/netwerk/protocol/res/SubstitutingProtocolHandler.h
+++ b/netwerk/protocol/res/SubstitutingProtocolHandler.h
@@ -32,45 +32,45 @@ public:
   explicit SubstitutingProtocolHandler(const char* aScheme);
 
   NS_INLINE_DECL_REFCOUNTING(SubstitutingProtocolHandler);
   NS_DECL_NON_VIRTUAL_NSIPROTOCOLHANDLER;
   NS_DECL_NON_VIRTUAL_NSISUBSTITUTINGPROTOCOLHANDLER;
 
   bool HasSubstitution(const nsACString& aRoot) const { return mSubstitutions.Get(aRoot, nullptr); }
 
-  nsresult CollectSubstitutions(InfallibleTArray<SubstitutionMapping>& aResources);
+  MOZ_MUST_USE nsresult CollectSubstitutions(InfallibleTArray<SubstitutionMapping>& aResources);
 
 protected:
   virtual ~SubstitutingProtocolHandler() {}
   void ConstructInternal();
 
-  nsresult SendSubstitution(const nsACString& aRoot, nsIURI* aBaseURI);
+  MOZ_MUST_USE nsresult SendSubstitution(const nsACString& aRoot, nsIURI* aBaseURI);
 
   // Override this in the subclass to try additional lookups after checking
   // mSubstitutions.
-  virtual nsresult GetSubstitutionInternal(const nsACString& aRoot, nsIURI** aResult)
+  virtual MOZ_MUST_USE nsresult GetSubstitutionInternal(const nsACString& aRoot, nsIURI** aResult)
   {
     *aResult = nullptr;
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   // Override this in the subclass to check for special case when resolving URIs
   // _before_ checking substitutions.
-  virtual bool ResolveSpecialCases(const nsACString& aHost,
-                                   const nsACString& aPath,
-                                   const nsACString& aPathname,
-                                   nsACString& aResult)
+  virtual MOZ_MUST_USE bool ResolveSpecialCases(const nsACString& aHost,
+                                                const nsACString& aPath,
+                                                const nsACString& aPathname,
+                                                nsACString& aResult)
   {
     return false;
   }
 
   // Override this in the subclass to check for special case when opening
   // channels.
-  virtual nsresult SubstituteChannel(nsIURI* uri, nsILoadInfo* aLoadInfo, nsIChannel** result)
+  virtual MOZ_MUST_USE nsresult SubstituteChannel(nsIURI* uri, nsILoadInfo* aLoadInfo, nsIChannel** result)
   {
     return NS_OK;
   }
 
   nsIIOService* IOService() { return mIOService; }
 
 private:
   nsCString mScheme;
@@ -92,16 +92,16 @@ private:
 };
 
 // SubstitutingURL : overrides nsStandardURL::GetFile to provide nsIFile resolution
 class SubstitutingURL : public nsStandardURL
 {
 public:
   SubstitutingURL() : nsStandardURL(true) {}
   virtual nsStandardURL* StartClone();
-  virtual nsresult EnsureFile();
+  virtual MOZ_MUST_USE nsresult EnsureFile();
   NS_IMETHOD GetClassIDNoAlloc(nsCID *aCID);
 };
 
 } // namespace net
 } // namespace mozilla
 
 #endif /* SubstitutingProtocolHandler_h___ */
--- a/netwerk/protocol/res/nsISubstitutingProtocolHandler.idl
+++ b/netwerk/protocol/res/nsISubstitutingProtocolHandler.idl
@@ -16,31 +16,31 @@ interface nsISubstitutingProtocolHandler
    * Sets the substitution for the root key:
    *   resource://root/path ==> baseURI.resolve(path)
    *
    * A null baseURI removes the specified substitution.
    *
    * A root key should always be lowercase; however, this may not be
    * enforced.
    */
-  void setSubstitution(in ACString root, in nsIURI baseURI);
+  [must_use] void setSubstitution(in ACString root, in nsIURI baseURI);
 
   /**
    * Gets the substitution for the root key.
    *
    * @throws NS_ERROR_NOT_AVAILABLE if none exists.
    */
-  nsIURI getSubstitution(in ACString root);
+  [must_use] nsIURI getSubstitution(in ACString root);
 
   /**
    * Returns TRUE if the substitution exists and FALSE otherwise.
    */
-  boolean hasSubstitution(in ACString root);
+  [must_use] boolean hasSubstitution(in ACString root);
 
   /**
    * Utility function to resolve a substituted URI.  A resolved URI is not
    * guaranteed to reference a resource that exists (ie. opening a channel to
    * the resolved URI may fail).
    *
    * @throws NS_ERROR_NOT_AVAILABLE if resURI.host() is an unknown root key.
    */
-  AUTF8String resolveURI(in nsIURI resURI);
+  [must_use] AUTF8String resolveURI(in nsIURI resURI);
 };
--- a/netwerk/protocol/res/nsResProtocolHandler.h
+++ b/netwerk/protocol/res/nsResProtocolHandler.h
@@ -24,17 +24,17 @@ public:
 
     NS_FORWARD_NSIPROTOCOLHANDLER(mozilla::SubstitutingProtocolHandler::)
 
     nsResProtocolHandler()
       : SubstitutingProtocolHandler("resource", URI_STD | URI_IS_UI_RESOURCE | URI_IS_LOCAL_RESOURCE,
                                     /* aEnforceFileOrJar = */ false)
     {}
 
-    nsresult Init();
+    MOZ_MUST_USE nsresult Init();
 
     NS_IMETHOD SetSubstitution(const nsACString& aRoot, nsIURI* aBaseURI) override;
 
     NS_IMETHOD GetSubstitution(const nsACString& aRoot, nsIURI** aResult) override
     {
         return mozilla::SubstitutingProtocolHandler::GetSubstitution(aRoot, aResult);
     }
 
@@ -44,22 +44,22 @@ public:
     }
 
     NS_IMETHOD ResolveURI(nsIURI *aResURI, nsACString& aResult) override
     {
         return mozilla::SubstitutingProtocolHandler::ResolveURI(aResURI, aResult);
     }
 
 protected:
-    nsresult GetSubstitutionInternal(const nsACString& aRoot, nsIURI** aResult) override;
+    MOZ_MUST_USE nsresult GetSubstitutionInternal(const nsACString& aRoot, nsIURI** aResult) override;
     virtual ~nsResProtocolHandler() {}
 
-    bool ResolveSpecialCases(const nsACString& aHost,
-                             const nsACString& aPath,
-                             const nsACString& aPathname,
-                             nsACString& aResult) override;
+    MOZ_MUST_USE bool ResolveSpecialCases(const nsACString& aHost,
+                                          const nsACString& aPath,
+                                          const nsACString& aPathname,
+                                          nsACString& aResult) override;
 
 private:
     nsCString mAppURI;
     nsCString mGREURI;
 };
 
 #endif /* nsResProtocolHandler_h___ */