Bug 1302843 - Don't UpdateCacheabilityInternal if not enabled/initialized. r?mayhemer draft
authorNicholas Hurley <hurley@todesschaf.org>
Fri, 09 Sep 2016 16:25:07 -0700
changeset 413768 933081021ef534b5ed00277edb5a9637d2a93ad8
parent 413613 8a494adbc5cced90a4edf0c98cffde906bf7f3ae
child 531293 6bdb048965d88438df9402631e9a4268742cb9d2
push id29501
push userbmo:hurley@todesschaf.org
push dateWed, 14 Sep 2016 20:39:28 +0000
reviewersmayhemer
bugs1302843
milestone51.0a1
Bug 1302843 - Don't UpdateCacheabilityInternal if not enabled/initialized. r?mayhemer MozReview-Commit-ID: HzSu0TM14R2
netwerk/base/Predictor.cpp
--- a/netwerk/base/Predictor.cpp
+++ b/netwerk/base/Predictor.cpp
@@ -2402,16 +2402,32 @@ Predictor::UpdateCacheability(nsIURI *so
 }
 
 void
 Predictor::UpdateCacheabilityInternal(nsIURI *sourceURI, nsIURI *targetURI,
                                       uint32_t httpStatus,
                                       const nsCString &method)
 {
   PREDICTOR_LOG(("Predictor::UpdateCacheability httpStatus=%u", httpStatus));
+
+  if (!mInitialized) {
+    PREDICTOR_LOG(("    not initialized"));
+    return;
+  }
+
+  if (!mEnabled) {
+    PREDICTOR_LOG(("    not enabled"));
+    return;
+  }
+
+  if (!mEnablePrefetch) {
+    PREDICTOR_LOG(("    prefetch not enabled"));
+    return;
+  }
+
   uint32_t openFlags = nsICacheStorage::OPEN_READONLY |
                        nsICacheStorage::OPEN_SECRETLY |
                        nsICacheStorage::CHECK_MULTITHREADED;
   RefPtr<Predictor::CacheabilityAction> action =
     new Predictor::CacheabilityAction(targetURI, httpStatus, method, this);
   nsAutoCString uri;
   targetURI->GetAsciiSpec(uri);
   PREDICTOR_LOG(("    uri=%s action=%p", uri.get(), action.get()));