1 // Copyright (c) 2013 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_V8_TRACING_H_
6 #define NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "net/base/net_export.h"
12 #include "net/proxy/proxy_resolver.h"
13 #include "net/proxy/proxy_resolver_factory.h"
19 // ProxyResolverV8Tracing is a non-blocking proxy resolver.
20 class NET_EXPORT ProxyResolverV8Tracing
{
22 // Bindings is an interface used by ProxyResolverV8Tracing to delegate
23 // per-request functionality. Each instance will be destroyed on the origin
24 // thread of the ProxyResolverV8Tracing when the request completes or is
25 // cancelled. All methods will be invoked from the origin thread.
29 virtual ~Bindings() {}
31 // Invoked in response to an alert() call by the PAC script.
32 virtual void Alert(const base::string16
& message
) = 0;
34 // Invoked in response to an error in the PAC script.
35 virtual void OnError(int line_number
, const base::string16
& message
) = 0;
37 // Returns a HostResolver to use for DNS resolution.
38 virtual HostResolver
* GetHostResolver() = 0;
40 // Returns a BoundNetLog to be passed to the HostResolver returned by
42 virtual BoundNetLog
GetBoundNetLog() = 0;
45 DISALLOW_COPY_AND_ASSIGN(Bindings
);
48 virtual ~ProxyResolverV8Tracing() {}
50 // Gets a list of proxy servers to use for |url|. This request always
51 // runs asynchronously and notifies the result by running |callback|. If the
52 // result code is OK then the request was successful and |results| contains
53 // the proxy resolution information. If |request| is non-null, |*request| is
54 // written to, and can be passed to CancelRequest().
55 virtual void GetProxyForURL(const GURL
& url
,
57 const CompletionCallback
& callback
,
58 ProxyResolver::RequestHandle
* request
,
59 scoped_ptr
<Bindings
> bindings
) = 0;
62 virtual void CancelRequest(ProxyResolver::RequestHandle request
) = 0;
64 // Gets the LoadState for |request|.
65 virtual LoadState
GetLoadState(
66 ProxyResolver::RequestHandle request
) const = 0;
69 // A factory for ProxyResolverV8Tracing instances. The default implementation,
70 // returned by Create(), creates ProxyResolverV8Tracing instances that execute
71 // ProxyResolverV8 on a single helper thread, and do some magic to avoid
72 // blocking in DNS. For more details see the design document:
73 // https://docs.google.com/a/google.com/document/d/16Ij5OcVnR3s0MH4Z5XkhI9VTPoMJdaBn9rKreAmGOdE/edit?pli=1
74 class NET_EXPORT ProxyResolverV8TracingFactory
{
76 ProxyResolverV8TracingFactory() {}
77 virtual ~ProxyResolverV8TracingFactory() = default;
79 virtual void CreateProxyResolverV8Tracing(
80 const scoped_refptr
<ProxyResolverScriptData
>& pac_script
,
81 scoped_ptr
<ProxyResolverV8Tracing::Bindings
> bindings
,
82 scoped_ptr
<ProxyResolverV8Tracing
>* resolver
,
83 const CompletionCallback
& callback
,
84 scoped_ptr
<ProxyResolverFactory::Request
>* request
) = 0;
86 static scoped_ptr
<ProxyResolverV8TracingFactory
> Create();
89 DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8TracingFactory
);
94 #endif // NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_