Bug 1473631: Part 1 - Replace pref observers with callbacks in nsHttpHandler. r?njn draft
authorKris Maglione <maglione.k@gmail.com>
Thu, 05 Jul 2018 13:10:20 -0700
changeset 818473 1e8404ea2dbd50a05258589a005f39ccddbc9a89
parent 818472 c0880fafb7ba06c02b501b14a896f393eb6818e5
child 818474 d2476f28372589bddc939ba5718a90907eeb7d33
push id116269
push usermaglione.k@gmail.com
push dateSat, 14 Jul 2018 02:18:47 +0000
reviewersnjn
bugs1473631
milestone63.0a1
Bug 1473631: Part 1 - Replace pref observers with callbacks in nsHttpHandler. r?njn MozReview-Commit-ID: LtWV0yEwSd6
netwerk/protocol/http/nsHttpHandler.cpp
netwerk/protocol/http/nsHttpHandler.h
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -412,16 +412,36 @@ nsHttpHandler::~nsHttpHandler()
     }
 
     // Note: don't call NeckoChild::DestroyNeckoChild() here, as it's too late
     // and it'll segfault.  NeckoChild will get cleaned up by process exit.
 
     nsHttp::DestroyAtomTable();
 }
 
+static const char* gCallbackPrefs[] = {
+    HTTP_PREF_PREFIX,
+    UA_PREF_PREFIX,
+    INTL_ACCEPT_LANGUAGES,
+    BROWSER_PREF("disk_cache_ssl"),
+    DONOTTRACK_HEADER_ENABLED,
+    TELEMETRY_ENABLED,
+    H2MANDATORY_SUITE,
+    HTTP_PREF("tcp_keepalive.short_lived_connections"),
+    HTTP_PREF("tcp_keepalive.long_lived_connections"),
+    SAFE_HINT_HEADER_VALUE,
+    SECURITY_PREFIX,
+    TCP_FAST_OPEN_ENABLE,
+    TCP_FAST_OPEN_FAILURE_LIMIT,
+    TCP_FAST_OPEN_STALLS_LIMIT,
+    TCP_FAST_OPEN_STALLS_IDLE,
+    TCP_FAST_OPEN_STALLS_TIMEOUT,
+    nullptr,
+};
+
 nsresult
 nsHttpHandler::Init()
 {
     nsresult rv;
 
     LOG(("nsHttpHandler::Init\n"));
     MOZ_ASSERT(NS_IsMainThread());
 
@@ -444,36 +464,20 @@ nsHttpHandler::Init()
 
     // This perference is only used in parent process.
     if (!IsNeckoChild()) {
         mActiveTabPriority =
             Preferences::GetBool(HTTP_PREF("active_tab_priority"), true);
     }
 
     // monitor some preference changes
-    nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
-    if (prefBranch) {
-        prefBranch->AddObserver(HTTP_PREF_PREFIX, this, true);
-        prefBranch->AddObserver(UA_PREF_PREFIX, this, true);
-        prefBranch->AddObserver(INTL_ACCEPT_LANGUAGES, this, true);
-        prefBranch->AddObserver(BROWSER_PREF("disk_cache_ssl"), this, true);
-        prefBranch->AddObserver(DONOTTRACK_HEADER_ENABLED, this, true);
-        prefBranch->AddObserver(TELEMETRY_ENABLED, this, true);
-        prefBranch->AddObserver(H2MANDATORY_SUITE, this, true);
-        prefBranch->AddObserver(HTTP_PREF("tcp_keepalive.short_lived_connections"), this, true);
-        prefBranch->AddObserver(HTTP_PREF("tcp_keepalive.long_lived_connections"), this, true);
-        prefBranch->AddObserver(SAFE_HINT_HEADER_VALUE, this, true);
-        prefBranch->AddObserver(SECURITY_PREFIX, this, true);
-        prefBranch->AddObserver(TCP_FAST_OPEN_ENABLE, this, true);
-        prefBranch->AddObserver(TCP_FAST_OPEN_FAILURE_LIMIT, this, true);
-        prefBranch->AddObserver(TCP_FAST_OPEN_STALLS_LIMIT, this, true);
-        prefBranch->AddObserver(TCP_FAST_OPEN_STALLS_IDLE, this, true);
-        prefBranch->AddObserver(TCP_FAST_OPEN_STALLS_TIMEOUT, this, true);
-        PrefsChanged(prefBranch, nullptr);
-    }
+    Preferences::RegisterPrefixCallbacks(
+        PREF_CHANGE_METHOD(nsHttpHandler::PrefsChanged),
+        gCallbackPrefs,
+        this);
 
     mMisc.AssignLiteral("rv:" MOZILLA_UAVERSION);
 
     mCompatFirefox.AssignLiteral("Firefox/" MOZILLA_UAVERSION);
 
     nsCOMPtr<nsIXULAppInfo> appInfo =
         do_GetService("@mozilla.org/xre/app-info;1");
 
@@ -1155,17 +1159,17 @@ nsHttpHandler::MaxSocketCount()
         maxCount = 1;
     else
         maxCount -= 8;
 
     return maxCount;
 }
 
 void
-nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
+nsHttpHandler::PrefsChanged(const char *pref)
 {
     nsresult rv = NS_OK;
     int32_t val;
 
     LOG(("nsHttpHandler::PrefsChanged [pref=%s]\n", pref));
 
 #define PREF_CHANGED(p) ((pref == nullptr) || !PL_strcmp(pref, p))
 #define MULTI_PREF_CHANGED(p) \
@@ -1190,24 +1194,24 @@ nsHttpHandler::PrefsChanged(nsIPrefBranc
 
     //
     // UA components
     //
 
     bool cVar = false;
 
     if (PREF_CHANGED(UA_PREF("compatMode.firefox"))) {
-        rv = prefs->GetBoolPref(UA_PREF("compatMode.firefox"), &cVar);
+        rv = Preferences::GetBool(UA_PREF("compatMode.firefox"), &cVar);
         mCompatFirefoxEnabled = (NS_SUCCEEDED(rv) && cVar);
         mUserAgentIsDirty = true;
     }
 
     // general.useragent.override
     if (PREF_CHANGED(UA_PREF("override"))) {
-        prefs->GetCharPref(UA_PREF("override"), mUserAgentOverride);
+        Preferences::GetCString(UA_PREF("override"), mUserAgentOverride);
         mUserAgentIsDirty = true;
     }
 
 #ifdef ANDROID
     // general.useragent.use_device
     if (PREF_CHANGED(UA_PREF("use_device"))) {
         if (Preferences::GetBool(UA_PREF("use_device"), false)) {
             mDeviceModelId = mozilla::net::GetDeviceModelId();
@@ -1218,56 +1222,56 @@ nsHttpHandler::PrefsChanged(nsIPrefBranc
     }
 #endif
 
     //
     // HTTP options
     //
 
     if (PREF_CHANGED(HTTP_PREF("keep-alive.timeout"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("keep-alive.timeout"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("keep-alive.timeout"), &val);
         if (NS_SUCCEEDED(rv))
             mIdleTimeout = PR_SecondsToInterval(clamped(val, 1, 0xffff));
     }
 
     if (PREF_CHANGED(HTTP_PREF("request.max-attempts"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("request.max-attempts"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("request.max-attempts"), &val);
         if (NS_SUCCEEDED(rv))
             mMaxRequestAttempts = (uint16_t) clamped(val, 1, 0xffff);
     }
 
     if (PREF_CHANGED(HTTP_PREF("request.max-start-delay"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("request.max-start-delay"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("request.max-start-delay"), &val);
         if (NS_SUCCEEDED(rv)) {
             mMaxRequestDelay = (uint16_t) clamped(val, 0, 0xffff);
             if (mConnMgr) {
                 rv = mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_REQUEST_DELAY,
                                            mMaxRequestDelay);
                 if (NS_FAILED(rv)) {
                     LOG(("nsHttpHandler::PrefsChanged (request.max-start-delay)"
                          "UpdateParam failed (%08x)\n", static_cast<uint32_t>(rv)));
                 }
             }
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("response.timeout"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("response.timeout"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("response.timeout"), &val);
         if (NS_SUCCEEDED(rv))
             mResponseTimeout = PR_SecondsToInterval(clamped(val, 0, 0xffff));
     }
 
     if (PREF_CHANGED(HTTP_PREF("network-changed.timeout"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("network-changed.timeout"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("network-changed.timeout"), &val);
         if (NS_SUCCEEDED(rv))
             mNetworkChangedTimeout = clamped(val, 1, 600) * 1000;
     }
 
     if (PREF_CHANGED(HTTP_PREF("max-connections"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("max-connections"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("max-connections"), &val);
         if (NS_SUCCEEDED(rv)) {
 
             mMaxConnections = (uint16_t) clamped((uint32_t)val,
                                                  (uint32_t)1, MaxSocketCount());
 
             if (mConnMgr) {
                 rv = mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_CONNECTIONS,
                                            mMaxConnections);
@@ -1275,182 +1279,182 @@ nsHttpHandler::PrefsChanged(nsIPrefBranc
                     LOG(("nsHttpHandler::PrefsChanged (max-connections)"
                          "UpdateParam failed (%08x)\n", static_cast<uint32_t>(rv)));
                 }
             }
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("max-urgent-start-excessive-connections-per-host"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("max-urgent-start-excessive-connections-per-host"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("max-urgent-start-excessive-connections-per-host"), &val);
         if (NS_SUCCEEDED(rv)) {
             mMaxUrgentExcessiveConns = (uint8_t) clamped(val, 1, 0xff);
             if (mConnMgr) {
                 rv = mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_URGENT_START_Q,
                                            mMaxUrgentExcessiveConns);
                 if (NS_FAILED(rv)) {
                     LOG(("nsHttpHandler::PrefsChanged (max-urgent-start-excessive-connections-per-host)"
                          "UpdateParam failed (%08x)\n", static_cast<uint32_t>(rv)));
                 }
              }
           }
     }
 
     if (PREF_CHANGED(HTTP_PREF("max-persistent-connections-per-server"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("max-persistent-connections-per-server"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("max-persistent-connections-per-server"), &val);
         if (NS_SUCCEEDED(rv)) {
             mMaxPersistentConnectionsPerServer = (uint8_t) clamped(val, 1, 0xff);
             if (mConnMgr) {
                 rv = mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_PERSISTENT_CONNECTIONS_PER_HOST,
                                            mMaxPersistentConnectionsPerServer);
                 if (NS_FAILED(rv)) {
                     LOG(("nsHttpHandler::PrefsChanged (max-persistent-connections-per-server)"
                          "UpdateParam failed (%08x)\n", static_cast<uint32_t>(rv)));
                 }
             }
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("max-persistent-connections-per-proxy"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("max-persistent-connections-per-proxy"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("max-persistent-connections-per-proxy"), &val);
         if (NS_SUCCEEDED(rv)) {
             mMaxPersistentConnectionsPerProxy = (uint8_t) clamped(val, 1, 0xff);
             if (mConnMgr) {
                 rv = mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_PERSISTENT_CONNECTIONS_PER_PROXY,
                                            mMaxPersistentConnectionsPerProxy);
                 if (NS_FAILED(rv)) {
                     LOG(("nsHttpHandler::PrefsChanged (max-persistent-connections-per-proxy)"
                          "UpdateParam failed (%08x)\n", static_cast<uint32_t>(rv)));
                 }
             }
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("sendRefererHeader"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("sendRefererHeader"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("sendRefererHeader"), &val);
         if (NS_SUCCEEDED(rv))
             mReferrerLevel = (uint8_t) clamped(val, 0, 0xff);
     }
 
     if (PREF_CHANGED(HTTP_PREF("referer.spoofSource"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("referer.spoofSource"), &cVar);
+        rv = Preferences::GetBool(HTTP_PREF("referer.spoofSource"), &cVar);
         if (NS_SUCCEEDED(rv))
             mSpoofReferrerSource = cVar;
     }
 
     if (PREF_CHANGED(HTTP_PREF("referer.hideOnionSource"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("referer.hideOnionSource"), &cVar);
+        rv = Preferences::GetBool(HTTP_PREF("referer.hideOnionSource"), &cVar);
         if (NS_SUCCEEDED(rv))
             mHideOnionReferrerSource = cVar;
     }
 
     if (PREF_CHANGED(HTTP_PREF("referer.trimmingPolicy"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("referer.trimmingPolicy"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("referer.trimmingPolicy"), &val);
         if (NS_SUCCEEDED(rv))
             mReferrerTrimmingPolicy = (uint8_t) clamped(val, 0, 2);
     }
 
     if (PREF_CHANGED(HTTP_PREF("referer.XOriginTrimmingPolicy"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("referer.XOriginTrimmingPolicy"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("referer.XOriginTrimmingPolicy"), &val);
         if (NS_SUCCEEDED(rv))
             mReferrerXOriginTrimmingPolicy = (uint8_t) clamped(val, 0, 2);
     }
 
     if (PREF_CHANGED(HTTP_PREF("referer.XOriginPolicy"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("referer.XOriginPolicy"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("referer.XOriginPolicy"), &val);
         if (NS_SUCCEEDED(rv))
             mReferrerXOriginPolicy = (uint8_t) clamped(val, 0, 0xff);
     }
 
     if (PREF_CHANGED(HTTP_PREF("redirection-limit"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("redirection-limit"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("redirection-limit"), &val);
         if (NS_SUCCEEDED(rv))
             mRedirectionLimit = (uint8_t) clamped(val, 0, 0xff);
     }
 
     if (PREF_CHANGED(HTTP_PREF("connection-retry-timeout"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("connection-retry-timeout"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("connection-retry-timeout"), &val);
         if (NS_SUCCEEDED(rv))
             mIdleSynTimeout = (uint16_t) clamped(val, 0, 3000);
     }
 
     if (PREF_CHANGED(HTTP_PREF("fast-fallback-to-IPv4"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("fast-fallback-to-IPv4"), &cVar);
+        rv = Preferences::GetBool(HTTP_PREF("fast-fallback-to-IPv4"), &cVar);
         if (NS_SUCCEEDED(rv))
             mFastFallbackToIPv4 = cVar;
     }
 
     if (PREF_CHANGED(HTTP_PREF("fallback-connection-timeout"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("fallback-connection-timeout"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("fallback-connection-timeout"), &val);
         if (NS_SUCCEEDED(rv))
             mFallbackSynTimeout = (uint16_t) clamped(val, 0, 10 * 60);
     }
 
     if (PREF_CHANGED(HTTP_PREF("version"))) {
         nsAutoCString httpVersion;
-        prefs->GetCharPref(HTTP_PREF("version"), httpVersion);
+        Preferences::GetCString(HTTP_PREF("version"), httpVersion);
         if (!httpVersion.IsVoid()) {
             if (httpVersion.EqualsLiteral("1.1"))
                 mHttpVersion = HttpVersion::v1_1;
             else if (httpVersion.EqualsLiteral("0.9"))
                 mHttpVersion = HttpVersion::v0_9;
             else
                 mHttpVersion = HttpVersion::v1_0;
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("proxy.version"))) {
         nsAutoCString httpVersion;
-        prefs->GetCharPref(HTTP_PREF("proxy.version"), httpVersion);
+        Preferences::GetCString(HTTP_PREF("proxy.version"), httpVersion);
         if (!httpVersion.IsVoid()) {
             if (httpVersion.EqualsLiteral("1.1"))
                 mProxyHttpVersion = HttpVersion::v1_1;
             else
                 mProxyHttpVersion = HttpVersion::v1_0;
             // it does not make sense to issue a HTTP/0.9 request to a proxy server
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("qos"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("qos"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("qos"), &val);
         if (NS_SUCCEEDED(rv))
             mQoSBits = (uint8_t) clamped(val, 0, 0xff);
     }
 
     if (PREF_CHANGED(HTTP_PREF("accept.default"))) {
         nsAutoCString accept;
-        rv = prefs->GetCharPref(HTTP_PREF("accept.default"), accept);
+        rv = Preferences::GetCString(HTTP_PREF("accept.default"), accept);
         if (NS_SUCCEEDED(rv)) {
             rv = SetAccept(accept.get());
             MOZ_ASSERT(NS_SUCCEEDED(rv));
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("accept-encoding"))) {
         nsAutoCString acceptEncodings;
-        rv = prefs->GetCharPref(HTTP_PREF("accept-encoding"), acceptEncodings);
+        rv = Preferences::GetCString(HTTP_PREF("accept-encoding"), acceptEncodings);
         if (NS_SUCCEEDED(rv)) {
             rv = SetAcceptEncodings(acceptEncodings.get(), false);
             MOZ_ASSERT(NS_SUCCEEDED(rv));
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("accept-encoding.secure"))) {
         nsAutoCString acceptEncodings;
-        rv = prefs->GetCharPref(HTTP_PREF("accept-encoding.secure"),
+        rv = Preferences::GetCString(HTTP_PREF("accept-encoding.secure"),
                                 acceptEncodings);
         if (NS_SUCCEEDED(rv)) {
             rv = SetAcceptEncodings(acceptEncodings.get(), true);
             MOZ_ASSERT(NS_SUCCEEDED(rv));
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("default-socket-type"))) {
         nsAutoCString sval;
-        rv = prefs->GetCharPref(HTTP_PREF("default-socket-type"), sval);
+        rv = Preferences::GetCString(HTTP_PREF("default-socket-type"), sval);
         if (NS_SUCCEEDED(rv)) {
             if (sval.IsEmpty())
                 mDefaultSocketType.SetIsVoid(true);
             else {
                 // verify that this socket type is actually valid
                 nsCOMPtr<nsISocketProviderService> sps(
                         do_GetService(NS_SOCKETPROVIDERSERVICE_CONTRACTID));
                 if (sps) {
@@ -1461,317 +1465,317 @@ nsHttpHandler::PrefsChanged(nsIPrefBranc
                         mDefaultSocketType.Assign(sval);
                     }
                 }
             }
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("prompt-temp-redirect"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("prompt-temp-redirect"), &cVar);
+        rv = Preferences::GetBool(HTTP_PREF("prompt-temp-redirect"), &cVar);
         if (NS_SUCCEEDED(rv)) {
             mPromptTempRedirect = cVar;
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("assoc-req.enforce"))) {
         cVar = false;
-        rv = prefs->GetBoolPref(HTTP_PREF("assoc-req.enforce"), &cVar);
+        rv = Preferences::GetBool(HTTP_PREF("assoc-req.enforce"), &cVar);
         if (NS_SUCCEEDED(rv))
             mEnforceAssocReq = cVar;
     }
 
     // enable Persistent caching for HTTPS - bug#205921
     if (PREF_CHANGED(BROWSER_PREF("disk_cache_ssl"))) {
         cVar = false;
-        rv = prefs->GetBoolPref(BROWSER_PREF("disk_cache_ssl"), &cVar);
+        rv = Preferences::GetBool(BROWSER_PREF("disk_cache_ssl"), &cVar);
         if (NS_SUCCEEDED(rv))
             mEnablePersistentHttpsCaching = cVar;
     }
 
     if (PREF_CHANGED(HTTP_PREF("phishy-userpass-length"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("phishy-userpass-length"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("phishy-userpass-length"), &val);
         if (NS_SUCCEEDED(rv))
             mPhishyUserPassLength = (uint8_t) clamped(val, 0, 0xff);
     }
 
     if (PREF_CHANGED(HTTP_PREF("spdy.enabled"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("spdy.enabled"), &cVar);
+        rv = Preferences::GetBool(HTTP_PREF("spdy.enabled"), &cVar);
         if (NS_SUCCEEDED(rv))
             mEnableSpdy = cVar;
     }
 
     if (PREF_CHANGED(HTTP_PREF("spdy.enabled.http2"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("spdy.enabled.http2"), &cVar);
+        rv = Preferences::GetBool(HTTP_PREF("spdy.enabled.http2"), &cVar);
         if (NS_SUCCEEDED(rv))
             mHttp2Enabled = cVar;
     }
 
     if (PREF_CHANGED(HTTP_PREF("spdy.enabled.deps"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("spdy.enabled.deps"), &cVar);
+        rv = Preferences::GetBool(HTTP_PREF("spdy.enabled.deps"), &cVar);
         if (NS_SUCCEEDED(rv))
             mUseH2Deps = cVar;
     }
 
     if (PREF_CHANGED(HTTP_PREF("spdy.enforce-tls-profile"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("spdy.enforce-tls-profile"), &cVar);
+        rv = Preferences::GetBool(HTTP_PREF("spdy.enforce-tls-profile"), &cVar);
         if (NS_SUCCEEDED(rv))
             mEnforceHttp2TlsProfile = cVar;
     }
 
     if (PREF_CHANGED(HTTP_PREF("spdy.coalesce-hostnames"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("spdy.coalesce-hostnames"), &cVar);
+        rv = Preferences::GetBool(HTTP_PREF("spdy.coalesce-hostnames"), &cVar);
         if (NS_SUCCEEDED(rv))
             mCoalesceSpdy = cVar;
     }
 
     if (PREF_CHANGED(HTTP_PREF("spdy.persistent-settings"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("spdy.persistent-settings"),
+        rv = Preferences::GetBool(HTTP_PREF("spdy.persistent-settings"),
                                 &cVar);
         if (NS_SUCCEEDED(rv))
             mSpdyPersistentSettings = cVar;
     }
 
     if (PREF_CHANGED(HTTP_PREF("spdy.timeout"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("spdy.timeout"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("spdy.timeout"), &val);
         if (NS_SUCCEEDED(rv))
             mSpdyTimeout = PR_SecondsToInterval(clamped(val, 1, 0xffff));
     }
 
     if (PREF_CHANGED(HTTP_PREF("spdy.chunk-size"))) {
         // keep this within http/2 ranges of 1 to 2^14-1
-        rv = prefs->GetIntPref(HTTP_PREF("spdy.chunk-size"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("spdy.chunk-size"), &val);
         if (NS_SUCCEEDED(rv))
             mSpdySendingChunkSize = (uint32_t) clamped(val, 1, 0x3fff);
     }
 
     // The amount of idle seconds on a spdy connection before initiating a
     // server ping. 0 will disable.
     if (PREF_CHANGED(HTTP_PREF("spdy.ping-threshold"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("spdy.ping-threshold"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("spdy.ping-threshold"), &val);
         if (NS_SUCCEEDED(rv))
             mSpdyPingThreshold =
                 PR_SecondsToInterval((uint16_t) clamped(val, 0, 0x7fffffff));
     }
 
     // The amount of seconds to wait for a spdy ping response before
     // closing the session.
     if (PREF_CHANGED(HTTP_PREF("spdy.ping-timeout"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("spdy.ping-timeout"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("spdy.ping-timeout"), &val);
         if (NS_SUCCEEDED(rv))
             mSpdyPingTimeout =
                 PR_SecondsToInterval((uint16_t) clamped(val, 0, 0x7fffffff));
     }
 
     if (PREF_CHANGED(HTTP_PREF("spdy.allow-push"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("spdy.allow-push"),
+        rv = Preferences::GetBool(HTTP_PREF("spdy.allow-push"),
                                 &cVar);
         if (NS_SUCCEEDED(rv))
             mAllowPush = cVar;
     }
 
     if (PREF_CHANGED(HTTP_PREF("altsvc.enabled"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("altsvc.enabled"),
+        rv = Preferences::GetBool(HTTP_PREF("altsvc.enabled"),
                                 &cVar);
         if (NS_SUCCEEDED(rv))
             mEnableAltSvc = cVar;
     }
 
 
     if (PREF_CHANGED(HTTP_PREF("altsvc.oe"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("altsvc.oe"),
+        rv = Preferences::GetBool(HTTP_PREF("altsvc.oe"),
                                 &cVar);
         if (NS_SUCCEEDED(rv))
             mEnableAltSvcOE = cVar;
     }
 
     if (PREF_CHANGED(HTTP_PREF("originextension"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("originextension"),
+        rv = Preferences::GetBool(HTTP_PREF("originextension"),
                                 &cVar);
         if (NS_SUCCEEDED(rv))
             mEnableOriginExtension = cVar;
     }
 
     if (PREF_CHANGED(HTTP_PREF("spdy.push-allowance"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("spdy.push-allowance"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("spdy.push-allowance"), &val);
         if (NS_SUCCEEDED(rv)) {
             mSpdyPushAllowance =
                 static_cast<uint32_t>
                 (clamped(val, 1024, static_cast<int32_t>(ASpdySession::kInitialRwin)));
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("spdy.pull-allowance"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("spdy.pull-allowance"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("spdy.pull-allowance"), &val);
         if (NS_SUCCEEDED(rv)) {
             mSpdyPullAllowance =
                 static_cast<uint32_t>(clamped(val, 1024, 0x7fffffff));
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("spdy.default-concurrent"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("spdy.default-concurrent"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("spdy.default-concurrent"), &val);
         if (NS_SUCCEEDED(rv)) {
             mDefaultSpdyConcurrent =
                 static_cast<uint32_t>(std::max<int32_t>(std::min<int32_t>(val, 9999), 1));
         }
     }
 
     // The amount of seconds to wait for a spdy ping response before
     // closing the session.
     if (PREF_CHANGED(HTTP_PREF("spdy.send-buffer-size"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("spdy.send-buffer-size"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("spdy.send-buffer-size"), &val);
         if (NS_SUCCEEDED(rv))
             mSpdySendBufferSize = (uint32_t) clamped(val, 1500, 0x7fffffff);
     }
 
     // The maximum amount of time to wait for socket transport to be
     // established
     if (PREF_CHANGED(HTTP_PREF("connection-timeout"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("connection-timeout"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("connection-timeout"), &val);
         if (NS_SUCCEEDED(rv))
             // the pref is in seconds, but the variable is in milliseconds
             mConnectTimeout = clamped(val, 1, 0xffff) * PR_MSEC_PER_SEC;
     }
 
     // The maximum amount of time to wait for a tls handshake to finish.
     if (PREF_CHANGED(HTTP_PREF("tls-handshake-timeout"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("tls-handshake-timeout"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("tls-handshake-timeout"), &val);
         if (NS_SUCCEEDED(rv))
             // the pref is in seconds, but the variable is in milliseconds
             mTLSHandshakeTimeout = clamped(val, 1, 0xffff) * PR_MSEC_PER_SEC;
     }
 
     // The maximum number of current global half open sockets allowable
     // for starting a new speculative connection.
     if (PREF_CHANGED(HTTP_PREF("speculative-parallel-limit"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("speculative-parallel-limit"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("speculative-parallel-limit"), &val);
         if (NS_SUCCEEDED(rv))
             mParallelSpeculativeConnectLimit = (uint32_t) clamped(val, 0, 1024);
     }
 
     // Whether or not to block requests for non head js/css items (e.g. media)
     // while those elements load.
     if (PREF_CHANGED(HTTP_PREF("rendering-critical-requests-prioritization"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("rendering-critical-requests-prioritization"), &cVar);
+        rv = Preferences::GetBool(HTTP_PREF("rendering-critical-requests-prioritization"), &cVar);
         if (NS_SUCCEEDED(rv))
             mCriticalRequestPrioritization = cVar;
     }
 
     // on transition of network.http.diagnostics to true print
     // a bunch of information to the console
     if (pref && PREF_CHANGED(HTTP_PREF("diagnostics"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("diagnostics"), &cVar);
+        rv = Preferences::GetBool(HTTP_PREF("diagnostics"), &cVar);
         if (NS_SUCCEEDED(rv) && cVar) {
             if (mConnMgr)
                 mConnMgr->PrintDiagnostics();
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("max_response_header_size"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("max_response_header_size"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("max_response_header_size"), &val);
         if (NS_SUCCEEDED(rv)) {
             mMaxHttpResponseHeaderSize = val;
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("throttle.enable"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("throttle.enable"), &mThrottleEnabled);
+        rv = Preferences::GetBool(HTTP_PREF("throttle.enable"), &mThrottleEnabled);
         if (NS_SUCCEEDED(rv) && mConnMgr) {
             Unused << mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_ENABLED,
                                             static_cast<int32_t>(mThrottleEnabled));
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("throttle.version"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("throttle.version"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("throttle.version"), &val);
         mThrottleVersion = (uint32_t)clamped(val, 1, 2);
     }
 
     if (PREF_CHANGED(HTTP_PREF("throttle.suspend-for"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("throttle.suspend-for"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("throttle.suspend-for"), &val);
         mThrottleSuspendFor = (uint32_t)clamped(val, 0, 120000);
         if (NS_SUCCEEDED(rv) && mConnMgr) {
             Unused << mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_SUSPEND_FOR,
                                             mThrottleSuspendFor);
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("throttle.resume-for"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("throttle.resume-for"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("throttle.resume-for"), &val);
         mThrottleResumeFor = (uint32_t)clamped(val, 0, 120000);
         if (NS_SUCCEEDED(rv) && mConnMgr) {
             Unused << mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_RESUME_FOR,
                                             mThrottleResumeFor);
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("throttle.read-limit-bytes"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("throttle.read-limit-bytes"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("throttle.read-limit-bytes"), &val);
         mThrottleReadLimit = (uint32_t)clamped(val, 0, 500000);
         if (NS_SUCCEEDED(rv) && mConnMgr) {
             Unused << mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_READ_LIMIT,
                                             mThrottleReadLimit);
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("throttle.read-interval-ms"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("throttle.read-interval-ms"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("throttle.read-interval-ms"), &val);
         mThrottleReadInterval = (uint32_t)clamped(val, 0, 120000);
         if (NS_SUCCEEDED(rv) && mConnMgr) {
             Unused << mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_READ_INTERVAL,
                                             mThrottleReadInterval);
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("throttle.hold-time-ms"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("throttle.hold-time-ms"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("throttle.hold-time-ms"), &val);
         mThrottleHoldTime = (uint32_t)clamped(val, 0, 120000);
         if (NS_SUCCEEDED(rv) && mConnMgr) {
             Unused << mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_HOLD_TIME,
                                             mThrottleHoldTime);
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("throttle.max-time-ms"))) {
-      rv = prefs->GetIntPref(HTTP_PREF("throttle.max-time-ms"), &val);
+      rv = Preferences::GetInt(HTTP_PREF("throttle.max-time-ms"), &val);
       mThrottleMaxTime = (uint32_t)clamped(val, 0, 120000);
       if (NS_SUCCEEDED(rv) && mConnMgr) {
         Unused << mConnMgr->UpdateParam(nsHttpConnectionMgr::THROTTLING_MAX_TIME,
                                         mThrottleMaxTime);
       }
     }
 
     if (PREF_CHANGED(HTTP_PREF("on_click_priority"))) {
-        Unused << prefs->GetBoolPref(HTTP_PREF("on_click_priority"), &mUrgentStartEnabled);
+        Unused << Preferences::GetBool(HTTP_PREF("on_click_priority"), &mUrgentStartEnabled);
     }
 
     if (PREF_CHANGED(HTTP_PREF("tailing.enabled"))) {
-        Unused << prefs->GetBoolPref(HTTP_PREF("tailing.enabled"), &mTailBlockingEnabled);
+        Unused << Preferences::GetBool(HTTP_PREF("tailing.enabled"), &mTailBlockingEnabled);
     }
     if (PREF_CHANGED(HTTP_PREF("tailing.delay-quantum"))) {
-        Unused << prefs->GetIntPref(HTTP_PREF("tailing.delay-quantum"), &val);
+        Unused << Preferences::GetInt(HTTP_PREF("tailing.delay-quantum"), &val);
         mTailDelayQuantum = (uint32_t)clamped(val, 0, 60000);
     }
     if (PREF_CHANGED(HTTP_PREF("tailing.delay-quantum-after-domcontentloaded"))) {
-        Unused << prefs->GetIntPref(HTTP_PREF("tailing.delay-quantum-after-domcontentloaded"), &val);
+        Unused << Preferences::GetInt(HTTP_PREF("tailing.delay-quantum-after-domcontentloaded"), &val);
         mTailDelayQuantumAfterDCL = (uint32_t)clamped(val, 0, 60000);
     }
     if (PREF_CHANGED(HTTP_PREF("tailing.delay-max"))) {
-        Unused << prefs->GetIntPref(HTTP_PREF("tailing.delay-max"), &val);
+        Unused << Preferences::GetInt(HTTP_PREF("tailing.delay-max"), &val);
         mTailDelayMax = (uint32_t)clamped(val, 0, 60000);
     }
     if (PREF_CHANGED(HTTP_PREF("tailing.total-max"))) {
-        Unused << prefs->GetIntPref(HTTP_PREF("tailing.total-max"), &val);
+        Unused << Preferences::GetInt(HTTP_PREF("tailing.total-max"), &val);
         mTailTotalMax = (uint32_t)clamped(val, 0, 60000);
     }
 
     if (PREF_CHANGED(HTTP_PREF("focused_window_transaction_ratio"))) {
         float ratio = 0;
-        rv = prefs->GetFloatPref(HTTP_PREF("focused_window_transaction_ratio"), &ratio);
+        rv = Preferences::GetFloat(HTTP_PREF("focused_window_transaction_ratio"), &ratio);
         if (NS_SUCCEEDED(rv)) {
             if (ratio > 0 && ratio < 1) {
                 mFocusedWindowTransactionRatio = ratio;
             } else {
                 NS_WARNING("Wrong value for focused_window_transaction_ratio");
             }
         }
     }
@@ -1788,216 +1792,216 @@ nsHttpHandler::PrefsChanged(nsIPrefBranc
     }
 
     //
     // Tracking options
     //
 
     if (PREF_CHANGED(DONOTTRACK_HEADER_ENABLED)) {
         cVar = false;
-        rv = prefs->GetBoolPref(DONOTTRACK_HEADER_ENABLED, &cVar);
+        rv = Preferences::GetBool(DONOTTRACK_HEADER_ENABLED, &cVar);
         if (NS_SUCCEEDED(rv)) {
             mDoNotTrackEnabled = cVar;
         }
     }
     // Hint option
     if (PREF_CHANGED(SAFE_HINT_HEADER_VALUE)) {
         cVar = false;
-        rv = prefs->GetBoolPref(SAFE_HINT_HEADER_VALUE, &cVar);
+        rv = Preferences::GetBool(SAFE_HINT_HEADER_VALUE, &cVar);
         if (NS_SUCCEEDED(rv)) {
             mSafeHintEnabled = cVar;
         }
     }
 
     // toggle to true anytime a token bucket related pref is changed.. that
     // includes telemetry and allow-experiments because of the abtest profile
     bool requestTokenBucketUpdated = false;
 
     //
     // Telemetry
     //
 
     if (PREF_CHANGED(TELEMETRY_ENABLED)) {
         cVar = false;
         requestTokenBucketUpdated = true;
-        rv = prefs->GetBoolPref(TELEMETRY_ENABLED, &cVar);
+        rv = Preferences::GetBool(TELEMETRY_ENABLED, &cVar);
         if (NS_SUCCEEDED(rv)) {
             mTelemetryEnabled = cVar;
         }
     }
 
     // "security.ssl3.ecdhe_rsa_aes_128_gcm_sha256" is the required h2 interop
     // suite.
 
     if (PREF_CHANGED(H2MANDATORY_SUITE)) {
         cVar = false;
-        rv = prefs->GetBoolPref(H2MANDATORY_SUITE, &cVar);
+        rv = Preferences::GetBool(H2MANDATORY_SUITE, &cVar);
         if (NS_SUCCEEDED(rv)) {
             mH2MandatorySuiteEnabled = cVar;
         }
     }
 
     //
     // network.allow-experiments
     //
     if (PREF_CHANGED(ALLOW_EXPERIMENTS)) {
         cVar = true;
         requestTokenBucketUpdated = true;
-        rv = prefs->GetBoolPref(ALLOW_EXPERIMENTS, &cVar);
+        rv = Preferences::GetBool(ALLOW_EXPERIMENTS, &cVar);
         if (NS_SUCCEEDED(rv)) {
             mAllowExperiments = cVar;
         }
     }
 
     // network.http.debug-observations
     if (PREF_CHANGED("network.http.debug-observations")) {
         cVar = false;
-        rv = prefs->GetBoolPref("network.http.debug-observations", &cVar);
+        rv = Preferences::GetBool("network.http.debug-observations", &cVar);
         if (NS_SUCCEEDED(rv)) {
             mDebugObservations = cVar;
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("pacing.requests.enabled"))) {
-        rv = prefs->GetBoolPref(HTTP_PREF("pacing.requests.enabled"), &cVar);
+        rv = Preferences::GetBool(HTTP_PREF("pacing.requests.enabled"), &cVar);
         if (NS_SUCCEEDED(rv)) {
             mRequestTokenBucketEnabled = cVar;
             requestTokenBucketUpdated = true;
         }
     }
     if (PREF_CHANGED(HTTP_PREF("pacing.requests.min-parallelism"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("pacing.requests.min-parallelism"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("pacing.requests.min-parallelism"), &val);
         if (NS_SUCCEEDED(rv)) {
             mRequestTokenBucketMinParallelism = static_cast<uint16_t>(clamped(val, 1, 1024));
             requestTokenBucketUpdated = true;
         }
     }
     if (PREF_CHANGED(HTTP_PREF("pacing.requests.hz"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("pacing.requests.hz"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("pacing.requests.hz"), &val);
         if (NS_SUCCEEDED(rv)) {
             mRequestTokenBucketHz = static_cast<uint32_t>(clamped(val, 1, 10000));
             requestTokenBucketUpdated = true;
         }
     }
     if (PREF_CHANGED(HTTP_PREF("pacing.requests.burst"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("pacing.requests.burst"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("pacing.requests.burst"), &val);
         if (NS_SUCCEEDED(rv)) {
             mRequestTokenBucketBurst = val ? val : 1;
             requestTokenBucketUpdated = true;
         }
     }
     if (requestTokenBucketUpdated) {
         MakeNewRequestTokenBucket();
     }
 
     // Keepalive values for initial and idle connections.
     if (PREF_CHANGED(HTTP_PREF("tcp_keepalive.short_lived_connections"))) {
-        rv = prefs->GetBoolPref(
+        rv = Preferences::GetBool(
             HTTP_PREF("tcp_keepalive.short_lived_connections"), &cVar);
         if (NS_SUCCEEDED(rv) && cVar != mTCPKeepaliveShortLivedEnabled) {
             mTCPKeepaliveShortLivedEnabled = cVar;
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("tcp_keepalive.short_lived_time"))) {
-        rv = prefs->GetIntPref(
+        rv = Preferences::GetInt(
             HTTP_PREF("tcp_keepalive.short_lived_time"), &val);
         if (NS_SUCCEEDED(rv) && val > 0)
             mTCPKeepaliveShortLivedTimeS = clamped(val, 1, 300); // Max 5 mins.
     }
 
     if (PREF_CHANGED(HTTP_PREF("tcp_keepalive.short_lived_idle_time"))) {
-        rv = prefs->GetIntPref(
+        rv = Preferences::GetInt(
             HTTP_PREF("tcp_keepalive.short_lived_idle_time"), &val);
         if (NS_SUCCEEDED(rv) && val > 0)
             mTCPKeepaliveShortLivedIdleTimeS = clamped(val,
                                                        1, kMaxTCPKeepIdle);
     }
 
     // Keepalive values for Long-lived Connections.
     if (PREF_CHANGED(HTTP_PREF("tcp_keepalive.long_lived_connections"))) {
-        rv = prefs->GetBoolPref(
+        rv = Preferences::GetBool(
             HTTP_PREF("tcp_keepalive.long_lived_connections"), &cVar);
         if (NS_SUCCEEDED(rv) && cVar != mTCPKeepaliveLongLivedEnabled) {
             mTCPKeepaliveLongLivedEnabled = cVar;
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("tcp_keepalive.long_lived_idle_time"))) {
-        rv = prefs->GetIntPref(
+        rv = Preferences::GetInt(
             HTTP_PREF("tcp_keepalive.long_lived_idle_time"), &val);
         if (NS_SUCCEEDED(rv) && val > 0)
             mTCPKeepaliveLongLivedIdleTimeS = clamped(val,
                                                       1, kMaxTCPKeepIdle);
     }
 
     if (PREF_CHANGED(HTTP_PREF("enforce-framing.http1")) ||
         PREF_CHANGED(HTTP_PREF("enforce-framing.soft")) ) {
-        rv = prefs->GetBoolPref(HTTP_PREF("enforce-framing.http1"), &cVar);
+        rv = Preferences::GetBool(HTTP_PREF("enforce-framing.http1"), &cVar);
         if (NS_SUCCEEDED(rv) && cVar) {
             mEnforceH1Framing = FRAMECHECK_STRICT;
         } else {
-            rv = prefs->GetBoolPref(HTTP_PREF("enforce-framing.soft"), &cVar);
+            rv = Preferences::GetBool(HTTP_PREF("enforce-framing.soft"), &cVar);
             if (NS_SUCCEEDED(rv) && cVar) {
                 mEnforceH1Framing = FRAMECHECK_BARELY;
             } else {
                 mEnforceH1Framing = FRAMECHECK_LAX;
             }
         }
     }
 
     if (PREF_CHANGED(TCP_FAST_OPEN_ENABLE)) {
-        rv = prefs->GetBoolPref(TCP_FAST_OPEN_ENABLE, &cVar);
+        rv = Preferences::GetBool(TCP_FAST_OPEN_ENABLE, &cVar);
         if (NS_SUCCEEDED(rv)) {
             mUseFastOpen = cVar;
         }
     }
 
     if (PREF_CHANGED(TCP_FAST_OPEN_FAILURE_LIMIT)) {
-        rv = prefs->GetIntPref(TCP_FAST_OPEN_FAILURE_LIMIT, &val);
+        rv = Preferences::GetInt(TCP_FAST_OPEN_FAILURE_LIMIT, &val);
         if (NS_SUCCEEDED(rv)) {
             if (val < 0) {
                 val = 0;
             }
             mFastOpenConsecutiveFailureLimit = val;
         }
     }
 
     if (PREF_CHANGED(TCP_FAST_OPEN_STALLS_LIMIT)) {
-        rv = prefs->GetIntPref(TCP_FAST_OPEN_STALLS_LIMIT, &val);
+        rv = Preferences::GetInt(TCP_FAST_OPEN_STALLS_LIMIT, &val);
         if (NS_SUCCEEDED(rv)) {
             if (val < 0) {
                 val = 0;
             }
             mFastOpenStallsLimit = val;
         }
     }
 
     if (PREF_CHANGED(TCP_FAST_OPEN_STALLS_TIMEOUT)) {
-        rv = prefs->GetIntPref(TCP_FAST_OPEN_STALLS_TIMEOUT, &val);
+        rv = Preferences::GetInt(TCP_FAST_OPEN_STALLS_TIMEOUT, &val);
         if (NS_SUCCEEDED(rv)) {
             if (val < 0) {
                 val = 0;
             }
             mFastOpenStallsTimeout = val;
         }
     }
 
     if (PREF_CHANGED(TCP_FAST_OPEN_STALLS_IDLE)) {
-        rv = prefs->GetIntPref(TCP_FAST_OPEN_STALLS_IDLE, &val);
+        rv = Preferences::GetInt(TCP_FAST_OPEN_STALLS_IDLE, &val);
         if (NS_SUCCEEDED(rv)) {
             if (val < 0) {
                 val = 0;
             }
             mFastOpenStallsIdleTime = val;
         }
     }
 
     if (PREF_CHANGED(HTTP_PREF("spdy.hpack-default-buffer"))) {
-        rv = prefs->GetIntPref(HTTP_PREF("spdy.default-hpack-buffer"), &val);
+        rv = Preferences::GetInt(HTTP_PREF("spdy.default-hpack-buffer"), &val);
         if (NS_SUCCEEDED(rv)) {
             mDefaultHpackBuffer = val;
         }
     }
 
     // Enable HTTP response timeout if TCP Keepalives are disabled.
     mResponseTimeoutEnabled = !mTCPKeepaliveShortLivedEnabled &&
                               !mTCPKeepaliveLongLivedEnabled;
@@ -2296,22 +2300,18 @@ NS_IMETHODIMP
 nsHttpHandler::Observe(nsISupports *subject,
                        const char *topic,
                        const char16_t *data)
 {
     MOZ_ASSERT(NS_IsMainThread());
     LOG(("nsHttpHandler::Observe [topic=\"%s\"]\n", topic));
 
     nsresult rv;
-    if (!strcmp(topic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
-        nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(subject);
-        if (prefBranch)
-            PrefsChanged(prefBranch, NS_ConvertUTF16toUTF8(data).get());
-    } else if (!strcmp(topic, "profile-change-net-teardown") ||
-               !strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) ) {
+    if (!strcmp(topic, "profile-change-net-teardown") ||
+        !strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) ) {
 
         mHandlerActive = false;
 
         // clear cache of all authentication credentials.
         Unused << mAuthCache.ClearAll();
         Unused << mPrivateAuthCache.ClearAll();
         if (mWifiTickler)
             mWifiTickler->Cancel();
--- a/netwerk/protocol/http/nsHttpHandler.h
+++ b/netwerk/protocol/http/nsHttpHandler.h
@@ -429,17 +429,17 @@ private:
 
     MOZ_MUST_USE nsresult Init();
 
     //
     // Useragent/prefs helper methods
     //
     void     BuildUserAgent();
     void     InitUserAgentComponents();
-    void     PrefsChanged(nsIPrefBranch *prefs, const char *pref);
+    void     PrefsChanged(const char *pref);
 
     MOZ_MUST_USE nsresult SetAccept(const char *);
     MOZ_MUST_USE nsresult SetAcceptLanguages();
     MOZ_MUST_USE nsresult SetAcceptEncodings(const char *, bool mIsSecure);
 
     MOZ_MUST_USE nsresult InitConnectionMgr();
 
     void     NotifyObservers(nsIHttpChannel *chan, const char *event);