From 16a5162579973364b3edeb4f17d798ce2c3efbda Mon Sep 17 00:00:00 2001
From: Dragana Damjanovic
Date: Fri, 1 Nov 2019 14:55:55 +0000
Subject: [PATCH] Bug 1581637 - Part 5 - Add Http3 prefs. r=mayhemer
Differential Revision: https://phabricator.services.mozilla.com/D46651
--HG--
extra : moz-landing-system : lando
---
mobile/android/app/mobile.js | 3 +++
modules/libpref/init/all.js | 8 ++++++++
netwerk/protocol/http/nsHttpHandler.cpp | 25 +++++++++++++++++++++++++
netwerk/protocol/http/nsHttpHandler.h | 13 +++++++++++++
4 files changed, 49 insertions(+)
diff --git a/mobile/android/app/mobile.js b/mobile/android/app/mobile.js
index 5ffd252a430d..162ad1d59536 100644
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -98,6 +98,9 @@ pref("network.http.max-persistent-connections-per-proxy", 20);
pref("network.http.spdy.push-allowance", 32768);
pref("network.http.spdy.default-hpack-buffer", 4096); // 4k
+// http3
+pref("network.http.http3.default-qpack-table-size", 4096); // 4k
+
// See bug 545869 for details on why these are set the way they are
pref("network.buffer.cache.count", 24);
pref("network.buffer.cache.size", 16384);
diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
index 6c74a3893cbb..833109d14e56 100644
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1406,6 +1406,14 @@ pref("network.http.spdy.default-hpack-buffer", 65536); // 64k
pref("network.http.spdy.websockets", true);
pref("network.http.spdy.enable-hpack-dump", false);
+// Http3 parameters
+pref("network.http.http3.enabled", false);
+// Http3 qpack table size.
+pref("network.http.http3.default-qpack-table-size", 65536); // 64k
+// Maximal number of streams that can be blocked on waiting for qpack
+// instructions.
+pref("network.http.http3.default-max-stream-blocked", 10);
+
// alt-svc allows separation of transport routing from
// the origin host without using a proxy.
pref("network.http.altsvc.enabled", true);
diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp
index d906dfc28de7..b4f052e6efc8 100644
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -280,6 +280,9 @@ nsHttpHandler::nsHttpHandler()
mBug1563538(true),
mBug1563695(true),
mBug1556491(true),
+ mHttp3Enabled(true),
+ mQpackTableSize(4096),
+ mHttp3MaxBlockedStreams(10),
mMaxHttpResponseHeaderSize(393216),
mFocusedWindowTransactionRatio(0.9f),
mSpeculativeConnectEnabled(false),
@@ -1917,6 +1920,28 @@ void nsHttpHandler::PrefsChanged(const char* pref) {
}
}
+ if (PREF_CHANGED(HTTP_PREF("http3.enabled"))) {
+ rv = Preferences::GetBool(HTTP_PREF("http3.enabled"), &cVar);
+ if (NS_SUCCEEDED(rv)) {
+ mHttp3Enabled = cVar;
+ }
+ }
+
+ if (PREF_CHANGED(HTTP_PREF("http3.default-qpack-table-size"))) {
+ rv = Preferences::GetInt(HTTP_PREF("http3.default-qpack-table-size"), &val);
+ if (NS_SUCCEEDED(rv)) {
+ mQpackTableSize = val;
+ }
+ }
+
+ if (PREF_CHANGED(HTTP_PREF("http3.default-max-stream-blocked"))) {
+ rv = Preferences::GetInt(HTTP_PREF("http3.default-max-stream-blocked"),
+ &val);
+ if (NS_SUCCEEDED(rv)) {
+ mHttp3MaxBlockedStreams = clamped(val, 0, 0xffff);
+ }
+ }
+
// Enable HTTP response timeout if TCP Keepalives are disabled.
mResponseTimeoutEnabled =
!mTCPKeepaliveShortLivedEnabled && !mTCPKeepaliveLongLivedEnabled;
diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h
index f4beab12b12a..c13ccde90c55 100644
--- a/netwerk/protocol/http/nsHttpHandler.h
+++ b/netwerk/protocol/http/nsHttpHandler.h
@@ -439,6 +439,12 @@ class nsHttpHandler final : public nsIHttpProtocolHandler,
bool IsHttp3VersionSupportedHex(const nsACString& version);
nsCString Http3Version() { return kHttp3Version; }
+ bool IsHttp3Enabled() const { return mHttp3Enabled; }
+ uint32_t DefaultQpackTableSize() const { return mQpackTableSize; }
+ uint16_t DefaultHttp3MaxBlockedStreams() const {
+ return (uint16_t)mHttp3MaxBlockedStreams;
+ }
+
uint32_t MaxHttpResponseHeaderSize() const {
return mMaxHttpResponseHeaderSize;
}
@@ -689,6 +695,13 @@ class nsHttpHandler final : public nsIHttpProtocolHandler,
Atomic mBug1563695;
Atomic mBug1556491;
+ Atomic mHttp3Enabled;
+ // Http3 parameters
+ Atomic mQpackTableSize;
+ Atomic
+ mHttp3MaxBlockedStreams; // uint16_t is enough here, but Atomic only
+ // supports uint32_t or uint64_t.
+
// The max size (in bytes) for received Http response header.
uint32_t mMaxHttpResponseHeaderSize;