| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_FACTORY_H_ | 5 #ifndef NET_PROXY_PROXY_RESOLVER_FACTORY_H_ |
| 6 #define NET_PROXY_PROXY_RESOLVER_FACTORY_H_ | 6 #define NET_PROXY_PROXY_RESOLVER_FACTORY_H_ |
| 7 | 7 |
| 8 #include <set> |
| 9 |
| 8 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 10 #include "net/base/completion_callback.h" | 12 #include "net/base/completion_callback.h" |
| 11 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
| 12 #include "net/proxy/proxy_resolver_script_data.h" | 14 #include "net/proxy/proxy_resolver_script_data.h" |
| 13 | 15 |
| 14 namespace net { | 16 namespace net { |
| 15 | 17 |
| 16 class ProxyResolver; | 18 class ProxyResolver; |
| 17 | 19 |
| 18 // ProxyResolverFactory is an interface for creating ProxyResolver instances. | 20 // ProxyResolverFactory is an interface for creating ProxyResolver instances. |
| 19 class NET_EXPORT ProxyResolverFactory { | 21 class NET_EXPORT ProxyResolverFactory { |
| 20 public: | 22 public: |
| 21 // A handle to a request. Deleting it will cancel the request. | 23 // A handle to a request. Deleting it will cancel the request. |
| 22 class Request { | 24 class Request { |
| 23 public: | 25 public: |
| 24 virtual ~Request() {} | 26 virtual ~Request() {} |
| 25 }; | 27 }; |
| 26 | 28 |
| 27 // See |expects_pac_bytes()| for the meaning of |expects_pac_bytes|. | 29 // See |expects_pac_bytes()| for the meaning of |expects_pac_bytes|. |
| 28 explicit ProxyResolverFactory(bool expects_pac_bytes); | 30 explicit ProxyResolverFactory(bool expects_pac_bytes); |
| 29 | 31 |
| 30 virtual ~ProxyResolverFactory(); | 32 virtual ~ProxyResolverFactory(); |
| 31 | 33 |
| 32 // Creates a new ProxyResolver. If the request will complete asynchronously, | 34 // Creates a new ProxyResolver. If the request will complete asynchronously, |
| 33 // it returns ERR_IO_PENDING and notifies the result by running |callback|. | 35 // it returns ERR_IO_PENDING and notifies the result by running |callback|. |
| 34 // If the result is OK, then |resolver| contains the ProxyResolver. In the | 36 // If the result is OK, then |resolver| contains the ProxyResolver. In the |
| 35 // case of asynchronous completion |*request| is written to, and can be | 37 // case of asynchronous completion |*request| is written to, and can be |
| 36 // deleted to cancel the request. | 38 // deleted to cancel the request. All requests in progress are cancelled if |
| 39 // the ProxyResolverFactory is deleted. |
| 37 virtual int CreateProxyResolver( | 40 virtual int CreateProxyResolver( |
| 38 const scoped_refptr<ProxyResolverScriptData>& pac_script, | 41 const scoped_refptr<ProxyResolverScriptData>& pac_script, |
| 39 scoped_ptr<ProxyResolver>* resolver, | 42 scoped_ptr<ProxyResolver>* resolver, |
| 40 const net::CompletionCallback& callback, | 43 const net::CompletionCallback& callback, |
| 41 scoped_ptr<Request>* request) = 0; | 44 scoped_ptr<Request>* request) = 0; |
| 42 | 45 |
| 43 // The PAC script backend can be specified to the ProxyResolverFactory either | 46 // The PAC script backend can be specified to the ProxyResolverFactory either |
| 44 // via URL, or via the javascript text itself. If |expects_pac_bytes| is true, | 47 // via URL, or via the javascript text itself. If |expects_pac_bytes| is true, |
| 45 // then the ProxyResolverScriptData passed to CreateProxyResolver() should | 48 // then the ProxyResolverScriptData passed to CreateProxyResolver() should |
| 46 // contain the actual script bytes rather than just the URL. | 49 // contain the actual script bytes rather than just the URL. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 58 | 61 |
| 59 ~LegacyProxyResolverFactory() override; | 62 ~LegacyProxyResolverFactory() override; |
| 60 | 63 |
| 61 int CreateProxyResolver( | 64 int CreateProxyResolver( |
| 62 const scoped_refptr<ProxyResolverScriptData>& pac_script, | 65 const scoped_refptr<ProxyResolverScriptData>& pac_script, |
| 63 scoped_ptr<ProxyResolver>* resolver, | 66 scoped_ptr<ProxyResolver>* resolver, |
| 64 const net::CompletionCallback& callback, | 67 const net::CompletionCallback& callback, |
| 65 scoped_ptr<Request>* request) override; | 68 scoped_ptr<Request>* request) override; |
| 66 | 69 |
| 67 virtual scoped_ptr<ProxyResolver> CreateProxyResolver() = 0; | 70 virtual scoped_ptr<ProxyResolver> CreateProxyResolver() = 0; |
| 71 |
| 72 private: |
| 73 class Job; |
| 74 |
| 75 void RemoveJob(Job* job); |
| 76 |
| 77 std::set<Job*> jobs_; |
| 68 }; | 78 }; |
| 69 | 79 |
| 70 } // namespace net | 80 } // namespace net |
| 71 | 81 |
| 72 #endif // NET_PROXY_PROXY_RESOLVER_FACTORY_H_ | 82 #endif // NET_PROXY_PROXY_RESOLVER_FACTORY_H_ |
| OLD | NEW |