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

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

Issue 1126513002: Add ProxyResolverFactoryV8Tracing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-proxy-refactor
Patch Set: Created 5 years, 7 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
8 #include "base/basictypes.h" 10 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
11 #include "base/threading/non_thread_safe.h"
12 #include "net/base/net_export.h" 13 #include "net/base/net_export.h"
13 #include "net/proxy/proxy_resolver.h" 14 #include "net/proxy/proxy_resolver.h"
14 15 #include "net/proxy/proxy_resolver_factory.h"
15 namespace base {
16 class Thread;
17 class MessageLoopProxy;
18 } // namespace base
19 16
20 namespace net { 17 namespace net {
21 18
22 class HostResolver; 19 class HostResolver;
23 class NetLog; 20 class NetLog;
24 class ProxyResolverErrorObserver; 21 class ProxyResolverErrorObserver;
25 class ProxyResolverV8;
26 22
27 // ProxyResolverV8Tracing is a non-blocking ProxyResolver. It executes 23 // ProxyResolverV8Tracing is a non-blocking ProxyResolver. It executes
eroman 2015/05/05 00:04:55 This reads a bit funny because the class below is
Sam McNally 2015/05/05 01:31:37 Done.
28 // ProxyResolverV8 on a single helper thread, and does some magic to avoid 24 // ProxyResolverV8 on a single helper thread, and does some magic to avoid
29 // blocking in DNS. For more details see the design document: 25 // blocking in DNS. For more details see the design document:
30 // https://docs.google.com/a/google.com/document/d/16Ij5OcVnR3s0MH4Z5XkhI9VTPoMJ daBn9rKreAmGOdE/edit?pli=1 26 // https://docs.google.com/a/google.com/document/d/16Ij5OcVnR3s0MH4Z5XkhI9VTPoMJ daBn9rKreAmGOdE/edit?pli=1
31 class NET_EXPORT_PRIVATE ProxyResolverV8Tracing 27 class NET_EXPORT ProxyResolverFactoryV8Tracing : public ProxyResolverFactory {
32 : public ProxyResolver,
33 NON_EXPORTED_BASE(public base::NonThreadSafe) {
34 public: 28 public:
35 // Constructs a ProxyResolver that will issue DNS requests through
36 // |host_resolver|, forward Javascript errors through |error_observer|, and
37 // log Javascript errors and alerts to |net_log|.
38 //
39 // Note that the constructor takes ownership of |error_observer|, whereas 29 // Note that the constructor takes ownership of |error_observer|, whereas
eroman 2015/05/05 00:04:55 remove reference to |error_observer|
Sam McNally 2015/05/05 01:31:37 Done.
40 // |host_resolver| and |net_log| are expected to outlive |this|. 30 // |host_resolver| and |net_log| are expected to outlive |this| and any
41 ProxyResolverV8Tracing(HostResolver* host_resolver, 31 // ProxyResolver instances created using |this|.
42 ProxyResolverErrorObserver* error_observer, 32 ProxyResolverFactoryV8Tracing(
43 NetLog* net_log); 33 HostResolver* host_resolver,
34 NetLog* net_log,
35 const ProxyResolver::LoadStateChangedCallback& callback);
eroman 2015/05/05 00:04:55 This seems weird to me -- one callback that applie
Sam McNally 2015/05/05 01:31:37 This is another place where it feels like this mig
44 36
45 // Constructs a ProxyResolver that will issue DNS requests through 37 // ProxyResolverFactory override.
46 // |host_resolver|, forward Javascript errors through |error_observer|, and 38 int CreateProxyResolver(
47 // log Javascript errors and alerts to |net_log|. When the LoadState for a 39 const scoped_refptr<ProxyResolverScriptData>& pac_script,
48 // request changes, |on_load_state_changed| will be invoked with the 40 scoped_ptr<ProxyResolver>* resolver,
49 // RequestHandle for that request with the new LoadState. 41 const CompletionCallback& callback,
50 // 42 scoped_ptr<Request>* request) override;
51 // Note that the constructor takes ownership of |error_observer|, whereas
52 // |host_resolver| and |net_log| are expected to outlive |this|.
53 ProxyResolverV8Tracing(HostResolver* host_resolver,
54 ProxyResolverErrorObserver* error_observer,
55 NetLog* net_log,
56 const LoadStateChangedCallback& on_load_state_changed);
57 43
58 ~ProxyResolverV8Tracing() override; 44 protected:
59 45 ~ProxyResolverFactoryV8Tracing() override;
60 // ProxyResolver implementation:
61 int GetProxyForURL(const GURL& url,
62 ProxyInfo* results,
63 const CompletionCallback& callback,
64 RequestHandle* request,
65 const BoundNetLog& net_log) override;
66 void CancelRequest(RequestHandle request) override;
67 LoadState GetLoadState(RequestHandle request) const override;
68 void CancelSetPacScript() override;
69 int SetPacScript(const scoped_refptr<ProxyResolverScriptData>& script_data,
70 const CompletionCallback& callback) override;
71 46
72 private: 47 private:
73 class Job; 48 class CreateJob;
74 49
75 // The worker thread on which the ProxyResolverV8 will be run. 50 // Invoked to create a ProxyResolverErrorObserver to be used to report proxy
76 scoped_ptr<base::Thread> thread_; 51 // resolver script errors for a ProxyResolver instance.
77 scoped_ptr<ProxyResolverV8> v8_resolver_; 52 virtual scoped_ptr<ProxyResolverErrorObserver> CreateErrorObserver() = 0;
eroman 2015/05/05 00:04:55 Why private and not protected? C++ lets you change
78 53
79 // Non-owned host resolver, which is to be operated on the origin thread. 54 void RemoveJob(CreateJob* job);
80 HostResolver* host_resolver_;
81 55
82 scoped_ptr<ProxyResolverErrorObserver> error_observer_; 56 HostResolver* const host_resolver_;
83 NetLog* net_log_; 57 NetLog* const net_log_;
58 const ProxyResolver::LoadStateChangedCallback load_state_changed_callback_;
84 59
85 // The outstanding SetPacScript operation, or NULL. 60 std::set<CreateJob*> jobs_;
86 scoped_refptr<Job> set_pac_script_job_;
87 61
88 // The number of outstanding (non-cancelled) jobs. 62 DISALLOW_COPY_AND_ASSIGN(ProxyResolverFactoryV8Tracing);
89 int num_outstanding_callbacks_;
90
91 // Invoked when the load state for a request changes.
92 const LoadStateChangedCallback on_load_state_changed_;
93
94 DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8Tracing);
95 }; 63 };
96 64
97 } // namespace net 65 } // namespace net
98 66
99 #endif // NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_ 67 #endif // NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698