Chromium Code Reviews| 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 COMPONENTS_PROXY_CONFIG_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ |
| 6 #define CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ | 6 #define COMPONENTS_PROXY_CONFIG_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" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "base/prefs/pref_change_registrar.h" | 12 #include "base/prefs/pref_change_registrar.h" |
| 13 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 13 #include "base/threading/thread_checker.h" |
| 14 #include "components/proxy_config/pref_proxy_config_tracker.h" | |
| 14 #include "components/proxy_config/proxy_config_dictionary.h" | 15 #include "components/proxy_config/proxy_config_dictionary.h" |
| 15 #include "net/proxy/proxy_config.h" | 16 #include "net/proxy/proxy_config.h" |
| 16 #include "net/proxy/proxy_config_service.h" | 17 #include "net/proxy/proxy_config_service.h" |
| 17 | 18 |
| 18 class PrefService; | 19 class PrefService; |
| 19 class PrefRegistrySimple; | 20 class PrefRegistrySimple; |
| 20 | 21 |
| 22 namespace base { | |
| 23 class SingleThreadTaskRunner; | |
| 24 } | |
| 25 | |
| 21 namespace user_prefs { | 26 namespace user_prefs { |
| 22 class PrefRegistrySyncable; | 27 class PrefRegistrySyncable; |
| 23 } | 28 } |
| 24 | 29 |
| 25 // A net::ProxyConfigService implementation that applies preference proxy | 30 // A net::ProxyConfigService implementation that applies preference proxy |
| 26 // settings (pushed from PrefProxyConfigTrackerImpl) as overrides to the proxy | 31 // settings (pushed from PrefProxyConfigTrackerImpl) as overrides to the proxy |
| 27 // configuration determined by a baseline delegate ProxyConfigService on | 32 // configuration determined by a baseline delegate ProxyConfigService on |
| 28 // non-ChromeOS platforms. ChromeOS has its own implementation of overrides in | 33 // non-ChromeOS platforms. ChromeOS has its own implementation of overrides in |
| 29 // chromeos::ProxyConfigServiceImpl. | 34 // chromeos::ProxyConfigServiceImpl. |
| 30 class ChromeProxyConfigService | 35 class ChromeProxyConfigService : public net::ProxyConfigService, |
|
droger
2015/08/17 13:51:36
This class should probably be renamed, maybe as Pr
Abhishek
2015/08/19 08:30:49
Done.
| |
| 31 : public net::ProxyConfigService, | 36 public net::ProxyConfigService::Observer { |
| 32 public net::ProxyConfigService::Observer { | |
| 33 public: | 37 public: |
| 34 // Takes ownership of the passed |base_service|. | 38 // Takes ownership of the passed |base_service|. |
| 35 // GetLatestProxyConfig returns ConfigAvailability::CONFIG_PENDING until | 39 // GetLatestProxyConfig returns ConfigAvailability::CONFIG_PENDING until |
| 36 // UpdateProxyConfig has been called. | 40 // UpdateProxyConfig has been called. |
| 37 explicit ChromeProxyConfigService(net::ProxyConfigService* base_service); | 41 explicit ChromeProxyConfigService(net::ProxyConfigService* base_service); |
| 38 ~ChromeProxyConfigService() override; | 42 ~ChromeProxyConfigService() override; |
| 39 | 43 |
| 40 // ProxyConfigService implementation: | 44 // ProxyConfigService implementation: |
| 41 void AddObserver(net::ProxyConfigService::Observer* observer) override; | 45 void AddObserver(net::ProxyConfigService::Observer* observer) override; |
| 42 void RemoveObserver(net::ProxyConfigService::Observer* observer) override; | 46 void RemoveObserver(net::ProxyConfigService::Observer* observer) override; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 66 // Configuration as defined by prefs. | 70 // Configuration as defined by prefs. |
| 67 net::ProxyConfig pref_config_; | 71 net::ProxyConfig pref_config_; |
| 68 | 72 |
| 69 // Flag that indicates that a PrefProxyConfigTracker needs to inform us | 73 // Flag that indicates that a PrefProxyConfigTracker needs to inform us |
| 70 // about a proxy configuration before we may return any configuration. | 74 // about a proxy configuration before we may return any configuration. |
| 71 bool pref_config_read_pending_; | 75 bool pref_config_read_pending_; |
| 72 | 76 |
| 73 // Indicates whether the base service registration is done. | 77 // Indicates whether the base service registration is done. |
| 74 bool registered_observer_; | 78 bool registered_observer_; |
| 75 | 79 |
| 80 base::ThreadChecker thread_checker_; | |
| 81 | |
| 76 DISALLOW_COPY_AND_ASSIGN(ChromeProxyConfigService); | 82 DISALLOW_COPY_AND_ASSIGN(ChromeProxyConfigService); |
| 77 }; | 83 }; |
| 78 | 84 |
| 79 // A class that tracks proxy preferences. It translates the configuration | 85 // A class that tracks proxy preferences. It translates the configuration |
| 80 // to net::ProxyConfig and pushes the result over to the IO thread for | 86 // to net::ProxyConfig and pushes the result over to the IO thread for |
| 81 // ChromeProxyConfigService::UpdateProxyConfig to use. | 87 // ChromeProxyConfigService::UpdateProxyConfig to use. |
| 82 class PrefProxyConfigTrackerImpl : public PrefProxyConfigTracker { | 88 class PrefProxyConfigTrackerImpl : public PrefProxyConfigTracker { |
| 83 public: | 89 public: |
| 84 explicit PrefProxyConfigTrackerImpl(PrefService* pref_service); | 90 explicit PrefProxyConfigTrackerImpl( |
|
droger
2015/08/17 13:51:35
Nit: Remove "explicit"
Abhishek
2015/08/19 08:30:49
Done.
| |
| 91 PrefService* pref_service, | |
| 92 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | |
|
droger
2015/08/17 13:51:36
Call this io_task_runner or network_task_runner.
Abhishek
2015/08/19 08:30:49
Done.
| |
| 85 ~PrefProxyConfigTrackerImpl() override; | 93 ~PrefProxyConfigTrackerImpl() override; |
| 86 | 94 |
| 87 // PrefProxyConfigTracker implementation: | 95 // PrefProxyConfigTracker implementation: |
| 88 scoped_ptr<net::ProxyConfigService> CreateTrackingProxyConfigService( | 96 scoped_ptr<net::ProxyConfigService> CreateTrackingProxyConfigService( |
| 89 scoped_ptr<net::ProxyConfigService> base_service) override; | 97 scoped_ptr<net::ProxyConfigService> base_service) override; |
| 90 | 98 |
| 91 // Notifies the tracker that the pref service passed upon construction is | 99 // Notifies the tracker that the pref service passed upon construction is |
| 92 // about to go away. This must be called from the UI thread. | 100 // about to go away. This must be called from the UI thread. |
| 93 void DetachFromPrefService() override; | 101 void DetachFromPrefService() override; |
| 94 | 102 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 ProxyPrefs::ConfigState config_state_; | 160 ProxyPrefs::ConfigState config_state_; |
| 153 | 161 |
| 154 // Configuration as defined by prefs. | 162 // Configuration as defined by prefs. |
| 155 net::ProxyConfig pref_config_; | 163 net::ProxyConfig pref_config_; |
| 156 | 164 |
| 157 PrefService* pref_service_; | 165 PrefService* pref_service_; |
| 158 ChromeProxyConfigService* chrome_proxy_config_service_; // Weak ptr. | 166 ChromeProxyConfigService* chrome_proxy_config_service_; // Weak ptr. |
| 159 bool update_pending_; // True if config has not been pushed to network stack. | 167 bool update_pending_; // True if config has not been pushed to network stack. |
| 160 PrefChangeRegistrar proxy_prefs_; | 168 PrefChangeRegistrar proxy_prefs_; |
| 161 | 169 |
| 170 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
|
droger
2015/08/17 13:51:36
Call this io_task_runner_ or network_task_runner_.
Abhishek
2015/08/19 08:30:49
Done.
| |
| 171 | |
| 172 base::ThreadChecker thread_checker_; | |
| 173 | |
| 162 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigTrackerImpl); | 174 DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigTrackerImpl); |
| 163 }; | 175 }; |
| 164 | 176 |
| 165 #endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ | 177 #endif // COMPONENTS_PROXY_CONFIG_PREF_PROXY_CONFIG_TRACKER_IMPL_H_ |
| OLD | NEW |