Bug 1310127 - Part 12: Use MOZ_MUST_USE in netwerk/protocol/http r?mak draft
authorWei-Cheng Pan <wpan@mozilla.com>
Tue, 20 Dec 2016 14:14:28 +0800
changeset 494459 9ae2049338e0e342050fcff7f30a162f7771b857
parent 494458 00de68796fb93c526fdb1b3603c412f29020ad69
child 494460 aa6d85722ce98f05544cca9816798e26a38f8c46
push id48029
push userbmo:wpan@mozilla.com
push dateTue, 07 Mar 2017 03:35:29 +0000
reviewersmak
bugs1310127
milestone54.0a1
Bug 1310127 - Part 12: Use MOZ_MUST_USE in netwerk/protocol/http r?mak MozReview-Commit-ID: Bl4CxvNCyS5
browser/components/feeds/nsFeedSniffer.cpp
--- a/browser/components/feeds/nsFeedSniffer.cpp
+++ b/browser/components/feeds/nsFeedSniffer.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsFeedSniffer.h"
 
+#include "mozilla/Unused.h"
 
 #include "nsNetCID.h"
 #include "nsXPCOM.h"
 #include "nsCOMPtr.h"
 #include "nsStringStream.h"
 
 #include "nsBrowserCompsCID.h"
 
@@ -52,18 +53,18 @@ nsFeedSniffer::ConvertEncodedData(nsIReq
   nsresult rv = NS_OK;
 
  mDecodedData = "";
  nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(request));
   if (!httpChannel)
     return NS_ERROR_NO_INTERFACE;
 
   nsAutoCString contentEncoding;
-  httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Encoding"), 
-                                 contentEncoding);
+  mozilla::Unused << httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Encoding"),
+                                                    contentEncoding);
   if (!contentEncoding.IsEmpty()) {
     nsCOMPtr<nsIStreamConverterService> converterService(do_GetService(NS_STREAMCONVERTERSERVICE_CONTRACTID));
     if (converterService) {
       ToLowerCase(contentEncoding);
 
       nsCOMPtr<nsIStreamListener> converter;
       rv = converterService->AsyncConvertData(contentEncoding.get(), 
                                               "uncompressed", this, nullptr, 
@@ -208,17 +209,17 @@ nsFeedSniffer::GetMIMETypeFromContent(ns
                                       nsACString& sniffedType)
 {
   nsCOMPtr<nsIHttpChannel> channel(do_QueryInterface(request));
   if (!channel)
     return NS_ERROR_NO_INTERFACE;
 
   // Check that this is a GET request, since you can't subscribe to a POST...
   nsAutoCString method;
-  channel->GetRequestMethod(method);
+  mozilla::Unused << channel->GetRequestMethod(method);
   if (!method.EqualsLiteral("GET")) {
     sniffedType.Truncate();
     return NS_OK;
   }
 
   // We need to find out if this is a load of a view-source document. In this
   // case we do not want to override the content type, since the source display
   // does not need to be converted from feed format to XUL. More importantly, 
@@ -260,18 +261,20 @@ nsFeedSniffer::GetMIMETypeFromContent(ns
     // check for an attachment after we have a likely feed.
     if(HasAttachmentDisposition(channel)) {
       sniffedType.Truncate();
       return NS_OK;
     }
 
     // set the feed header as a response header, since we have good metadata
     // telling us that the feed is supposed to be RSS or Atom
-    channel->SetResponseHeader(NS_LITERAL_CSTRING("X-Moz-Is-Feed"),
-                               NS_LITERAL_CSTRING("1"), false);
+    mozilla::DebugOnly<nsresult> rv =
+      channel->SetResponseHeader(NS_LITERAL_CSTRING("X-Moz-Is-Feed"),
+                                 NS_LITERAL_CSTRING("1"), false);
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
     sniffedType.AssignLiteral(TYPE_MAYBE_FEED);
     return NS_OK;
   }
 
   // Don't sniff arbitrary types.  Limit sniffing to situations that
   // we think can reasonably arise.
   if (!contentType.EqualsLiteral(TEXT_HTML) &&
       !contentType.EqualsLiteral(APPLICATION_OCTET_STREAM) &&