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

Side by Side Diff: chrome/browser/profiles/net_http_session_params_observer.cc

Issue 2546533003: Respect QuicAllowed policy for new streams (Closed)
Patch Set: Move ApplySettingsOnIOThread out of NetHttpSessionParamsObserver Created 3 years, 11 months 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.
mmenke 2017/01/09 16:46:04 2017, new files should not use the (c).
pmarko 2017/01/09 19:53:12 Done.
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/profiles/net_http_session_params_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/browser/profiles/profile_manager.h"
13 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
14 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/pref_names.h"
16 #include "components/pref_registry/pref_registry_syncable.h"
17 #include "components/prefs/pref_service.h"
18 #include "content/public/browser/browser_thread.h"
19
20 #include "net/http/http_network_session.h"
mmenke 2017/01/09 16:46:04 Not needed - included in header
pmarko 2017/01/09 19:53:12 Done.
21
22 using content::BrowserThread;
23
24 namespace {
25
26 void ApplySettingsOnIOThread(
27 net::HttpNetworkSession::ParamsUpdate params_update,
28 NetHttpSessionParamsObserver::UpdateNetParamsCallback callback,
29 IOThread* io_thread,
30 bool quic_allowed_for_profile) {
31 DCHECK_CURRENTLY_ON(BrowserThread::IO);
32
33 // Never re-enable QUIC if it was disallowed on startup, e.g. due to command
34 // line flags.
35 bool quic_allowed_on_startup = io_thread->NetworkSessionParams().enable_quic;
mmenke 2017/01/09 16:46:04 This isn't actually whether quic was allowed on st
pmarko 2017/01/09 19:53:12 You're right about that. See my answer on the comm
36 if (!quic_allowed_on_startup)
mmenke 2017/01/09 16:46:04 This is weird - if quic_allowed_on_startup is fals
pmarko 2017/01/09 19:53:12 You're right, we should always send out an update,
37 return;
mmenke 2017/01/09 16:46:04 Hrm...Sorry I missed this when making my earlier s
pmarko 2017/01/09 19:53:12 Oh you're right, I also missed that. Probably that
38
39 // Make the profile adhere to its current setting by invoking its callback.
40 callback.Run(params_update);
41
42 // Globally-owned HttpNetworkSessions should only be updated if QUIC is being
43 // turned off. This "kill switch"-like behavior prevents multiple Profiles
44 // fighting over QUIC enablement for global HttpNetworkSessions.
45 if (!quic_allowed_for_profile)
46 io_thread->UpdateNetworkSessionParams(params_update);
mmenke 2017/01/09 16:46:04 I wonder if we could simplify this method to somet
pmarko 2017/01/09 19:53:12 As discussed, simplified to sending out DisableQui
47 }
48
49 } // namespace
50
51 NetHttpSessionParamsObserver::NetHttpSessionParamsObserver(
52 PrefService* prefs,
53 UpdateNetParamsCallback update_net_params_callback)
54 : update_net_params_callback_(update_net_params_callback) {
55 DCHECK_CURRENTLY_ON(BrowserThread::UI);
56 DCHECK(prefs);
57
58 base::Closure prefs_callback = base::Bind(
59 &NetHttpSessionParamsObserver::ApplySettings, base::Unretained(this));
60 quic_allowed_.Init(prefs::kQuicAllowed, prefs, prefs_callback);
61
62 ApplySettings();
63 }
64
65 NetHttpSessionParamsObserver::~NetHttpSessionParamsObserver() {
66 DCHECK_CURRENTLY_ON(BrowserThread::UI);
67 }
68
69 void NetHttpSessionParamsObserver::ApplySettings() {
70 DCHECK_CURRENTLY_ON(BrowserThread::UI);
71
72 IOThread* io_thread = g_browser_process->io_thread();
73 if (!io_thread)
74 return;
75
76 bool quic_allowed_for_profile = true;
77 if (quic_allowed_.IsManaged())
78 quic_allowed_for_profile = *quic_allowed_;
79
80 net::HttpNetworkSession::ParamsUpdate params_update;
mmenke 2017/01/09 16:46:04 We're not setting params_update.quic_allowed. Hav
mmenke 2017/01/09 17:42:47 Oops, missed that we are, but we're just setting i
pmarko 2017/01/09 19:53:12 Actually, it is setting params_update.enable_quic_
pmarko 2017/01/09 19:53:12 As discussed, removing ParamsUpdate and just calli
81 params_update.enable_quic_new = quic_allowed_for_profile;
82
83 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
84 base::Bind(ApplySettingsOnIOThread, params_update,
85 update_net_params_callback_, io_thread,
86 quic_allowed_for_profile));
87
88 // Globally-owned HttpNetworkSessions should only be updated if QUIC is being
89 // turned off. This "kill switch"-like behavior prevents multiple Profiles
90 // fighting over QUIC enablement for global HttpNetworkSessions.
91 if (!quic_allowed_for_profile && g_browser_process->safe_browsing_service())
92 g_browser_process->safe_browsing_service()->UpdateNetParams(params_update);
93 }
94
95 // static
96 void NetHttpSessionParamsObserver::RegisterProfilePrefs(
97 user_prefs::PrefRegistrySyncable* registry) {
98 registry->RegisterBooleanPref(prefs::kQuicAllowed, true);
99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698