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

Side by Side Diff: chrome/browser/net/net_pref_observer.cc

Issue 2546533003: Respect QuicAllowed policy for new streams (Closed)
Patch Set: Naming, formatting 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/net/net_pref_observer.h"
6
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/io_thread.h"
11 #include "chrome/common/pref_names.h"
12 #include "components/pref_registry/pref_registry_syncable.h"
13 #include "components/prefs/pref_service.h"
14 #include "content/public/browser/browser_thread.h"
15 #include "net/http/http_network_session.h"
16
17 using content::BrowserThread;
18
19 namespace {
20
21 void SetQuicAllowedOnIOThread(IOThread* io_thread, bool quic_allowed) {
22 DCHECK_CURRENTLY_ON(BrowserThread::IO);
23
24 net::HttpNetworkSession::DynamicSharedParams* dynamic_shared_params =
25 io_thread->globals()->http_network_session_dynamic_shared_params.get();
26
27 dynamic_shared_params->enable_quic_for_new_streams = quic_allowed;
28 }
29
30 } // namespace
31
32 NetPrefObserver::NetPrefObserver(PrefService* prefs) {
33 DCHECK_CURRENTLY_ON(BrowserThread::UI);
34 DCHECK(prefs);
35
36 base::Closure prefs_callback =
37 base::Bind(&NetPrefObserver::ApplySettings, base::Unretained(this));
38 quic_allowed_.Init(prefs::kQuicAllowed, prefs, prefs_callback);
39
40 ApplySettings();
41 }
42
43 NetPrefObserver::~NetPrefObserver() {
44 DCHECK_CURRENTLY_ON(BrowserThread::UI);
45 }
46
47 void NetPrefObserver::ApplySettings() {
48 DCHECK_CURRENTLY_ON(BrowserThread::UI);
49
50 IOThread* io_thread = g_browser_process->io_thread();
51 if (!io_thread)
52 return;
53
54 bool quic_allowed = true;
55 if (quic_allowed_.IsManaged()) {
56 quic_allowed = *quic_allowed_;
57 }
58
59 BrowserThread::PostTask(
60 BrowserThread::IO, FROM_HERE,
61 base::Bind(SetQuicAllowedOnIOThread, io_thread, quic_allowed));
62 }
63
64 // static
65 void NetPrefObserver::RegisterProfilePrefs(
66 user_prefs::PrefRegistrySyncable* registry) {
67 registry->RegisterBooleanPref(prefs::kQuicAllowed, true);
68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698