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 #ifndef CHROME_BROWSER_NET_NET_PREF_OBSERVER_H_ | |
| 6 #define CHROME_BROWSER_NET_NET_PREF_OBSERVER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "components/prefs/pref_member.h" | |
| 10 #include "net/http/http_network_session.h" | |
| 11 | |
| 12 class PrefService; | |
| 13 | |
| 14 namespace safe_browsing { | |
| 15 class SafeBrowsingService; | |
| 16 } | |
| 17 | |
| 18 namespace user_prefs { | |
| 19 class PrefRegistrySyncable; | |
| 20 } | |
| 21 | |
| 22 class IOThread; | |
| 23 | |
| 24 // Monitors network-related preferences for changes and applies them to | |
| 25 // globally owned HttpNetworkSessions. | |
| 26 // Profile-owned HttpNetworkSessions are taken care of by a | |
| 27 // UpdateNetParamsCallback passed to the constructor. | |
| 28 // The supplied PrefService must outlive this NetPrefObserver. | |
| 29 // Must be used only on the UI thread. | |
| 30 class NetPrefObserver { | |
|
mmenke
2017/01/06 16:18:43
NetHttpSessionParamsObserver? There are a number
pmarko
2017/01/08 20:51:48
Done.
| |
| 31 public: | |
| 32 // Type of callback which will be called when enablement of QUIC is changed. | |
| 33 // This callback will be called on the IO thread. | |
| 34 typedef base::Callback<void(net::HttpNetworkSession::ParamsUpdate)> | |
| 35 UpdateNetParamsCallback; | |
| 36 | |
| 37 // |prefs| must be non-NULL and |*prefs| must outlive this. | |
| 38 // |update_net_params_callback| will be invoked on the IO thread when an | |
| 39 // observed network parmeter is changed. | |
| 40 NetPrefObserver(PrefService* prefs, | |
| 41 UpdateNetParamsCallback update_net_params_callback); | |
| 42 ~NetPrefObserver(); | |
| 43 | |
| 44 // Register user preferences which NetPrefObserver uses into |registry|. | |
| 45 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | |
| 46 | |
| 47 private: | |
| 48 // Called on UI thread when an observed net pref changes | |
| 49 void ApplySettings(); | |
| 50 | |
| 51 // Called on IO thread from ApplySettings | |
| 52 void ApplySettingsOnIOThread( | |
| 53 IOThread* io_thread, | |
| 54 safe_browsing::SafeBrowsingService* safe_browsing_service, | |
| 55 bool quic_allowed_for_profile); | |
| 56 | |
| 57 BooleanPrefMember quic_allowed_; | |
| 58 UpdateNetParamsCallback update_net_params_callback_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(NetPrefObserver); | |
| 61 }; | |
| 62 | |
| 63 #endif // CHROME_BROWSER_NET_NET_PREF_OBSERVER_H_ | |
| OLD | NEW |