OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ |
6 #define CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ | 6 #define CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // Configuration is known to be not set. | 42 // Configuration is known to be not set. |
43 CONFIG_UNSET, | 43 CONFIG_UNSET, |
44 }; | 44 }; |
45 | 45 |
46 explicit PrefProxyConfigTracker(PrefService* pref_service); | 46 explicit PrefProxyConfigTracker(PrefService* pref_service); |
47 | 47 |
48 // Observer manipulation is only valid on the IO thread. | 48 // Observer manipulation is only valid on the IO thread. |
49 void AddObserver(Observer* observer); | 49 void AddObserver(Observer* observer); |
50 void RemoveObserver(Observer* observer); | 50 void RemoveObserver(Observer* observer); |
51 | 51 |
52 // Get the proxy configuration currently defined by preferences. Status is | 52 // Get the proxy configuration currently defined by preferences on the IO |
53 // indicated in the return value. Writes the configuration to |config| unless | 53 // and UI threads respectively. Status is indicated in the return value. |
54 // the return value is CONFIG_UNSET, in which case |config| is not touched. | 54 // Writes the configuration to |config| unless the return value is |
55 ConfigState GetProxyConfig(net::ProxyConfig* config); | 55 // CONFIG_UNSET, in which case |config| is not touched. |
| 56 ConfigState IOGetProxyConfig(net::ProxyConfig* config); |
| 57 ConfigState UIGetProxyConfig(net::ProxyConfig* config); |
56 | 58 |
57 // Notifies the tracker that the pref service passed upon construction is | 59 // Notifies the tracker that the pref service passed upon construction is |
58 // about to go away. This must be called from the UI thread. | 60 // about to go away. This must be called from the UI thread. |
59 void DetachFromPrefService(); | 61 void DetachFromPrefService(); |
60 | 62 |
61 private: | 63 private: |
62 friend class base::RefCountedThreadSafe<PrefProxyConfigTracker>; | 64 friend class base::RefCountedThreadSafe<PrefProxyConfigTracker>; |
63 virtual ~PrefProxyConfigTracker(); | 65 virtual ~PrefProxyConfigTracker(); |
64 | 66 |
65 // NotificationObserver implementation: | 67 // NotificationObserver implementation: |
(...skipping 11 matching lines...) Expand all Loading... |
77 // Creates a proxy configuration from proxy-related preferences. Configuration | 79 // Creates a proxy configuration from proxy-related preferences. Configuration |
78 // is stored in |config| and the return value indicates whether the | 80 // is stored in |config| and the return value indicates whether the |
79 // configuration is valid. | 81 // configuration is valid. |
80 ConfigState ReadPrefConfig(net::ProxyConfig* config); | 82 ConfigState ReadPrefConfig(net::ProxyConfig* config); |
81 | 83 |
82 // Converts a ProxyConfigDictionary to net::ProxyConfig representation. | 84 // Converts a ProxyConfigDictionary to net::ProxyConfig representation. |
83 // Returns true if the data from in the dictionary is valid, false otherwise. | 85 // Returns true if the data from in the dictionary is valid, false otherwise. |
84 static bool PrefConfigToNetConfig(const ProxyConfigDictionary& proxy_dict, | 86 static bool PrefConfigToNetConfig(const ProxyConfigDictionary& proxy_dict, |
85 net::ProxyConfig* config); | 87 net::ProxyConfig* config); |
86 | 88 |
| 89 // Configuration as defined by prefs. Only to be accessed from the UI thread. |
| 90 net::ProxyConfig ui_pref_config_; |
| 91 |
| 92 // Tracks configuration state. |ui_pref_config_| is valid only if |
| 93 // |ui_config_state_| is not CONFIG_UNSET. |
| 94 ConfigState ui_config_state_; |
| 95 |
87 // Configuration as defined by prefs. Only to be accessed from the IO thread | 96 // Configuration as defined by prefs. Only to be accessed from the IO thread |
88 // (except for construction). | 97 // (except for construction). |
89 net::ProxyConfig pref_config_; | 98 net::ProxyConfig io_pref_config_; |
90 | 99 |
91 // Tracks configuration state. |pref_config_| is valid only if |config_state_| | 100 // Tracks configuration state. |io_pref_config_| is valid only if |
92 // is not CONFIG_UNSET. | 101 // |io_config_state_| is not CONFIG_UNSET. |
93 ConfigState config_state_; | 102 ConfigState io_config_state_; |
94 | 103 |
95 // List of observers, accessed exclusively from the IO thread. | 104 // List of observers, accessed exclusively from the IO thread. |
96 ObserverList<Observer, true> observers_; | 105 ObserverList<Observer, true> observers_; |
97 | 106 |
98 // Pref-related members that should only be accessed from the UI thread. | 107 // Pref-related members that should only be accessed from the UI thread. |
99 PrefService* pref_service_; | 108 PrefService* pref_service_; |
100 scoped_ptr<PrefSetObserver> proxy_prefs_observer_; | 109 scoped_ptr<PrefSetObserver> proxy_prefs_observer_; |
101 | 110 |
102 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigTracker); | 111 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigTracker); |
103 }; | 112 }; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 ObserverList<net::ProxyConfigService::Observer, true> observers_; | 148 ObserverList<net::ProxyConfigService::Observer, true> observers_; |
140 scoped_refptr<PrefProxyConfigTracker> pref_config_tracker_; | 149 scoped_refptr<PrefProxyConfigTracker> pref_config_tracker_; |
141 | 150 |
142 // Indicates whether the base service and tracker registrations are done. | 151 // Indicates whether the base service and tracker registrations are done. |
143 bool registered_observers_; | 152 bool registered_observers_; |
144 | 153 |
145 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigService); | 154 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigService); |
146 }; | 155 }; |
147 | 156 |
148 #endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ | 157 #endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ |
OLD | NEW |