Chromium Code Reviews| 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/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 | |
|
Bence
2016/12/02 18:53:25
Please remove this empty line. (Did you remember
pmarko
2016/12/08 17:01:59
Done.
| |
| 16 #include "net/http/http_network_session.h" | |
| 17 | |
| 18 using content::BrowserThread; | |
| 19 | |
| 20 namespace { | |
| 21 | |
| 22 void SetQuicAllowedOnIOThread(IOThread* io_thread, bool quic_allowed) { | |
| 23 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 24 | |
| 25 net::HttpNetworkSession::SharedParams* shared_params = | |
|
Bence
2016/12/02 18:53:25
Move this line two spaces to the left please.
pmarko
2016/12/08 17:01:59
Done.
| |
| 26 io_thread->globals()->http_network_session_shared_params.get(); | |
| 27 | |
| 28 shared_params->enable_quic_for_new_streams = quic_allowed; | |
|
Bence
2016/12/02 18:53:25
Move this line two spaces to the left please.
pmarko
2016/12/08 17:01:59
Done.
| |
| 29 } | |
| 30 | |
| 31 } // namespace | |
| 32 | |
| 33 NetPrefObserver::NetPrefObserver(PrefService* prefs) { | |
| 34 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 35 DCHECK(prefs); | |
| 36 | |
| 37 base::Closure prefs_callback = base::Bind(&NetPrefObserver::ApplySettings, | |
|
Bence
2016/12/02 18:53:25
Please run git cl format to reformat this line.
pmarko
2016/12/08 17:01:59
Done.
| |
| 38 base::Unretained(this)); | |
| 39 quic_allowed_.Init(prefs::kQuicAllowed, prefs, prefs_callback); | |
| 40 | |
| 41 ApplySettings(); | |
| 42 } | |
| 43 | |
| 44 NetPrefObserver::~NetPrefObserver() { | |
| 45 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 46 } | |
| 47 | |
| 48 void NetPrefObserver::ApplySettings() { | |
| 49 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 50 | |
| 51 IOThread* io_thread = g_browser_process->io_thread(); | |
| 52 if (io_thread) { | |
|
Bence
2016/12/02 18:53:25
Maybe do early return instead?
if (!io_thread) {
pmarko
2016/12/08 17:01:59
Good idea, thanks! Done.
| |
| 53 bool quic_allowed = true; | |
| 54 if (quic_allowed_.IsManaged()) { | |
| 55 quic_allowed = *quic_allowed_; | |
| 56 } | |
| 57 | |
| 58 BrowserThread::PostTask( | |
| 59 BrowserThread::IO, | |
| 60 FROM_HERE, | |
|
Bence
2016/12/02 18:53:25
Merge with previous line.
pmarko
2016/12/08 17:01:59
Done.
| |
| 61 base::Bind(SetQuicAllowedOnIOThread, io_thread, quic_allowed)); | |
| 62 } | |
| 63 } | |
| 64 | |
| 65 // static | |
| 66 void NetPrefObserver::RegisterProfilePrefs( | |
| 67 user_prefs::PrefRegistrySyncable* registry) { | |
| 68 registry->RegisterBooleanPref(prefs::kQuicAllowed, true); | |
| 69 } | |
| OLD | NEW |