| 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 COMPONENTS_PROXY_CONFIG_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ | 5 #ifndef COMPONENTS_PROXY_CONFIG_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ |
| 6 #define COMPONENTS_PROXY_CONFIG_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ | 6 #define COMPONENTS_PROXY_CONFIG_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 // A net::ProxyConfigService implementation that applies preference proxy | 31 // A net::ProxyConfigService implementation that applies preference proxy |
| 32 // settings (pushed from PrefProxyConfigTrackerImpl) as overrides to the proxy | 32 // settings (pushed from PrefProxyConfigTrackerImpl) as overrides to the proxy |
| 33 // configuration determined by a baseline delegate ProxyConfigService on | 33 // configuration determined by a baseline delegate ProxyConfigService on |
| 34 // non-ChromeOS platforms. ChromeOS has its own implementation of overrides in | 34 // non-ChromeOS platforms. ChromeOS has its own implementation of overrides in |
| 35 // chromeos::ProxyConfigServiceImpl. | 35 // chromeos::ProxyConfigServiceImpl. |
| 36 class ProxyConfigServiceImpl : public net::ProxyConfigService, | 36 class ProxyConfigServiceImpl : public net::ProxyConfigService, |
| 37 public net::ProxyConfigService::Observer { | 37 public net::ProxyConfigService::Observer { |
| 38 public: | 38 public: |
| 39 // Takes ownership of the passed |base_service|. | 39 ProxyConfigServiceImpl(std::unique_ptr<net::ProxyConfigService> base_service, |
| 40 // GetLatestProxyConfig returns ConfigAvailability::CONFIG_PENDING until | 40 ProxyPrefs::ConfigState initial_config_state, |
| 41 // UpdateProxyConfig has been called. | 41 const net::ProxyConfig& initial_config); |
| 42 explicit ProxyConfigServiceImpl(net::ProxyConfigService* base_service); | |
| 43 ~ProxyConfigServiceImpl() override; | 42 ~ProxyConfigServiceImpl() override; |
| 44 | 43 |
| 45 // ProxyConfigService implementation: | 44 // ProxyConfigService implementation: |
| 46 void AddObserver(net::ProxyConfigService::Observer* observer) override; | 45 void AddObserver(net::ProxyConfigService::Observer* observer) override; |
| 47 void RemoveObserver(net::ProxyConfigService::Observer* observer) override; | 46 void RemoveObserver(net::ProxyConfigService::Observer* observer) override; |
| 48 ConfigAvailability GetLatestProxyConfig(net::ProxyConfig* config) override; | 47 ConfigAvailability GetLatestProxyConfig(net::ProxyConfig* config) override; |
| 49 void OnLazyPoll() override; | 48 void OnLazyPoll() override; |
| 50 | 49 |
| 51 // Method on IO thread that receives the preference proxy settings pushed from | 50 // Method on IO thread that receives the preference proxy settings pushed from |
| 52 // PrefProxyConfigTrackerImpl. | 51 // PrefProxyConfigTrackerImpl. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 64 std::unique_ptr<net::ProxyConfigService> base_service_; | 63 std::unique_ptr<net::ProxyConfigService> base_service_; |
| 65 base::ObserverList<net::ProxyConfigService::Observer, true> observers_; | 64 base::ObserverList<net::ProxyConfigService::Observer, true> observers_; |
| 66 | 65 |
| 67 // Tracks configuration state of |pref_config_|. |pref_config_| is valid only | 66 // Tracks configuration state of |pref_config_|. |pref_config_| is valid only |
| 68 // if |pref_config_state_| is not CONFIG_UNSET. | 67 // if |pref_config_state_| is not CONFIG_UNSET. |
| 69 ProxyPrefs::ConfigState pref_config_state_; | 68 ProxyPrefs::ConfigState pref_config_state_; |
| 70 | 69 |
| 71 // Configuration as defined by prefs. | 70 // Configuration as defined by prefs. |
| 72 net::ProxyConfig pref_config_; | 71 net::ProxyConfig pref_config_; |
| 73 | 72 |
| 74 // Flag that indicates that a PrefProxyConfigTracker needs to inform us | |
| 75 // about a proxy configuration before we may return any configuration. | |
| 76 bool pref_config_read_pending_; | |
| 77 | |
| 78 // Indicates whether the base service registration is done. | 73 // Indicates whether the base service registration is done. |
| 79 bool registered_observer_; | 74 bool registered_observer_; |
| 80 | 75 |
| 81 base::ThreadChecker thread_checker_; | 76 base::ThreadChecker thread_checker_; |
| 82 | 77 |
| 83 DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceImpl); | 78 DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceImpl); |
| 84 }; | 79 }; |
| 85 | 80 |
| 86 // A class that tracks proxy preferences. It translates the configuration | 81 // A class that tracks proxy preferences. It translates the configuration |
| 87 // to net::ProxyConfig and pushes the result over to the IO thread for | 82 // to net::ProxyConfig and pushes the result over to the IO thread for |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 PrefChangeRegistrar proxy_prefs_; | 165 PrefChangeRegistrar proxy_prefs_; |
| 171 | 166 |
| 172 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 167 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 173 | 168 |
| 174 base::ThreadChecker thread_checker_; | 169 base::ThreadChecker thread_checker_; |
| 175 | 170 |
| 176 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigTrackerImpl); | 171 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigTrackerImpl); |
| 177 }; | 172 }; |
| 178 | 173 |
| 179 #endif // COMPONENTS_PROXY_CONFIG_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ | 174 #endif // COMPONENTS_PROXY_CONFIG_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ |
| OLD | NEW |