| 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_RESOLVER_H_ | 5 #ifndef NET_PROXY_PROXY_RESOLVER_H_ |
| 6 #define NET_PROXY_PROXY_RESOLVER_H_ | 6 #define NET_PROXY_PROXY_RESOLVER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 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 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 | 15 |
| 16 class LoadLog; | 16 class BoundNetLog; |
| 17 class ProxyInfo; | 17 class ProxyInfo; |
| 18 | 18 |
| 19 // Interface for "proxy resolvers". A ProxyResolver fills in a list of proxies | 19 // Interface for "proxy resolvers". A ProxyResolver fills in a list of proxies |
| 20 // to use for a particular URL. Generally the backend for a ProxyResolver is | 20 // to use for a particular URL. Generally the backend for a ProxyResolver is |
| 21 // a PAC script, but it doesn't need to be. ProxyResolver can service multiple | 21 // a PAC script, but it doesn't need to be. ProxyResolver can service multiple |
| 22 // requests at a time. | 22 // requests at a time. |
| 23 class ProxyResolver { | 23 class ProxyResolver { |
| 24 public: | 24 public: |
| 25 // Opaque pointer type, to return a handle to cancel outstanding requests. | 25 // Opaque pointer type, to return a handle to cancel outstanding requests. |
| 26 typedef void* RequestHandle; | 26 typedef void* RequestHandle; |
| 27 | 27 |
| 28 // See |expects_pac_bytes()| for the meaning of |expects_pac_bytes|. | 28 // See |expects_pac_bytes()| for the meaning of |expects_pac_bytes|. |
| 29 explicit ProxyResolver(bool expects_pac_bytes) | 29 explicit ProxyResolver(bool expects_pac_bytes) |
| 30 : expects_pac_bytes_(expects_pac_bytes) {} | 30 : expects_pac_bytes_(expects_pac_bytes) {} |
| 31 | 31 |
| 32 virtual ~ProxyResolver() {} | 32 virtual ~ProxyResolver() {} |
| 33 | 33 |
| 34 // Gets a list of proxy servers to use for |url|. If the request will | 34 // Gets a list of proxy servers to use for |url|. If the request will |
| 35 // complete asynchronously returns ERR_IO_PENDING and notifies the result | 35 // complete asynchronously returns ERR_IO_PENDING and notifies the result |
| 36 // by running |callback|. If the result code is OK then | 36 // by running |callback|. If the result code is OK then |
| 37 // the request was successful and |results| contains the proxy | 37 // the request was successful and |results| contains the proxy |
| 38 // resolution information. In the case of asynchronous completion | 38 // resolution information. In the case of asynchronous completion |
| 39 // |*request| is written to, and can be passed to CancelRequest(). | 39 // |*request| is written to, and can be passed to CancelRequest(). |
| 40 virtual int GetProxyForURL(const GURL& url, | 40 virtual int GetProxyForURL(const GURL& url, |
| 41 ProxyInfo* results, | 41 ProxyInfo* results, |
| 42 CompletionCallback* callback, | 42 CompletionCallback* callback, |
| 43 RequestHandle* request, | 43 RequestHandle* request, |
| 44 LoadLog* load_log) = 0; | 44 const BoundNetLog& net_log) = 0; |
| 45 | 45 |
| 46 // Cancels |request|. | 46 // Cancels |request|. |
| 47 virtual void CancelRequest(RequestHandle request) = 0; | 47 virtual void CancelRequest(RequestHandle request) = 0; |
| 48 | 48 |
| 49 // The PAC script backend can be specified to the ProxyResolver either via | 49 // The PAC script backend can be specified to the ProxyResolver either via |
| 50 // URL, or via the javascript text itself. If |expects_pac_bytes| is true, | 50 // URL, or via the javascript text itself. If |expects_pac_bytes| is true, |
| 51 // then PAC scripts should be specified using SetPacScriptByData(). Otherwise | 51 // then PAC scripts should be specified using SetPacScriptByData(). Otherwise |
| 52 // they should be specified using SetPacScriptByUrl(). | 52 // they should be specified using SetPacScriptByUrl(). |
| 53 bool expects_pac_bytes() const { return expects_pac_bytes_; } | 53 bool expects_pac_bytes() const { return expects_pac_bytes_; } |
| 54 | 54 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 CompletionCallback* callback) = 0; | 86 CompletionCallback* callback) = 0; |
| 87 | 87 |
| 88 const bool expects_pac_bytes_; | 88 const bool expects_pac_bytes_; |
| 89 | 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(ProxyResolver); | 90 DISALLOW_COPY_AND_ASSIGN(ProxyResolver); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 } // namespace net | 93 } // namespace net |
| 94 | 94 |
| 95 #endif // NET_PROXY_PROXY_RESOLVER_H_ | 95 #endif // NET_PROXY_PROXY_RESOLVER_H_ |
| OLD | NEW |