| 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_INIT_PROXY_RESOLVER_H_ | 5 #ifndef NET_PROXY_INIT_PROXY_RESOLVER_H_ |
| 6 #define NET_PROXY_INIT_PROXY_RESOLVER_H_ | 6 #define NET_PROXY_INIT_PROXY_RESOLVER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 12 #include "net/base/completion_callback.h" | 12 #include "net/base/completion_callback.h" |
| 13 #include "net/base/net_log.h" | 13 #include "net/base/net_log.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 class BoundNetLog; | |
| 18 class ProxyConfig; | 17 class ProxyConfig; |
| 19 class ProxyResolver; | 18 class ProxyResolver; |
| 20 class ProxyScriptFetcher; | 19 class ProxyScriptFetcher; |
| 21 | 20 |
| 22 // InitProxyResolver is a helper class used by ProxyService to | 21 // InitProxyResolver is a helper class used by ProxyService to |
| 23 // initialize a ProxyResolver with the PAC script data specified | 22 // initialize a ProxyResolver with the PAC script data specified |
| 24 // by a particular ProxyConfig. | 23 // by a particular ProxyConfig. |
| 25 // | 24 // |
| 26 // This involves trying to use PAC scripts in this order: | 25 // This involves trying to use PAC scripts in this order: |
| 27 // | 26 // |
| 28 // (1) WPAD if auto-detect is on. | 27 // (1) WPAD if auto-detect is on. |
| 29 // (2) Custom PAC script if a URL was given. | 28 // (2) Custom PAC script if a URL was given. |
| 30 // | 29 // |
| 31 // If no PAC script was successfully downloaded + parsed, then it fails with | 30 // If no PAC script was successfully downloaded + parsed, then it fails with |
| 32 // a network error. Otherwise the proxy resolver is left initialized with | 31 // a network error. Otherwise the proxy resolver is left initialized with |
| 33 // the PAC script. | 32 // the PAC script. |
| 34 // | 33 // |
| 35 // Deleting InitProxyResolver while Init() is in progress, will | 34 // Deleting InitProxyResolver while Init() is in progress, will |
| 36 // cancel the request. | 35 // cancel the request. |
| 37 // | 36 // |
| 38 class InitProxyResolver { | 37 class InitProxyResolver { |
| 39 public: | 38 public: |
| 40 // |resolver| and |proxy_script_fetcher| must remain valid for | 39 // |resolver|, |proxy_script_fetcher| and |net_log| must remain valid for |
| 41 // the lifespan of InitProxyResolver. | 40 // the lifespan of InitProxyResolver. |
| 42 InitProxyResolver(ProxyResolver* resolver, | 41 InitProxyResolver(ProxyResolver* resolver, |
| 43 ProxyScriptFetcher* proxy_script_fetcher); | 42 ProxyScriptFetcher* proxy_script_fetcher, |
| 43 NetLog* net_log); |
| 44 | 44 |
| 45 // Aborts any in-progress request. | 45 // Aborts any in-progress request. |
| 46 ~InitProxyResolver(); | 46 ~InitProxyResolver(); |
| 47 | 47 |
| 48 // Apply the PAC settings of |config| to |resolver_|. | 48 // Apply the PAC settings of |config| to |resolver_|. |
| 49 int Init(const ProxyConfig& config, | 49 int Init(const ProxyConfig& config, |
| 50 CompletionCallback* callback, | 50 CompletionCallback* callback); |
| 51 const BoundNetLog& net_log); | |
| 52 | 51 |
| 53 private: | 52 private: |
| 54 enum State { | 53 enum State { |
| 55 STATE_NONE, | 54 STATE_NONE, |
| 56 STATE_FETCH_PAC_SCRIPT, | 55 STATE_FETCH_PAC_SCRIPT, |
| 57 STATE_FETCH_PAC_SCRIPT_COMPLETE, | 56 STATE_FETCH_PAC_SCRIPT_COMPLETE, |
| 58 STATE_SET_PAC_SCRIPT, | 57 STATE_SET_PAC_SCRIPT, |
| 59 STATE_SET_PAC_SCRIPT_COMPLETE, | 58 STATE_SET_PAC_SCRIPT_COMPLETE, |
| 60 }; | 59 }; |
| 61 typedef std::vector<GURL> UrlList; | 60 typedef std::vector<GURL> UrlList; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 State next_state_; | 103 State next_state_; |
| 105 | 104 |
| 106 BoundNetLog net_log_; | 105 BoundNetLog net_log_; |
| 107 | 106 |
| 108 DISALLOW_COPY_AND_ASSIGN(InitProxyResolver); | 107 DISALLOW_COPY_AND_ASSIGN(InitProxyResolver); |
| 109 }; | 108 }; |
| 110 | 109 |
| 111 } // namespace net | 110 } // namespace net |
| 112 | 111 |
| 113 #endif // NET_PROXY_INIT_PROXY_RESOLVER_H_ | 112 #endif // NET_PROXY_INIT_PROXY_RESOLVER_H_ |
| OLD | NEW |