Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: components/proxy_config/pref_proxy_config_tracker_impl.h

Issue 1296663003: Componentize proxy code from chrome/browser/net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated gn build Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 ProxyConfigServiceImpl : public net::ProxyConfigService,
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 ProxyConfigServiceImpl(net::ProxyConfigService* base_service);
38 ~ChromeProxyConfigService() override; 42 ~ProxyConfigServiceImpl() 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;
43 ConfigAvailability GetLatestProxyConfig(net::ProxyConfig* config) override; 47 ConfigAvailability GetLatestProxyConfig(net::ProxyConfig* config) override;
44 void OnLazyPoll() override; 48 void OnLazyPoll() override;
45 49
46 // 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
47 // PrefProxyConfigTrackerImpl. 51 // PrefProxyConfigTrackerImpl.
48 void UpdateProxyConfig(ProxyPrefs::ConfigState config_state, 52 void UpdateProxyConfig(ProxyPrefs::ConfigState config_state,
(...skipping 17 matching lines...) Expand all
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
76 DISALLOW_COPY_AND_ASSIGN(ChromeProxyConfigService); 80 base::ThreadChecker thread_checker_;
81
82 DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceImpl);
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 // ProxyConfigServiceImpl::UpdateProxyConfig to use.
82 class PrefProxyConfigTrackerImpl : public PrefProxyConfigTracker { 88 class PrefProxyConfigTrackerImpl : public PrefProxyConfigTracker {
83 public: 89 public:
84 explicit PrefProxyConfigTrackerImpl(PrefService* pref_service); 90 PrefProxyConfigTrackerImpl(
91 PrefService* pref_service,
92 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner);
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 156
149 private: 157 private:
150 // Tracks configuration state. |pref_config_| is valid only if |config_state_| 158 // Tracks configuration state. |pref_config_| is valid only if |config_state_|
151 // is not CONFIG_UNSET. 159 // is not CONFIG_UNSET.
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 ProxyConfigServiceImpl* chrome_proxy_config_service_; // Weak ptr.
droger 2015/08/19 09:18:45 nit: rename this to: proxy_config_service_impl_
Abhishek 2015/08/19 10:10:29 Done.
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> io_task_runner_;
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698