Bug 1302843 - Don't UpdateCacheabilityInternal if not enabled/initialized. r=mayhemer
authorNicholas Hurley <hurley@todesschaf.org>
Fri, 09 Sep 2016 16:25:07 -0700
changeset 314227 7c2cd6896be70464cb68e89a90bcc748c08ce849
parent 314226 fde4f3db7ee65ec33ac056a1d53c4ebe09e4dbe7
child 314228 1bd98b397fb20d4b4483284968ca9f47498fafa4
push id30711
push userkwierso@gmail.com
push dateFri, 16 Sep 2016 20:38:50 +0000
treeherdermozilla-central@85647c98a790 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1302843
milestone51.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 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()));