OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 NET_PROXY_PROXY_SERVICE_H_ | 5 #ifndef NET_PROXY_PROXY_SERVICE_H_ |
6 #define NET_PROXY_PROXY_SERVICE_H_ | 6 #define NET_PROXY_PROXY_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy | 33 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy |
34 // resolution. See ProxyResolverV8 for example. | 34 // resolution. See ProxyResolverV8 for example. |
35 class ProxyService : public base::RefCountedThreadSafe<ProxyService>, | 35 class ProxyService : public base::RefCountedThreadSafe<ProxyService>, |
36 public NetworkChangeNotifier::Observer { | 36 public NetworkChangeNotifier::Observer { |
37 public: | 37 public: |
38 // The instance takes ownership of |config_service| and |resolver|. | 38 // The instance takes ownership of |config_service| and |resolver|. |
39 // If |network_change_notifier| is non-NULL, the proxy service will register | 39 // If |network_change_notifier| is non-NULL, the proxy service will register |
40 // with it to detect when the network setup has changed. This is used to | 40 // with it to detect when the network setup has changed. This is used to |
41 // decide when to re-configure the proxy discovery. | 41 // decide when to re-configure the proxy discovery. |
42 ProxyService(ProxyConfigService* config_service, ProxyResolver* resolver, | 42 ProxyService(ProxyConfigService* config_service, ProxyResolver* resolver, |
43 NetworkChangeNotifier* network_change_notifier); | 43 NetworkChangeNotifier* network_change_notifier, |
| 44 const BoundNetLog& init_proxy_resolver_log); |
44 | 45 |
45 // Used internally to handle PAC queries. | 46 // Used internally to handle PAC queries. |
46 // TODO(eroman): consider naming this simply "Request". | 47 // TODO(eroman): consider naming this simply "Request". |
47 class PacRequest; | 48 class PacRequest; |
48 | 49 |
49 // Returns ERR_IO_PENDING if the proxy information could not be provided | 50 // Returns ERR_IO_PENDING if the proxy information could not be provided |
50 // synchronously, to indicate that the result will be available when the | 51 // synchronously, to indicate that the result will be available when the |
51 // callback is run. The callback is run on the thread that calls | 52 // callback is run. The callback is run on the thread that calls |
52 // ResolveProxy. | 53 // ResolveProxy. |
53 // | 54 // |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // Tells this ProxyService to start using a new ProxyConfigService to | 102 // Tells this ProxyService to start using a new ProxyConfigService to |
102 // retrieve its ProxyConfig from. The new ProxyConfigService will immediately | 103 // retrieve its ProxyConfig from. The new ProxyConfigService will immediately |
103 // be queried for new config info which will be used for all subsequent | 104 // be queried for new config info which will be used for all subsequent |
104 // ResolveProxy calls. ProxyService takes ownership of | 105 // ResolveProxy calls. ProxyService takes ownership of |
105 // |new_proxy_config_service|. | 106 // |new_proxy_config_service|. |
106 void ResetConfigService(ProxyConfigService* new_proxy_config_service); | 107 void ResetConfigService(ProxyConfigService* new_proxy_config_service); |
107 | 108 |
108 // Tells the resolver to purge any memory it does not need. | 109 // Tells the resolver to purge any memory it does not need. |
109 void PurgeMemory(); | 110 void PurgeMemory(); |
110 | 111 |
111 // Returns the log for the most recent WPAD + PAC initialization. | |
112 // (This shows how much time was spent downloading and parsing the | |
113 // PAC scripts for the current configuration). | |
114 const CapturingBoundNetLog& init_proxy_resolver_log() const { | |
115 return init_proxy_resolver_log_; | |
116 } | |
117 | |
118 // Returns true if we have called UpdateConfig() at least once. | 112 // Returns true if we have called UpdateConfig() at least once. |
119 bool config_has_been_initialized() const { | 113 bool config_has_been_initialized() const { |
120 return config_.id() != ProxyConfig::INVALID_ID; | 114 return config_.id() != ProxyConfig::INVALID_ID; |
121 } | 115 } |
122 | 116 |
123 // Returns the last configuration fetched from ProxyConfigService. | 117 // Returns the last configuration fetched from ProxyConfigService. |
124 const ProxyConfig& config() { | 118 const ProxyConfig& config() { |
125 return config_; | 119 return config_; |
126 } | 120 } |
127 | 121 |
(...skipping 26 matching lines...) Expand all Loading... |
154 // ########################################################################## | 148 // ########################################################################## |
155 // # See the warnings in net/proxy/proxy_resolver_v8.h describing the | 149 // # See the warnings in net/proxy/proxy_resolver_v8.h describing the |
156 // # multi-threading model. In order for this to be safe to use, *ALL* the | 150 // # multi-threading model. In order for this to be safe to use, *ALL* the |
157 // # other V8's running in the process must use v8::Locker. | 151 // # other V8's running in the process must use v8::Locker. |
158 // ########################################################################## | 152 // ########################################################################## |
159 static ProxyService* Create( | 153 static ProxyService* Create( |
160 ProxyConfigService* proxy_config_service, | 154 ProxyConfigService* proxy_config_service, |
161 bool use_v8_resolver, | 155 bool use_v8_resolver, |
162 URLRequestContext* url_request_context, | 156 URLRequestContext* url_request_context, |
163 NetworkChangeNotifier* network_change_notifier, | 157 NetworkChangeNotifier* network_change_notifier, |
| 158 NetLog* net_log, |
164 MessageLoop* io_loop); | 159 MessageLoop* io_loop); |
165 | 160 |
166 // Convenience method that creates a proxy service using the | 161 // Convenience method that creates a proxy service using the |
167 // specified fixed settings. |pc| must not be NULL. | 162 // specified fixed settings. |pc| must not be NULL. |
168 static ProxyService* CreateFixed(const ProxyConfig& pc); | 163 static ProxyService* CreateFixed(const ProxyConfig& pc); |
169 | 164 |
170 // Creates a proxy service that always fails to fetch the proxy configuration, | 165 // Creates a proxy service that always fails to fetch the proxy configuration, |
171 // so it falls back to direct connect. | 166 // so it falls back to direct connect. |
172 static ProxyService* CreateNull(); | 167 static ProxyService* CreateNull(); |
173 | 168 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 274 |
280 // Callback for when |init_proxy_resolver_| is done. | 275 // Callback for when |init_proxy_resolver_| is done. |
281 CompletionCallbackImpl<ProxyService> init_proxy_resolver_callback_; | 276 CompletionCallbackImpl<ProxyService> init_proxy_resolver_callback_; |
282 | 277 |
283 // Helper to download the PAC script (wpad + custom) and apply fallback rules. | 278 // Helper to download the PAC script (wpad + custom) and apply fallback rules. |
284 // | 279 // |
285 // Note that the declaration is important here: |proxy_script_fetcher_| and | 280 // Note that the declaration is important here: |proxy_script_fetcher_| and |
286 // |proxy_resolver_| must outlive |init_proxy_resolver_|. | 281 // |proxy_resolver_| must outlive |init_proxy_resolver_|. |
287 scoped_ptr<InitProxyResolver> init_proxy_resolver_; | 282 scoped_ptr<InitProxyResolver> init_proxy_resolver_; |
288 | 283 |
289 // Log from the *last* time |init_proxy_resolver_.Init()| was called, or NULL. | 284 // Log for events generated by |init_proxy_resolver_|. |
290 CapturingBoundNetLog init_proxy_resolver_log_; | 285 BoundNetLog init_proxy_resolver_log_; |
291 | 286 |
292 // The (possibly NULL) network change notifier that we use to decide when | 287 // The (possibly NULL) network change notifier that we use to decide when |
293 // to refetch PAC scripts or re-run WPAD. | 288 // to refetch PAC scripts or re-run WPAD. |
294 NetworkChangeNotifier* const network_change_notifier_; | 289 NetworkChangeNotifier* const network_change_notifier_; |
295 | 290 |
296 DISALLOW_COPY_AND_ASSIGN(ProxyService); | 291 DISALLOW_COPY_AND_ASSIGN(ProxyService); |
297 }; | 292 }; |
298 | 293 |
299 // Wrapper for invoking methods on a ProxyService synchronously. | 294 // Wrapper for invoking methods on a ProxyService synchronously. |
300 class SyncProxyServiceHelper | 295 class SyncProxyServiceHelper |
(...skipping 21 matching lines...) Expand all Loading... |
322 | 317 |
323 base::WaitableEvent event_; | 318 base::WaitableEvent event_; |
324 CompletionCallbackImpl<SyncProxyServiceHelper> callback_; | 319 CompletionCallbackImpl<SyncProxyServiceHelper> callback_; |
325 ProxyInfo proxy_info_; | 320 ProxyInfo proxy_info_; |
326 int result_; | 321 int result_; |
327 }; | 322 }; |
328 | 323 |
329 } // namespace net | 324 } // namespace net |
330 | 325 |
331 #endif // NET_PROXY_PROXY_SERVICE_H_ | 326 #endif // NET_PROXY_PROXY_SERVICE_H_ |
OLD | NEW |