Revert of Re-enabling webrtc Telemetry tests. (patchset #1 id:1 of https://codereview...
[chromium-blink-merge.git] / net / proxy / proxy_resolver_v8_tracing.h
blob0b0ab35ee38163960d1fd18c82e2e3f4b1ca00d1
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"
15 namespace net {
17 class HostResolver;
19 // ProxyResolverV8Tracing is a non-blocking proxy resolver.
20 class NET_EXPORT ProxyResolverV8Tracing {
21 public:
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 after
25 // the request is cancelled. In the cancellation case, the Bindings instance
26 // for a request may be destroyed after CancelRequest completes.
27 class Bindings {
28 public:
29 Bindings() {}
30 virtual ~Bindings() {}
32 // Invoked in response to an alert() call by the PAC script. This may be
33 // called after cancellation and from any thread.
34 virtual void Alert(const base::string16& message) = 0;
36 // Invoked in response to an error in the PAC script. This may be
37 // called after cancellation and from any thread.
38 virtual void OnError(int line_number, const base::string16& message) = 0;
40 // Returns a HostResolver to use for DNS resolution. This will only be
41 // called from the origin thread and will never be called after
42 // cancellation.
43 virtual HostResolver* GetHostResolver() = 0;
45 // Returns a BoundNetLog to be passed to the HostResolver returned by
46 // GetHostResolver(). This will only be called from the origin thread and
47 // will never be called after cancellation.
48 virtual BoundNetLog GetBoundNetLog() = 0;
50 private:
51 DISALLOW_COPY_AND_ASSIGN(Bindings);
54 virtual ~ProxyResolverV8Tracing() {}
56 // Gets a list of proxy servers to use for |url|. This request always
57 // runs asynchronously and notifies the result by running |callback|. If the
58 // result code is OK then the request was successful and |results| contains
59 // the proxy resolution information. If |request| is non-null, |*request| is
60 // written to, and can be passed to CancelRequest().
61 virtual void GetProxyForURL(const GURL& url,
62 ProxyInfo* results,
63 const CompletionCallback& callback,
64 ProxyResolver::RequestHandle* request,
65 scoped_ptr<Bindings> bindings) = 0;
67 // Cancels |request|.
68 virtual void CancelRequest(ProxyResolver::RequestHandle request) = 0;
70 // Gets the LoadState for |request|.
71 virtual LoadState GetLoadState(
72 ProxyResolver::RequestHandle request) const = 0;
75 // A factory for ProxyResolverV8Tracing instances. The default implementation,
76 // returned by Create(), creates ProxyResolverV8Tracing instances that execute
77 // ProxyResolverV8 on a single helper thread, and do some magic to avoid
78 // blocking in DNS. For more details see the design document:
79 // https://docs.google.com/a/google.com/document/d/16Ij5OcVnR3s0MH4Z5XkhI9VTPoMJdaBn9rKreAmGOdE/edit?pli=1
80 class NET_EXPORT ProxyResolverV8TracingFactory {
81 public:
82 ProxyResolverV8TracingFactory() {}
83 virtual ~ProxyResolverV8TracingFactory() = default;
85 virtual void CreateProxyResolverV8Tracing(
86 const scoped_refptr<ProxyResolverScriptData>& pac_script,
87 scoped_ptr<ProxyResolverV8Tracing::Bindings> bindings,
88 scoped_ptr<ProxyResolverV8Tracing>* resolver,
89 const CompletionCallback& callback,
90 scoped_ptr<ProxyResolverFactory::Request>* request) = 0;
92 static scoped_ptr<ProxyResolverV8TracingFactory> Create();
94 private:
95 DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8TracingFactory);
98 } // namespace net
100 #endif // NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_