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

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, 6 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 ProxyResolver. It executes
eroman 2015/06/05 01:11:47 ProxyResolver --> proxy resolver (no longer implem
Sam McNally 2015/06/23 00:32:46 Done.
24 // non-blocking ProxyResolver instances. Each ProxyResolver instance executes
25 // ProxyResolverV8 on a single helper thread, and does some magic to avoid 20 // ProxyResolverV8 on a single helper thread, and does some magic to avoid
eroman 2015/06/05 01:11:47 This comment reads strangely now, since this is no
Sam McNally 2015/06/23 00:32:46 Done.
26 // blocking in DNS. For more details see the design document: 21 // 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 22 // https://docs.google.com/a/google.com/document/d/16Ij5OcVnR3s0MH4Z5XkhI9VTPoMJ daBn9rKreAmGOdE/edit?pli=1
28 class NET_EXPORT ProxyResolverFactoryV8Tracing : public ProxyResolverFactory { 23 class NET_EXPORT ProxyResolverV8Tracing {
29 public: 24 public:
30 // Note that |host_resolver| and |net_log| are expected to outlive |this| and 25 class Bindings {
31 // any ProxyResolver instances created using |this|. |error_observer_factory| 26 public:
32 // will be invoked once per CreateProxyResolver() call to create a 27 Bindings() {}
33 // ProxyResolverErrorObserver to be used by the ProxyResolver instance 28 virtual ~Bindings() {}
eroman 2015/06/05 01:11:47 It would also be useful to give some comments on w
Sam McNally 2015/06/23 00:32:46 Done.
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 29
43 // ProxyResolverFactory override. 30 // Invoked in response to an alert() call by the PAC script. This may be
44 int CreateProxyResolver( 31 // called after cancellation and from any thread.
32 virtual void Alert(const base::string16& message) = 0;
33
34 // Invoked in response to an error in the PAC script. This may be
35 // called after cancellation and from any thread.
36 virtual void OnError(int line_number, const base::string16& message) = 0;
37
38 // Returns a HostResolver to use for DNS resolution. This will only be
39 // called from the origin thread and will never be called after
40 // cancellation.
41 virtual HostResolver* GetHostResolver() = 0;
42
43 // Returns a BoundNetLog to be passed to the HostResolver returned by
44 // GetHostResolver(). This will only be called from the origin thread and
45 // will never be called after cancellation.
46 virtual BoundNetLog GetBoundNetLog() = 0;
47
48 private:
49 DISALLOW_COPY_AND_ASSIGN(Bindings);
50 };
51
52 virtual ~ProxyResolverV8Tracing() {}
53
54 // Gets a list of proxy servers to use for |url|. This request always
55 // runs asynchronously and notifies the result by running |callback|. If the
56 // result code is OK then the request was successful and |results| contains
57 // the proxy resolution information. If |request| is non-null, |*request| is
58 // written to, and can be passed to CancelRequest().
59 virtual void GetProxyForURL(const GURL& url,
60 ProxyInfo* results,
61 const CompletionCallback& callback,
62 ProxyResolver::RequestHandle* request,
63 scoped_ptr<Bindings> bindings) = 0;
64
65 // Cancels |request|.
66 virtual void CancelRequest(ProxyResolver::RequestHandle request) = 0;
67
68 // Gets the LoadState for |request|.
69 virtual LoadState GetLoadState(
70 ProxyResolver::RequestHandle request) const = 0;
71 };
72
73 // A factory for ProxyResolverV8Tracing instances.
74 class NET_EXPORT ProxyResolverV8TracingFactory {
75 public:
76 ProxyResolverV8TracingFactory() {}
77 virtual ~ProxyResolverV8TracingFactory() = default;
78
79 virtual void CreateProxyResolverV8Tracing(
45 const scoped_refptr<ProxyResolverScriptData>& pac_script, 80 const scoped_refptr<ProxyResolverScriptData>& pac_script,
46 scoped_ptr<ProxyResolver>* resolver, 81 scoped_ptr<ProxyResolverV8Tracing::Bindings> bindings,
82 scoped_ptr<ProxyResolverV8Tracing>* resolver,
47 const CompletionCallback& callback, 83 const CompletionCallback& callback,
48 scoped_ptr<Request>* request) override; 84 scoped_ptr<ProxyResolverFactory::Request>* request) = 0;
85
86 static scoped_ptr<ProxyResolverV8TracingFactory> Create();
49 87
50 private: 88 private:
51 class CreateJob; 89 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 }; 90 };
65 91
66 } // namespace net 92 } // namespace net
67 93
68 #endif // NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_ 94 #endif // NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698