Bug 1386013 - Log an error when Safe Browsing times out. r?hchang draft
authorFrancois Marier <francois@mozilla.com>
Mon, 31 Jul 2017 20:29:25 -0700
changeset 618779 0a6147cca49e3e718b46522a9b99fbc9bf3976e2
parent 618757 44121dbcac6a9d3ff18ed087a09b3205e5a04db1
child 640181 3c607dd35f764dcdff9ce03802c90a0b0b37d771
push id71454
push userfmarier@mozilla.com
push dateTue, 01 Aug 2017 03:30:05 +0000
reviewershchang
bugs1386013
milestone56.0a1
Bug 1386013 - Log an error when Safe Browsing times out. r?hchang MozReview-Commit-ID: A99ov9T7rtm
toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js
toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
--- a/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js
+++ b/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js
@@ -411,17 +411,17 @@ HashCompleterRequest.prototype = {
     });
   },
 
   notify: function HCR_notify() {
     // If we haven't gotten onStopRequest, just cancel. This will call us
     // with onStopRequest since we implement nsIStreamListener on the
     // channel.
     if (this._channel && this._channel.isPending()) {
-      log("cancelling request to " + this.gethashUrl + "\n");
+      log("cancelling request to " + this.gethashUrl + " (timeout)\n");
       Services.telemetry.getKeyedHistogramById("URLCLASSIFIER_COMPLETE_TIMEOUT2").
         add(this.telemetryProvider, 1);
       this._channel.cancel(Cr.NS_BINDING_ABORTED);
     }
   },
 
   // Creates an nsIChannel for the request and fills the body.
   openChannel: function HCR_openChannel() {
--- a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
@@ -972,25 +972,29 @@ nsUrlClassifierStreamUpdater::Notify(nsI
   if (timer == mResponseTimeoutTimer) {
     mResponseTimeoutTimer = nullptr;
     if (mTimeoutTimer) {
       mTimeoutTimer->Cancel();
       mTimeoutTimer = nullptr;
     }
     mDownloadError = true; // Trigger backoff
     updateFailed = true;
+    MOZ_LOG(gUrlClassifierStreamUpdaterLog, mozilla::LogLevel::Error,
+            ("Safe Browsing timed out while waiting for the update server to respond."));
     mozilla::Telemetry::Accumulate(mozilla::Telemetry::URLCLASSIFIER_UPDATE_TIMEOUT,
                                    mTelemetryProvider,
                                    static_cast<uint8_t>(eResponseTimeout));
   }
 
   if (timer == mTimeoutTimer) {
     mTimeoutTimer = nullptr;
     // No backoff since the connection may just be temporarily slow.
     updateFailed = true;
+    MOZ_LOG(gUrlClassifierStreamUpdaterLog, mozilla::LogLevel::Error,
+            ("Safe Browsing timed out while waiting for the update server to finish."));
     mozilla::Telemetry::Accumulate(mozilla::Telemetry::URLCLASSIFIER_UPDATE_TIMEOUT,
                                    mTelemetryProvider,
                                    static_cast<uint8_t>(eDownloadTimeout));
   }
 
   if (updateFailed) {
     // Cancelling the channel will trigger OnStopRequest.
     mozilla::Unused << mChannel->Cancel(NS_ERROR_ABORT);