| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // Returns true if we have called UpdateConfig() at least once. | 113 // Returns true if we have called UpdateConfig() at least once. |
| 114 bool config_has_been_initialized() const { | 114 bool config_has_been_initialized() const { |
| 115 return config_.id() != ProxyConfig::INVALID_ID; | 115 return config_.id() != ProxyConfig::INVALID_ID; |
| 116 } | 116 } |
| 117 | 117 |
| 118 // Returns the last configuration fetched from ProxyConfigService. | 118 // Returns the last configuration fetched from ProxyConfigService. |
| 119 const ProxyConfig& config() { | 119 const ProxyConfig& config() { |
| 120 return config_; | 120 return config_; |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Creates a proxy service using the specified settings. If |pc| is NULL then | 123 // Creates a proxy service that polls |proxy_config_service| to notice when |
| 124 // the system's default proxy settings will be used (on Windows this will | 124 // the proxy settings change. We take ownership of |proxy_config_service|. |
| 125 // use IE's settings). | |
| 126 // Iff |use_v8_resolver| is true, then the V8 implementation is | 125 // Iff |use_v8_resolver| is true, then the V8 implementation is |
| 127 // used. | 126 // used. |
| 128 // |url_request_context| is only used when use_v8_resolver is true: | 127 // |url_request_context| is only used when use_v8_resolver is true: |
| 129 // it specifies the URL request context that will be used if a PAC | 128 // it specifies the URL request context that will be used if a PAC |
| 130 // script needs to be fetched. | 129 // script needs to be fetched. |
| 131 // |io_loop| points to the IO thread's message loop. It is only used | 130 // |io_loop| points to the IO thread's message loop. It is only used |
| 132 // when pc is NULL. If both pc and io_loop are NULL, then monitoring | 131 // when pc is NULL. |
| 133 // of proxy setting changes will be disabled in ProxyConfigServiceLinux. | |
| 134 // |file_loop| points to the file thread's message loop. It is used | |
| 135 // to read any files necessary to get proxy settings. | |
| 136 // ########################################################################## | 132 // ########################################################################## |
| 137 // # See the warnings in net/proxy/proxy_resolver_v8.h describing the | 133 // # See the warnings in net/proxy/proxy_resolver_v8.h describing the |
| 138 // # multi-threading model. In order for this to be safe to use, *ALL* the | 134 // # multi-threading model. In order for this to be safe to use, *ALL* the |
| 139 // # other V8's running in the process must use v8::Locker. | 135 // # other V8's running in the process must use v8::Locker. |
| 140 // ########################################################################## | 136 // ########################################################################## |
| 141 static ProxyService* Create( | 137 static ProxyService* Create( |
| 142 const ProxyConfig* pc, | 138 ProxyConfigService* proxy_config_service, |
| 143 bool use_v8_resolver, | 139 bool use_v8_resolver, |
| 144 URLRequestContext* url_request_context, | 140 URLRequestContext* url_request_context, |
| 145 MessageLoop* io_loop, MessageLoop* file_loop); | 141 MessageLoop* io_loop); |
| 146 | 142 |
| 147 // Convenience method that creates a proxy service using the | 143 // Convenience method that creates a proxy service using the |
| 148 // specified fixed settings. |pc| must not be NULL. | 144 // specified fixed settings. |pc| must not be NULL. |
| 149 static ProxyService* CreateFixed(const ProxyConfig& pc); | 145 static ProxyService* CreateFixed(const ProxyConfig& pc); |
| 150 | 146 |
| 151 // Creates a proxy service that always fails to fetch the proxy configuration, | 147 // Creates a proxy service that always fails to fetch the proxy configuration, |
| 152 // so it falls back to direct connect. | 148 // so it falls back to direct connect. |
| 153 static ProxyService* CreateNull(); | 149 static ProxyService* CreateNull(); |
| 154 | 150 |
| 151 // Creates a config service appropriate for this platform that fetches the |
| 152 // system proxy settings. |
| 153 static ProxyConfigService* CreateSystemProxyConfigService( |
| 154 MessageLoop* io_loop, MessageLoop* file_loop); |
| 155 |
| 155 private: | 156 private: |
| 156 FRIEND_TEST(ProxyServiceTest, IsLocalName); | 157 FRIEND_TEST(ProxyServiceTest, IsLocalName); |
| 157 FRIEND_TEST(ProxyServiceTest, UpdateConfigAfterFailedAutodetect); | 158 FRIEND_TEST(ProxyServiceTest, UpdateConfigAfterFailedAutodetect); |
| 158 FRIEND_TEST(ProxyServiceTest, UpdateConfigFromPACToDirect); | 159 FRIEND_TEST(ProxyServiceTest, UpdateConfigFromPACToDirect); |
| 159 friend class PacRequest; | 160 friend class PacRequest; |
| 160 // TODO(eroman): change this to a std::set. Note that this requires updating | 161 // TODO(eroman): change this to a std::set. Note that this requires updating |
| 161 // some tests in proxy_service_unittest.cc such as: | 162 // some tests in proxy_service_unittest.cc such as: |
| 162 // ProxyServiceTest.InitialPACScriptDownload | 163 // ProxyServiceTest.InitialPACScriptDownload |
| 163 // which expects requests to finish in the order they were added. | 164 // which expects requests to finish in the order they were added. |
| 164 typedef std::vector<scoped_refptr<PacRequest> > PendingRequests; | 165 typedef std::vector<scoped_refptr<PacRequest> > PendingRequests; |
| 165 | 166 |
| 166 // Creates a config service appropriate for this platform that fetches the | |
| 167 // system proxy settings. | |
| 168 static ProxyConfigService* CreateSystemProxyConfigService( | |
| 169 MessageLoop* io_loop, MessageLoop* file_loop); | |
| 170 | |
| 171 // Creates a proxy resolver appropriate for this platform that doesn't rely | 167 // Creates a proxy resolver appropriate for this platform that doesn't rely |
| 172 // on V8. | 168 // on V8. |
| 173 static ProxyResolver* CreateNonV8ProxyResolver(); | 169 static ProxyResolver* CreateNonV8ProxyResolver(); |
| 174 | 170 |
| 175 // Identifies the proxy configuration. | 171 // Identifies the proxy configuration. |
| 176 ProxyConfig::ID config_id() const { return config_.id(); } | 172 ProxyConfig::ID config_id() const { return config_.id(); } |
| 177 | 173 |
| 178 // Checks to see if the proxy configuration changed, and then updates config_ | 174 // Checks to see if the proxy configuration changed, and then updates config_ |
| 179 // to reference the new configuration. | 175 // to reference the new configuration. |
| 180 void UpdateConfig(); | 176 void UpdateConfig(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 | 293 |
| 298 base::WaitableEvent event_; | 294 base::WaitableEvent event_; |
| 299 CompletionCallbackImpl<SyncProxyServiceHelper> callback_; | 295 CompletionCallbackImpl<SyncProxyServiceHelper> callback_; |
| 300 ProxyInfo proxy_info_; | 296 ProxyInfo proxy_info_; |
| 301 int result_; | 297 int result_; |
| 302 }; | 298 }; |
| 303 | 299 |
| 304 } // namespace net | 300 } // namespace net |
| 305 | 301 |
| 306 #endif // NET_PROXY_PROXY_SERVICE_H_ | 302 #endif // NET_PROXY_PROXY_SERVICE_H_ |
| OLD | NEW |