| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_TRACKER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ |
| 6 #define CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ | 6 #define CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 public net::ProxyConfigService::Observer { | 32 public net::ProxyConfigService::Observer { |
| 33 public: | 33 public: |
| 34 // Takes ownership of the passed |base_service|. | 34 // Takes ownership of the passed |base_service|. |
| 35 // GetLatestProxyConfig returns ConfigAvailability::CONFIG_PENDING until | 35 // GetLatestProxyConfig returns ConfigAvailability::CONFIG_PENDING until |
| 36 // UpdateProxyConfig has been called. | 36 // UpdateProxyConfig has been called. |
| 37 explicit ChromeProxyConfigService(net::ProxyConfigService* base_service); | 37 explicit ChromeProxyConfigService(net::ProxyConfigService* base_service); |
| 38 virtual ~ChromeProxyConfigService(); | 38 virtual ~ChromeProxyConfigService(); |
| 39 | 39 |
| 40 // ProxyConfigService implementation: | 40 // ProxyConfigService implementation: |
| 41 virtual void AddObserver( | 41 virtual void AddObserver( |
| 42 net::ProxyConfigService::Observer* observer) OVERRIDE; | 42 net::ProxyConfigService::Observer* observer) override; |
| 43 virtual void RemoveObserver( | 43 virtual void RemoveObserver( |
| 44 net::ProxyConfigService::Observer* observer) OVERRIDE; | 44 net::ProxyConfigService::Observer* observer) override; |
| 45 virtual ConfigAvailability GetLatestProxyConfig( | 45 virtual ConfigAvailability GetLatestProxyConfig( |
| 46 net::ProxyConfig* config) OVERRIDE; | 46 net::ProxyConfig* config) override; |
| 47 virtual void OnLazyPoll() OVERRIDE; | 47 virtual void OnLazyPoll() override; |
| 48 | 48 |
| 49 // Method on IO thread that receives the preference proxy settings pushed from | 49 // Method on IO thread that receives the preference proxy settings pushed from |
| 50 // PrefProxyConfigTrackerImpl. | 50 // PrefProxyConfigTrackerImpl. |
| 51 void UpdateProxyConfig(ProxyPrefs::ConfigState config_state, | 51 void UpdateProxyConfig(ProxyPrefs::ConfigState config_state, |
| 52 const net::ProxyConfig& config); | 52 const net::ProxyConfig& config); |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 // ProxyConfigService::Observer implementation: | 55 // ProxyConfigService::Observer implementation: |
| 56 virtual void OnProxyConfigChanged(const net::ProxyConfig& config, | 56 virtual void OnProxyConfigChanged(const net::ProxyConfig& config, |
| 57 ConfigAvailability availability) OVERRIDE; | 57 ConfigAvailability availability) override; |
| 58 | 58 |
| 59 // Makes sure that the observer registration with the base service is set up. | 59 // Makes sure that the observer registration with the base service is set up. |
| 60 void RegisterObserver(); | 60 void RegisterObserver(); |
| 61 | 61 |
| 62 scoped_ptr<net::ProxyConfigService> base_service_; | 62 scoped_ptr<net::ProxyConfigService> base_service_; |
| 63 ObserverList<net::ProxyConfigService::Observer, true> observers_; | 63 ObserverList<net::ProxyConfigService::Observer, true> observers_; |
| 64 | 64 |
| 65 // Tracks configuration state of |pref_config_|. |pref_config_| is valid only | 65 // Tracks configuration state of |pref_config_|. |pref_config_| is valid only |
| 66 // if |pref_config_state_| is not CONFIG_UNSET. | 66 // if |pref_config_state_| is not CONFIG_UNSET. |
| 67 ProxyPrefs::ConfigState pref_config_state_; | 67 ProxyPrefs::ConfigState pref_config_state_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 82 // A class that tracks proxy preferences. It translates the configuration | 82 // A class that tracks proxy preferences. It translates the configuration |
| 83 // to net::ProxyConfig and pushes the result over to the IO thread for | 83 // to net::ProxyConfig and pushes the result over to the IO thread for |
| 84 // ChromeProxyConfigService::UpdateProxyConfig to use. | 84 // ChromeProxyConfigService::UpdateProxyConfig to use. |
| 85 class PrefProxyConfigTrackerImpl : public PrefProxyConfigTracker { | 85 class PrefProxyConfigTrackerImpl : public PrefProxyConfigTracker { |
| 86 public: | 86 public: |
| 87 explicit PrefProxyConfigTrackerImpl(PrefService* pref_service); | 87 explicit PrefProxyConfigTrackerImpl(PrefService* pref_service); |
| 88 virtual ~PrefProxyConfigTrackerImpl(); | 88 virtual ~PrefProxyConfigTrackerImpl(); |
| 89 | 89 |
| 90 // PrefProxyConfigTracker implementation: | 90 // PrefProxyConfigTracker implementation: |
| 91 virtual scoped_ptr<net::ProxyConfigService> CreateTrackingProxyConfigService( | 91 virtual scoped_ptr<net::ProxyConfigService> CreateTrackingProxyConfigService( |
| 92 scoped_ptr<net::ProxyConfigService> base_service) OVERRIDE; | 92 scoped_ptr<net::ProxyConfigService> base_service) override; |
| 93 | 93 |
| 94 // Notifies the tracker that the pref service passed upon construction is | 94 // Notifies the tracker that the pref service passed upon construction is |
| 95 // about to go away. This must be called from the UI thread. | 95 // about to go away. This must be called from the UI thread. |
| 96 virtual void DetachFromPrefService() OVERRIDE; | 96 virtual void DetachFromPrefService() override; |
| 97 | 97 |
| 98 // Determines if |config_state| takes precedence regardless, which happens if | 98 // Determines if |config_state| takes precedence regardless, which happens if |
| 99 // config is from policy or extension or other-precede. | 99 // config is from policy or extension or other-precede. |
| 100 static bool PrefPrecedes(ProxyPrefs::ConfigState config_state); | 100 static bool PrefPrecedes(ProxyPrefs::ConfigState config_state); |
| 101 | 101 |
| 102 // Determines the proxy configuration that should take effect in the network | 102 // Determines the proxy configuration that should take effect in the network |
| 103 // layer, based on prefs and system configurations. | 103 // layer, based on prefs and system configurations. |
| 104 // |pref_state| refers to state of |pref_config|. | 104 // |pref_state| refers to state of |pref_config|. |
| 105 // |system_availability| refers to availability of |system_config|. | 105 // |system_availability| refers to availability of |system_config|. |
| 106 // |ignore_fallback_config| indicates if fallback config from prefs should | 106 // |ignore_fallback_config| indicates if fallback config from prefs should |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 PrefService* pref_service_; | 160 PrefService* pref_service_; |
| 161 ChromeProxyConfigService* chrome_proxy_config_service_; // Weak ptr. | 161 ChromeProxyConfigService* chrome_proxy_config_service_; // Weak ptr. |
| 162 bool update_pending_; // True if config has not been pushed to network stack. | 162 bool update_pending_; // True if config has not been pushed to network stack. |
| 163 PrefChangeRegistrar proxy_prefs_; | 163 PrefChangeRegistrar proxy_prefs_; |
| 164 | 164 |
| 165 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigTrackerImpl); | 165 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigTrackerImpl); |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 #endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ | 168 #endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ |
| OLD | NEW |