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/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 public: | 26 public: |
27 // Observer interface used to send out notifications on the IO thread about | 27 // Observer interface used to send out notifications on the IO thread about |
28 // changes to the proxy configuration. | 28 // changes to the proxy configuration. |
29 class Observer { | 29 class Observer { |
30 public: | 30 public: |
31 virtual ~Observer() {} | 31 virtual ~Observer() {} |
32 virtual void OnPrefProxyConfigChanged() = 0; | 32 virtual void OnPrefProxyConfigChanged() = 0; |
33 }; | 33 }; |
34 | 34 |
35 explicit PrefProxyConfigTracker(PrefService* pref_service); | 35 explicit PrefProxyConfigTracker(PrefService* pref_service); |
36 virtual ~PrefProxyConfigTracker(); | |
37 | 36 |
38 // Observer manipulation is only valid on the IO thread. | 37 // Observer manipulation is only valid on the IO thread. |
39 void AddObserver(Observer* observer); | 38 void AddObserver(Observer* observer); |
40 void RemoveObserver(Observer* observer); | 39 void RemoveObserver(Observer* observer); |
41 | 40 |
42 // Get the proxy configuration currently defined by preferences. Writes the | 41 // Get the proxy configuration currently defined by preferences. Writes the |
43 // configuration to |config| and returns true on success. |config| is not | 42 // configuration to |config| and returns true on success. |config| is not |
44 // touched and false is returned if there is no configuration defined. This | 43 // touched and false is returned if there is no configuration defined. This |
45 // must be called on the IO thread. | 44 // must be called on the IO thread. |
46 bool GetProxyConfig(net::ProxyConfig* config); | 45 bool GetProxyConfig(net::ProxyConfig* config); |
47 | 46 |
48 // Notifies the tracker that the pref service passed upon construction is | 47 // Notifies the tracker that the pref service passed upon construction is |
49 // about to go away. This must be called from the UI thread. | 48 // about to go away. This must be called from the UI thread. |
50 void DetachFromPrefService(); | 49 void DetachFromPrefService(); |
51 | 50 |
52 private: | 51 private: |
| 52 friend class base::RefCountedThreadSafe<PrefProxyConfigTracker>; |
| 53 virtual ~PrefProxyConfigTracker(); |
| 54 |
53 // NotificationObserver implementation: | 55 // NotificationObserver implementation: |
54 virtual void Observe(NotificationType type, | 56 virtual void Observe(NotificationType type, |
55 const NotificationSource& source, | 57 const NotificationSource& source, |
56 const NotificationDetails& details); | 58 const NotificationDetails& details); |
57 | 59 |
58 // Install a new configuration. This is invoked on the IO thread to update | 60 // Install a new configuration. This is invoked on the IO thread to update |
59 // the internal state after handling a pref change on the UI thread. |valid| | 61 // the internal state after handling a pref change on the UI thread. |valid| |
60 // indicates whether there is a preference proxy configuration defined, in | 62 // indicates whether there is a preference proxy configuration defined, in |
61 // which case this configuration is given by |config|. |config| is ignored if | 63 // which case this configuration is given by |config|. |config| is ignored if |
62 // |valid| is false. | 64 // |valid| is false. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 ObserverList<net::ProxyConfigService::Observer, true> observers_; | 122 ObserverList<net::ProxyConfigService::Observer, true> observers_; |
121 scoped_refptr<PrefProxyConfigTracker> pref_config_tracker_; | 123 scoped_refptr<PrefProxyConfigTracker> pref_config_tracker_; |
122 | 124 |
123 // Indicates whether the base service and tracker registrations are done. | 125 // Indicates whether the base service and tracker registrations are done. |
124 bool registered_observers_; | 126 bool registered_observers_; |
125 | 127 |
126 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigService); | 128 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigService); |
127 }; | 129 }; |
128 | 130 |
129 #endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ | 131 #endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_SERVICE_H_ |
OLD | NEW |