OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "net/base/completion_callback.h" | 13 #include "net/base/completion_callback.h" |
14 #include "net/base/load_states.h" | 14 #include "net/base/load_states.h" |
15 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
16 #include "net/proxy/proxy_resolver_script_data.h" | 16 #include "net/proxy/proxy_resolver_script_data.h" |
17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 | 20 |
21 class BoundNetLog; | 21 class BoundNetLog; |
22 class ProxyInfo; | 22 class ProxyInfo; |
23 | 23 |
24 // Interface for "proxy resolvers". A ProxyResolver fills in a list of proxies | 24 // Interface for "proxy resolvers". A ProxyResolver fills in a list of proxies |
25 // to use for a particular URL. Generally the backend for a ProxyResolver is | 25 // to use for a particular URL. Generally the backend for a ProxyResolver is |
26 // a PAC script, but it doesn't need to be. ProxyResolver can service multiple | 26 // a PAC script, but it doesn't need to be. ProxyResolver can service multiple |
27 // requests at a time. | 27 // requests at a time. |
28 class NET_EXPORT_PRIVATE ProxyResolver { | 28 class NET_EXPORT_PRIVATE ProxyResolver { |
29 public: | 29 public: |
30 // Opaque pointer type, to return a handle to cancel outstanding requests. | 30 class Request { |
31 typedef void* RequestHandle; | 31 public: |
| 32 virtual ~Request() {} // Cancels the request |
| 33 virtual LoadState GetLoadState() = 0; |
| 34 }; |
32 | 35 |
33 ProxyResolver() {} | 36 ProxyResolver() {} |
34 | 37 |
35 virtual ~ProxyResolver() {} | 38 virtual ~ProxyResolver() {} |
36 | 39 |
37 // Gets a list of proxy servers to use for |url|. If the request will | 40 // Gets a list of proxy servers to use for |url|. If the request will |
38 // complete asynchronously returns ERR_IO_PENDING and notifies the result | 41 // complete asynchronously returns ERR_IO_PENDING and notifies the result |
39 // by running |callback|. If the result code is OK then | 42 // by running |callback|. If the result code is OK then |
40 // the request was successful and |results| contains the proxy | 43 // the request was successful and |results| contains the proxy |
41 // resolution information. In the case of asynchronous completion | 44 // resolution information. In the case of asynchronous completion |
42 // |*request| is written to, and can be passed to CancelRequest(). | 45 // |*request| is written to. Call request->reset() to cancel. The |
| 46 // scoped_ptr<Request> must not outlive the ProxyResolver that assigned it. |
43 virtual int GetProxyForURL(const GURL& url, | 47 virtual int GetProxyForURL(const GURL& url, |
44 ProxyInfo* results, | 48 ProxyInfo* results, |
45 const CompletionCallback& callback, | 49 const CompletionCallback& callback, |
46 RequestHandle* request, | 50 scoped_ptr<Request>* request, |
47 const BoundNetLog& net_log) = 0; | 51 const BoundNetLog& net_log) = 0; |
48 | 52 |
49 // Cancels |request|. | |
50 virtual void CancelRequest(RequestHandle request) = 0; | |
51 | |
52 // Gets the LoadState for |request|. | |
53 virtual LoadState GetLoadState(RequestHandle request) const = 0; | |
54 | |
55 private: | 53 private: |
56 DISALLOW_COPY_AND_ASSIGN(ProxyResolver); | 54 DISALLOW_COPY_AND_ASSIGN(ProxyResolver); |
57 }; | 55 }; |
58 | 56 |
59 } // namespace net | 57 } // namespace net |
60 | 58 |
61 #endif // NET_PROXY_PROXY_RESOLVER_H_ | 59 #endif // NET_PROXY_PROXY_RESOLVER_H_ |
OLD | NEW |