Chromium Code Reviews| Index: net/proxy/proxy_resolver_v8_tracing.h |
| diff --git a/net/proxy/proxy_resolver_v8_tracing.h b/net/proxy/proxy_resolver_v8_tracing.h |
| index d1666638fb08b0387cae2bbf4c6f1a33337e587f..6cf1b20a6e8f7a7a7a28e4257cdef3a7c5fc84cb 100644 |
| --- a/net/proxy/proxy_resolver_v8_tracing.h |
| +++ b/net/proxy/proxy_resolver_v8_tracing.h |
| @@ -5,93 +5,61 @@ |
| #ifndef NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_ |
| #define NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_ |
| +#include <set> |
| + |
| #include "base/basictypes.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| -#include "base/threading/non_thread_safe.h" |
| #include "net/base/net_export.h" |
| #include "net/proxy/proxy_resolver.h" |
| - |
| -namespace base { |
| -class Thread; |
| -class MessageLoopProxy; |
| -} // namespace base |
| +#include "net/proxy/proxy_resolver_factory.h" |
| namespace net { |
| class HostResolver; |
| class NetLog; |
| class ProxyResolverErrorObserver; |
| -class ProxyResolverV8; |
| // 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.
|
| // ProxyResolverV8 on a single helper thread, and does some magic to avoid |
| // blocking in DNS. For more details see the design document: |
| // https://docs.google.com/a/google.com/document/d/16Ij5OcVnR3s0MH4Z5XkhI9VTPoMJdaBn9rKreAmGOdE/edit?pli=1 |
| -class NET_EXPORT_PRIVATE ProxyResolverV8Tracing |
| - : public ProxyResolver, |
| - NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| +class NET_EXPORT ProxyResolverFactoryV8Tracing : public ProxyResolverFactory { |
| public: |
| - // Constructs a ProxyResolver that will issue DNS requests through |
| - // |host_resolver|, forward Javascript errors through |error_observer|, and |
| - // log Javascript errors and alerts to |net_log|. |
| - // |
| - // Note that the constructor takes ownership of |error_observer|, whereas |
| - // |host_resolver| and |net_log| are expected to outlive |this|. |
| - ProxyResolverV8Tracing(HostResolver* host_resolver, |
| - ProxyResolverErrorObserver* error_observer, |
| - NetLog* net_log); |
| - |
| - // Constructs a ProxyResolver that will issue DNS requests through |
| - // |host_resolver|, forward Javascript errors through |error_observer|, and |
| - // log Javascript errors and alerts to |net_log|. When the LoadState for a |
| - // request changes, |on_load_state_changed| will be invoked with the |
| - // RequestHandle for that request with the new LoadState. |
| - // |
| // 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.
|
| - // |host_resolver| and |net_log| are expected to outlive |this|. |
| - ProxyResolverV8Tracing(HostResolver* host_resolver, |
| - ProxyResolverErrorObserver* error_observer, |
| - NetLog* net_log, |
| - const LoadStateChangedCallback& on_load_state_changed); |
| - |
| - ~ProxyResolverV8Tracing() override; |
| - |
| - // ProxyResolver implementation: |
| - int GetProxyForURL(const GURL& url, |
| - ProxyInfo* results, |
| - const CompletionCallback& callback, |
| - RequestHandle* request, |
| - const BoundNetLog& net_log) override; |
| - void CancelRequest(RequestHandle request) override; |
| - LoadState GetLoadState(RequestHandle request) const override; |
| - void CancelSetPacScript() override; |
| - int SetPacScript(const scoped_refptr<ProxyResolverScriptData>& script_data, |
| - const CompletionCallback& callback) override; |
| + // |host_resolver| and |net_log| are expected to outlive |this| and any |
| + // ProxyResolver instances created using |this|. |
| + ProxyResolverFactoryV8Tracing( |
| + HostResolver* host_resolver, |
| + NetLog* net_log, |
| + 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
|
| + |
| + // ProxyResolverFactory override. |
| + int CreateProxyResolver( |
| + const scoped_refptr<ProxyResolverScriptData>& pac_script, |
| + scoped_ptr<ProxyResolver>* resolver, |
| + const CompletionCallback& callback, |
| + scoped_ptr<Request>* request) override; |
| + |
| + protected: |
| + ~ProxyResolverFactoryV8Tracing() override; |
| private: |
| - class Job; |
| - |
| - // The worker thread on which the ProxyResolverV8 will be run. |
| - scoped_ptr<base::Thread> thread_; |
| - scoped_ptr<ProxyResolverV8> v8_resolver_; |
| - |
| - // Non-owned host resolver, which is to be operated on the origin thread. |
| - HostResolver* host_resolver_; |
| + class CreateJob; |
| - scoped_ptr<ProxyResolverErrorObserver> error_observer_; |
| - NetLog* net_log_; |
| + // Invoked to create a ProxyResolverErrorObserver to be used to report proxy |
| + // resolver script errors for a ProxyResolver instance. |
| + virtual scoped_ptr<ProxyResolverErrorObserver> CreateErrorObserver() = 0; |
|
eroman
2015/05/05 00:04:55
Why private and not protected? C++ lets you change
|
| - // The outstanding SetPacScript operation, or NULL. |
| - scoped_refptr<Job> set_pac_script_job_; |
| + void RemoveJob(CreateJob* job); |
| - // The number of outstanding (non-cancelled) jobs. |
| - int num_outstanding_callbacks_; |
| + HostResolver* const host_resolver_; |
| + NetLog* const net_log_; |
| + const ProxyResolver::LoadStateChangedCallback load_state_changed_callback_; |
| - // Invoked when the load state for a request changes. |
| - const LoadStateChangedCallback on_load_state_changed_; |
| + std::set<CreateJob*> jobs_; |
| - DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8Tracing); |
| + DISALLOW_COPY_AND_ASSIGN(ProxyResolverFactoryV8Tracing); |
| }; |
| } // namespace net |