Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: net/proxy/proxy_resolver_v8_tracing.h

Issue 1145153004: Split ProxyResolverV8Tracing into an implementation and a wrapper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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_V8_TRACING_H_ 5 #ifndef NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_
6 #define NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_ 6 #define NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_
7 7
8 #include <set>
9
10 #include "base/basictypes.h" 8 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
13 #include "net/base/net_export.h" 11 #include "net/base/net_export.h"
14 #include "net/proxy/proxy_resolver.h" 12 #include "net/proxy/proxy_resolver.h"
15 #include "net/proxy/proxy_resolver_factory.h" 13 #include "net/proxy/proxy_resolver_factory.h"
16 14
17 namespace net { 15 namespace net {
18 16
19 class HostResolver; 17 class HostResolver;
20 class NetLog;
21 class ProxyResolverErrorObserver;
22 18
23 // ProxyResolverFactoryV8Tracing is a ProxyResolverFactory that returns 19 // ProxyResolverV8Tracing is a non-blocking proxy resolver.
24 // non-blocking ProxyResolver instances. Each ProxyResolver instance executes 20 class NET_EXPORT ProxyResolverV8Tracing {
25 // ProxyResolverV8 on a single helper thread, and does some magic to avoid 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() {}
31
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;
35
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;
39
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;
44
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;
49
50 private:
51 DISALLOW_COPY_AND_ASSIGN(Bindings);
52 };
53
54 virtual ~ProxyResolverV8Tracing() {}
55
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;
66
67 // Cancels |request|.
68 virtual void CancelRequest(ProxyResolver::RequestHandle request) = 0;
69
70 // Gets the LoadState for |request|.
71 virtual LoadState GetLoadState(
72 ProxyResolver::RequestHandle request) const = 0;
73 };
74
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
26 // blocking in DNS. For more details see the design document: 78 // blocking in DNS. For more details see the design document:
27 // https://docs.google.com/a/google.com/document/d/16Ij5OcVnR3s0MH4Z5XkhI9VTPoMJ daBn9rKreAmGOdE/edit?pli=1 79 // https://docs.google.com/a/google.com/document/d/16Ij5OcVnR3s0MH4Z5XkhI9VTPoMJ daBn9rKreAmGOdE/edit?pli=1
28 class NET_EXPORT ProxyResolverFactoryV8Tracing : public ProxyResolverFactory { 80 class NET_EXPORT ProxyResolverV8TracingFactory {
29 public: 81 public:
30 // Note that |host_resolver| and |net_log| are expected to outlive |this| and 82 ProxyResolverV8TracingFactory() {}
31 // any ProxyResolver instances created using |this|. |error_observer_factory| 83 virtual ~ProxyResolverV8TracingFactory() = default;
32 // will be invoked once per CreateProxyResolver() call to create a
33 // ProxyResolverErrorObserver to be used by the ProxyResolver instance
34 // returned by that call.
35 ProxyResolverFactoryV8Tracing(
36 HostResolver* host_resolver,
37 NetLog* net_log,
38 const ProxyResolver::LoadStateChangedCallback& callback,
39 const base::Callback<scoped_ptr<ProxyResolverErrorObserver>()>&
40 error_observer_factory);
41 ~ProxyResolverFactoryV8Tracing() override;
42 84
43 // ProxyResolverFactory override. 85 virtual void CreateProxyResolverV8Tracing(
44 int CreateProxyResolver(
45 const scoped_refptr<ProxyResolverScriptData>& pac_script, 86 const scoped_refptr<ProxyResolverScriptData>& pac_script,
46 scoped_ptr<ProxyResolver>* resolver, 87 scoped_ptr<ProxyResolverV8Tracing::Bindings> bindings,
88 scoped_ptr<ProxyResolverV8Tracing>* resolver,
47 const CompletionCallback& callback, 89 const CompletionCallback& callback,
48 scoped_ptr<Request>* request) override; 90 scoped_ptr<ProxyResolverFactory::Request>* request) = 0;
91
92 static scoped_ptr<ProxyResolverV8TracingFactory> Create();
49 93
50 private: 94 private:
51 class CreateJob; 95 DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8TracingFactory);
52
53 void RemoveJob(CreateJob* job);
54
55 HostResolver* const host_resolver_;
56 NetLog* const net_log_;
57 const ProxyResolver::LoadStateChangedCallback load_state_changed_callback_;
58 const base::Callback<scoped_ptr<ProxyResolverErrorObserver>()>
59 error_observer_factory_;
60
61 std::set<CreateJob*> jobs_;
62
63 DISALLOW_COPY_AND_ASSIGN(ProxyResolverFactoryV8Tracing);
64 }; 96 };
65 97
66 } // namespace net 98 } // namespace net
67 99
68 #endif // NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_ 100 #endif // NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_
OLDNEW
« no previous file with comments | « net/proxy/proxy_resolver_factory_mojo_unittest.cc ('k') | net/proxy/proxy_resolver_v8_tracing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698