Chromium Code Reviews| 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 18 matching lines...) Expand all Loading... | |
| 29 class ProxyScriptFetcher; | 29 class ProxyScriptFetcher; |
| 30 | 30 |
| 31 // This class can be used to resolve the proxy server to use when loading a | 31 // This class can be used to resolve the proxy server to use when loading a |
| 32 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy | 32 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy |
| 33 // resolution. See ProxyResolverV8 for example. | 33 // resolution. See ProxyResolverV8 for example. |
| 34 class ProxyService : public base::RefCountedThreadSafe<ProxyService> { | 34 class ProxyService : public base::RefCountedThreadSafe<ProxyService> { |
| 35 public: | 35 public: |
| 36 // The instance takes ownership of |config_service| and |resolver|. | 36 // The instance takes ownership of |config_service| and |resolver|. |
| 37 ProxyService(ProxyConfigService* config_service, ProxyResolver* resolver); | 37 ProxyService(ProxyConfigService* config_service, ProxyResolver* resolver); |
| 38 | 38 |
| 39 ~ProxyService(); | |
| 40 | |
| 41 // Used internally to handle PAC queries. | 39 // Used internally to handle PAC queries. |
| 42 // TODO(eroman): consider naming this simply "Request". | 40 // TODO(eroman): consider naming this simply "Request". |
| 43 class PacRequest; | 41 class PacRequest; |
| 44 | 42 |
| 45 // Returns ERR_IO_PENDING if the proxy information could not be provided | 43 // Returns ERR_IO_PENDING if the proxy information could not be provided |
| 46 // synchronously, to indicate that the result will be available when the | 44 // synchronously, to indicate that the result will be available when the |
| 47 // callback is run. The callback is run on the thread that calls | 45 // callback is run. The callback is run on the thread that calls |
| 48 // ResolveProxy. | 46 // ResolveProxy. |
| 49 // | 47 // |
| 50 // The caller is responsible for ensuring that |results| and |callback| | 48 // The caller is responsible for ensuring that |results| and |callback| |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 // Creates a proxy service that always fails to fetch the proxy configuration, | 145 // Creates a proxy service that always fails to fetch the proxy configuration, |
| 148 // so it falls back to direct connect. | 146 // so it falls back to direct connect. |
| 149 static ProxyService* CreateNull(); | 147 static ProxyService* CreateNull(); |
| 150 | 148 |
| 151 // Creates a config service appropriate for this platform that fetches the | 149 // Creates a config service appropriate for this platform that fetches the |
| 152 // system proxy settings. | 150 // system proxy settings. |
| 153 static ProxyConfigService* CreateSystemProxyConfigService( | 151 static ProxyConfigService* CreateSystemProxyConfigService( |
| 154 MessageLoop* io_loop, MessageLoop* file_loop); | 152 MessageLoop* io_loop, MessageLoop* file_loop); |
| 155 | 153 |
| 156 private: | 154 private: |
| 155 friend class base::RefCountedThreadSafe<ProxyService>; | |
| 157 FRIEND_TEST(ProxyServiceTest, IsLocalName); | 156 FRIEND_TEST(ProxyServiceTest, IsLocalName); |
| 158 FRIEND_TEST(ProxyServiceTest, UpdateConfigAfterFailedAutodetect); | 157 FRIEND_TEST(ProxyServiceTest, UpdateConfigAfterFailedAutodetect); |
| 159 FRIEND_TEST(ProxyServiceTest, UpdateConfigFromPACToDirect); | 158 FRIEND_TEST(ProxyServiceTest, UpdateConfigFromPACToDirect); |
| 160 friend class PacRequest; | 159 friend class PacRequest; |
| 160 | |
| 161 ~ProxyService(); | |
|
eroman
2009/11/05 20:52:19
nit: move this below the typedef
jam
2009/11/05 21:56:02
Done.
| |
| 162 | |
| 161 // TODO(eroman): change this to a std::set. Note that this requires updating | 163 // TODO(eroman): change this to a std::set. Note that this requires updating |
| 162 // some tests in proxy_service_unittest.cc such as: | 164 // some tests in proxy_service_unittest.cc such as: |
| 163 // ProxyServiceTest.InitialPACScriptDownload | 165 // ProxyServiceTest.InitialPACScriptDownload |
| 164 // which expects requests to finish in the order they were added. | 166 // which expects requests to finish in the order they were added. |
| 165 typedef std::vector<scoped_refptr<PacRequest> > PendingRequests; | 167 typedef std::vector<scoped_refptr<PacRequest> > PendingRequests; |
| 166 | 168 |
| 167 // Creates a proxy resolver appropriate for this platform that doesn't rely | 169 // Creates a proxy resolver appropriate for this platform that doesn't rely |
| 168 // on V8. | 170 // on V8. |
| 169 static ProxyResolver* CreateNonV8ProxyResolver(); | 171 static ProxyResolver* CreateNonV8ProxyResolver(); |
| 170 | 172 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 : public base::RefCountedThreadSafe<SyncProxyServiceHelper> { | 278 : public base::RefCountedThreadSafe<SyncProxyServiceHelper> { |
| 277 public: | 279 public: |
| 278 SyncProxyServiceHelper(MessageLoop* io_message_loop, | 280 SyncProxyServiceHelper(MessageLoop* io_message_loop, |
| 279 ProxyService* proxy_service); | 281 ProxyService* proxy_service); |
| 280 | 282 |
| 281 int ResolveProxy(const GURL& url, ProxyInfo* proxy_info, LoadLog* load_log); | 283 int ResolveProxy(const GURL& url, ProxyInfo* proxy_info, LoadLog* load_log); |
| 282 int ReconsiderProxyAfterError(const GURL& url, | 284 int ReconsiderProxyAfterError(const GURL& url, |
| 283 ProxyInfo* proxy_info, LoadLog* load_log); | 285 ProxyInfo* proxy_info, LoadLog* load_log); |
| 284 | 286 |
| 285 private: | 287 private: |
| 288 friend class base::RefCountedThreadSafe<SyncProxyServiceHelper>; | |
| 289 | |
| 290 ~SyncProxyServiceHelper() {} | |
| 291 | |
| 286 void StartAsyncResolve(const GURL& url, LoadLog* load_log); | 292 void StartAsyncResolve(const GURL& url, LoadLog* load_log); |
| 287 void StartAsyncReconsider(const GURL& url, LoadLog* load_log); | 293 void StartAsyncReconsider(const GURL& url, LoadLog* load_log); |
| 288 | 294 |
| 289 void OnCompletion(int result); | 295 void OnCompletion(int result); |
| 290 | 296 |
| 291 MessageLoop* io_message_loop_; | 297 MessageLoop* io_message_loop_; |
| 292 ProxyService* proxy_service_; | 298 ProxyService* proxy_service_; |
| 293 | 299 |
| 294 base::WaitableEvent event_; | 300 base::WaitableEvent event_; |
| 295 CompletionCallbackImpl<SyncProxyServiceHelper> callback_; | 301 CompletionCallbackImpl<SyncProxyServiceHelper> callback_; |
| 296 ProxyInfo proxy_info_; | 302 ProxyInfo proxy_info_; |
| 297 int result_; | 303 int result_; |
| 298 }; | 304 }; |
| 299 | 305 |
| 300 } // namespace net | 306 } // namespace net |
| 301 | 307 |
| 302 #endif // NET_PROXY_PROXY_SERVICE_H_ | 308 #endif // NET_PROXY_PROXY_SERVICE_H_ |
| OLD | NEW |