Bug 1197000 - Better debugging output for Safe Browsing list updates. r=gcp
authorFrancois Marier <francois@mozilla.com>
Fri, 21 Aug 2015 13:53:53 -0700
changeset 287175 25d46daf76f71e0d81242e6fbf020d45dfefc055
parent 287174 ea072f95e28e9a201542339591a334fecfe3a0ff
child 287176 bc43f663e5e16b7a5e5a6d77b4a96b7c27accafa
push id4660
push usermartin.thomson@gmail.com
push dateFri, 21 Aug 2015 22:37:38 +0000
reviewersgcp
bugs1197000
milestone43.0a1
Bug 1197000 - Better debugging output for Safe Browsing list updates. r=gcp
netwerk/base/nsChannelClassifier.cpp
toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
--- a/netwerk/base/nsChannelClassifier.cpp
+++ b/netwerk/base/nsChannelClassifier.cpp
@@ -615,18 +615,19 @@ nsChannelClassifier::OnClassifyComplete(
 
     if (aErrorCode == NS_ERROR_TRACKING_URI &&
         NS_SUCCEEDED(IsTrackerWhitelisted())) {
       LOG(("nsChannelClassifier[%p]:OnClassifyComplete tracker found "
            "in whitelist so we won't block it)", this));
       aErrorCode = NS_OK;
     }
 
-    LOG(("nsChannelClassifier[%p]:OnClassifyComplete %d", this, aErrorCode));
     if (mSuspendedChannel) {
+        LOG(("nsChannelClassifier[%p]:OnClassifyComplete %d (suspended channel)",
+             this, aErrorCode));
         MarkEntryClassified(aErrorCode);
 
         if (NS_FAILED(aErrorCode)) {
 #ifdef DEBUG
             nsCOMPtr<nsIURI> uri;
             mChannel->GetURI(getter_AddRefs(uri));
             nsCString spec;
             uri->GetSpec(spec);
--- a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
@@ -10,16 +10,17 @@
 #include "nsIUploadChannel.h"
 #include "nsIURI.h"
 #include "nsIUrlClassifierDBService.h"
 #include "nsNetUtil.h"
 #include "nsStreamUtils.h"
 #include "nsStringStream.h"
 #include "nsToolkitCompsCID.h"
 #include "nsUrlClassifierStreamUpdater.h"
+#include "mozilla/ErrorNames.h"
 #include "mozilla/Logging.h"
 #include "nsIInterfaceRequestor.h"
 #include "mozilla/LoadContext.h"
 #include "nsContentUtils.h"
 
 static const char* gQuitApplicationMessage = "quit-application";
 
 #undef LOG
@@ -451,39 +452,46 @@ nsUrlClassifierStreamUpdater::OnStartReq
   bool downloadError = false;
   nsAutoCString strStatus;
   nsresult status = NS_OK;
 
   // Only update if we got http success header
   nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(request);
   if (httpChannel) {
     rv = httpChannel->GetStatus(&status);
-    LOG(("nsUrlClassifierStreamUpdater::OnStartRequest (status=%x, this=%p)",
-         status, this));
     NS_ENSURE_SUCCESS(rv, rv);
 
+    if (MOZ_LOG_TEST(gUrlClassifierStreamUpdaterLog, mozilla::LogLevel::Debug)) {
+      nsAutoCString errorName, spec;
+      mozilla::GetErrorName(status, errorName);
+      nsCOMPtr<nsIURI> uri;
+      rv = httpChannel->GetURI(getter_AddRefs(uri));
+      if (NS_SUCCEEDED(rv) && uri) {
+        uri->GetAsciiSpec(spec);
+      }
+      LOG(("nsUrlClassifierStreamUpdater::OnStartRequest "
+           "(status=%s, uri=%s, this=%p)", errorName.get(),
+           spec.get(), this));
+    }
+
     if (NS_FAILED(status)) {
       // Assume we're overloading the server and trigger backoff.
       downloadError = true;
     } else {
       bool succeeded = false;
       rv = httpChannel->GetRequestSucceeded(&succeeded);
       NS_ENSURE_SUCCESS(rv, rv);
 
-      LOG(("nsUrlClassifierStreamUpdater::OnStartRequest (%s)", succeeded ?
-           "succeeded" : "failed"));
+      uint32_t requestStatus;
+      rv = httpChannel->GetResponseStatus(&requestStatus);
+      NS_ENSURE_SUCCESS(rv, rv);
+      LOG(("nsUrlClassifierStreamUpdater::OnStartRequest %s (%d)", succeeded ?
+           "succeeded" : "failed", requestStatus));
       if (!succeeded) {
         // 404 or other error, pass error status back
-        LOG(("HTTP request returned failure code."));
-
-        uint32_t requestStatus;
-        rv = httpChannel->GetResponseStatus(&requestStatus);
-        LOG(("HTTP request returned failure code: %d.", requestStatus));
-        NS_ENSURE_SUCCESS(rv, rv);
-
         strStatus.AppendInt(requestStatus);
         downloadError = true;
       }
     }
   }
 
   if (downloadError) {
     LOG(("nsUrlClassifierStreamUpdater::Download error [this=%p]", this));