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 | |
11 class PrefService; | |
12 | |
13 namespace user_prefs { | |
14 class PrefRegistrySyncable; | |
15 } | |
16 | |
17 class IOThread; | |
18 | |
19 // Monitors network-related preferences for changes and applies them to | |
20 // globally owned HttpNetworkSessions. | |
21 // Profile-owned HttpNetworkSessions are taken care of by a | |
22 // UpdateNetParamsCallback passed to the constructor. | |
23 // The supplied PrefService must outlive this NetPrefObserver. | |
24 // Must be used only on the UI thread. | |
25 class NetPrefObserver { | |
26 public: | |
27 // Describes what change in terms of net parameters. | |
28 struct NetParamsChange { | |
29 // New value of QUIC enablement. | |
30 bool quic_enabled_new; | |
31 }; | |
32 | |
33 // Type of callback which will be called when enablement of QUIC is changed. | |
34 // This callback will be called on the UI thread. | |
35 typedef base::Callback<void(NetParamsChange)> 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 explicit NetPrefObserver(PrefService* prefs, | |
Bence
2016/12/26 18:47:56
Do not use |explicit|, because constructor takes m
pmarko
2017/01/02 10:33:55
Done.
| |
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(IOThread* io_thread, | |
53 NetParamsChange net_params_change); | |
54 | |
55 BooleanPrefMember quic_allowed_; | |
56 UpdateNetParamsCallback update_net_params_callback_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(NetPrefObserver); | |
59 }; | |
60 | |
61 #endif // CHROME_BROWSER_NET_NET_PREF_OBSERVER_H_ | |
OLD | NEW |