Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: chrome/browser/net/net_pref_observer.cc

Issue 2546533003: Respect QuicAllowed policy for new streams (Closed)
Patch Set: Improve enable_quic_for_new_streams comment Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/net_pref_observer.cc
diff --git a/chrome/browser/net/net_pref_observer.cc b/chrome/browser/net/net_pref_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..97c79b2c2f072e037ffb657fddaf8f1f96c3f72a
--- /dev/null
+++ b/chrome/browser/net/net_pref_observer.cc
@@ -0,0 +1,68 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/net/net_pref_observer.h"
+
+#include "base/bind.h"
+#include "base/logging.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/io_thread.h"
+#include "chrome/common/pref_names.h"
+#include "components/pref_registry/pref_registry_syncable.h"
+#include "components/prefs/pref_service.h"
+#include "content/public/browser/browser_thread.h"
+#include "net/http/http_network_session.h"
+
+using content::BrowserThread;
+
+namespace {
+
+void SetQuicAllowedOnIOThread(IOThread* io_thread, bool quic_allowed) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ net::HttpNetworkSession::SharedParams* shared_params =
+ io_thread->globals()->http_network_session_shared_params.get();
+
+ shared_params->enable_quic_for_new_streams = quic_allowed;
+}
+
+} // namespace
+
+NetPrefObserver::NetPrefObserver(PrefService* prefs) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(prefs);
+
+ base::Closure prefs_callback =
+ base::Bind(&NetPrefObserver::ApplySettings, base::Unretained(this));
+ quic_allowed_.Init(prefs::kQuicAllowed, prefs, prefs_callback);
+
+ ApplySettings();
+}
+
+NetPrefObserver::~NetPrefObserver() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+}
+
+void NetPrefObserver::ApplySettings() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ IOThread* io_thread = g_browser_process->io_thread();
+ if (!io_thread)
+ return;
+
+ bool quic_allowed = true;
+ if (quic_allowed_.IsManaged()) {
+ quic_allowed = *quic_allowed_;
+ }
+
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(SetQuicAllowedOnIOThread, io_thread, quic_allowed));
+}
+
+// static
+void NetPrefObserver::RegisterProfilePrefs(
+ user_prefs::PrefRegistrySyncable* registry) {
+ registry->RegisterBooleanPref(prefs::kQuicAllowed, true);
+}

Powered by Google App Engine
This is Rietveld 408576698