| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_ | |
| 6 #define NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/threading/non_thread_safe.h" | |
| 12 #include "net/base/net_export.h" | |
| 13 #include "net/proxy/proxy_resolver.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class Thread; | |
| 17 class MessageLoopProxy; | |
| 18 } // namespace base | |
| 19 | |
| 20 namespace net { | |
| 21 | |
| 22 class HostResolver; | |
| 23 class NetLog; | |
| 24 class ProxyResolverErrorObserver; | |
| 25 class ProxyResolverV8; | |
| 26 | |
| 27 // ProxyResolverV8Tracing is a non-blocking ProxyResolver. It executes | |
| 28 // ProxyResolverV8 on a single helper thread, and does some magic to avoid | |
| 29 // 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 | |
| 31 class NET_EXPORT_PRIVATE ProxyResolverV8Tracing | |
| 32 : public ProxyResolver, | |
| 33 NON_EXPORTED_BASE(public base::NonThreadSafe) { | |
| 34 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 | |
| 40 // |host_resolver| and |net_log| are expected to outlive |this|. | |
| 41 ProxyResolverV8Tracing(HostResolver* host_resolver, | |
| 42 ProxyResolverErrorObserver* error_observer, | |
| 43 NetLog* net_log); | |
| 44 | |
| 45 ~ProxyResolverV8Tracing() override; | |
| 46 | |
| 47 // ProxyResolver implementation: | |
| 48 int GetProxyForURL(const GURL& url, | |
| 49 ProxyInfo* results, | |
| 50 const CompletionCallback& callback, | |
| 51 RequestHandle* request, | |
| 52 const BoundNetLog& net_log) override; | |
| 53 void CancelRequest(RequestHandle request) override; | |
| 54 LoadState GetLoadState(RequestHandle request) const override; | |
| 55 void CancelSetPacScript() override; | |
| 56 int SetPacScript(const scoped_refptr<ProxyResolverScriptData>& script_data, | |
| 57 const CompletionCallback& callback) override; | |
| 58 | |
| 59 private: | |
| 60 class Job; | |
| 61 | |
| 62 // The worker thread on which the ProxyResolverV8 will be run. | |
| 63 scoped_ptr<base::Thread> thread_; | |
| 64 scoped_ptr<ProxyResolverV8> v8_resolver_; | |
| 65 | |
| 66 // Non-owned host resolver, which is to be operated on the origin thread. | |
| 67 HostResolver* host_resolver_; | |
| 68 | |
| 69 scoped_ptr<ProxyResolverErrorObserver> error_observer_; | |
| 70 NetLog* net_log_; | |
| 71 | |
| 72 // The outstanding SetPacScript operation, or NULL. | |
| 73 scoped_refptr<Job> set_pac_script_job_; | |
| 74 | |
| 75 // The number of outstanding (non-cancelled) jobs. | |
| 76 int num_outstanding_callbacks_; | |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8Tracing); | |
| 79 }; | |
| 80 | |
| 81 } // namespace net | |
| 82 | |
| 83 #endif // NET_PROXY_PROXY_RESOLVER_V8_TRACING_H_ | |
| OLD | NEW |