OLD | NEW |
---|---|
(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/command_line.h" | |
9 #include "base/logging.h" | |
10 #include "chrome/browser/browser_process.h" | |
11 #include "chrome/browser/io_thread.h" | |
12 #include "chrome/common/chrome_switches.h" | |
13 #include "chrome/common/pref_names.h" | |
14 #include "components/network_session_configurator/network_session_configurator.h " | |
15 #include "components/pref_registry/pref_registry_syncable.h" | |
16 #include "components/prefs/pref_service.h" | |
17 #include "content/public/browser/browser_thread.h" | |
18 | |
19 #include "net/http/http_network_session.h" | |
20 | |
21 using content::BrowserThread; | |
22 | |
23 namespace { | |
24 | |
25 void SetQuicEnabledOnIOThread(IOThread* io_thread, | |
26 bool quic_allowed_by_policy) { | |
27 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
28 | |
29 net::HttpNetworkSession::DynamicSharedParams* dynamic_shared_params = | |
30 io_thread->globals()->http_network_session_dynamic_shared_params.get(); | |
31 | |
32 // If QUIC has already been disabled, don't re-enable it. Currently, | |
33 // re-enabling QUIC requires a restart. If we want to support re-enabling QUIC | |
34 // dynamically, it would either have to be per-profile, or we'd have to | |
35 // enable it only if all active profiles allow QUIC. | |
36 // We'd also need to evaluated command-line switches::kDisableQuic here. | |
Bence
2016/12/20 14:58:07
s/evaluated/evaluate/
pmarko
2016/12/20 18:00:37
Done.
| |
37 dynamic_shared_params->enable_quic &= quic_allowed_by_policy; | |
38 } | |
39 | |
40 } // namespace | |
41 | |
42 NetPrefObserver::NetPrefObserver(PrefService* prefs) { | |
43 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
44 DCHECK(prefs); | |
45 | |
46 base::Closure prefs_callback = | |
47 base::Bind(&NetPrefObserver::ApplySettings, base::Unretained(this)); | |
48 quic_allowed_.Init(prefs::kQuicAllowed, prefs, prefs_callback); | |
49 | |
50 ApplySettings(); | |
51 } | |
52 | |
53 NetPrefObserver::~NetPrefObserver() { | |
54 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
55 } | |
56 | |
57 void NetPrefObserver::ApplySettings() { | |
58 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
59 | |
60 IOThread* io_thread = g_browser_process->io_thread(); | |
61 if (!io_thread) | |
62 return; | |
63 | |
64 bool quic_allowed_by_policy = true; | |
65 if (quic_allowed_.IsManaged()) { | |
66 quic_allowed_by_policy = *quic_allowed_; | |
67 } | |
68 | |
69 BrowserThread::PostTask( | |
70 BrowserThread::IO, FROM_HERE, | |
71 base::Bind(SetQuicEnabledOnIOThread, io_thread, quic_allowed_by_policy)); | |
72 } | |
73 | |
74 // static | |
75 void NetPrefObserver::RegisterProfilePrefs( | |
76 user_prefs::PrefRegistrySyncable* registry) { | |
77 registry->RegisterBooleanPref(prefs::kQuicAllowed, true); | |
78 } | |
OLD | NEW |