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
3 // found in the LICENSE file.
5 #ifndef NET_PROXY_PROXY_RESOLVER_FACTORY_H_
6 #define NET_PROXY_PROXY_RESOLVER_FACTORY_H_
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "net/base/completion_callback.h"
13 #include "net/base/net_export.h"
14 #include "net/proxy/proxy_resolver_script_data.h"
20 // ProxyResolverFactory is an interface for creating ProxyResolver instances.
21 class NET_EXPORT ProxyResolverFactory
{
23 // A handle to a request. Deleting it will cancel the request.
29 // See |expects_pac_bytes()| for the meaning of |expects_pac_bytes|.
30 explicit ProxyResolverFactory(bool expects_pac_bytes
);
32 virtual ~ProxyResolverFactory();
34 // Creates a new ProxyResolver. If the request will complete asynchronously,
35 // it returns ERR_IO_PENDING and notifies the result by running |callback|.
36 // If the result is OK, then |resolver| contains the ProxyResolver. In the
37 // case of asynchronous completion |*request| is written to, and can be
38 // deleted to cancel the request. All requests in progress are cancelled if
39 // the ProxyResolverFactory is deleted.
40 virtual int CreateProxyResolver(
41 const scoped_refptr
<ProxyResolverScriptData
>& pac_script
,
42 scoped_ptr
<ProxyResolver
>* resolver
,
43 const net::CompletionCallback
& callback
,
44 scoped_ptr
<Request
>* request
) = 0;
46 // The PAC script backend can be specified to the ProxyResolverFactory either
47 // via URL, or via the javascript text itself. If |expects_pac_bytes| is true,
48 // then the ProxyResolverScriptData passed to CreateProxyResolver() should
49 // contain the actual script bytes rather than just the URL.
50 bool expects_pac_bytes() const { return expects_pac_bytes_
; }
53 bool expects_pac_bytes_
;
55 DISALLOW_COPY_AND_ASSIGN(ProxyResolverFactory
);
60 #endif // NET_PROXY_PROXY_RESOLVER_FACTORY_H_