Index: net/proxy/proxy_service.cc |
=================================================================== |
--- net/proxy/proxy_service.cc (revision 52046) |
+++ net/proxy/proxy_service.cc (working copy) |
@@ -11,6 +11,7 @@ |
#include "base/message_loop.h" |
#include "base/string_util.h" |
#include "googleurl/src/gurl.h" |
+#include "net/base/forwarding_net_log.h" |
#include "net/base/net_log.h" |
#include "net/base/net_errors.h" |
#include "net/base/net_util.h" |
@@ -79,23 +80,29 @@ |
// This factory creates V8ProxyResolvers with appropriate javascript bindings. |
class ProxyResolverFactoryForV8 : public ProxyResolverFactory { |
public: |
- // Both |async_host_resolver| and |host_resolver_loop| must remain valid for |
- // duration of our lifetime. |
+ // |async_host_resolver|, |io_loop| and |net_log| must remain |
+ // valid for the duration of our lifetime. |
+ // Both |async_host_resolver| and |net_log| will only be operated on |
+ // |io_loop|. |
ProxyResolverFactoryForV8(HostResolver* async_host_resolver, |
- MessageLoop* host_resolver_loop) |
+ MessageLoop* io_loop, |
+ NetLog* net_log) |
: ProxyResolverFactory(true /*expects_pac_bytes*/), |
async_host_resolver_(async_host_resolver), |
- host_resolver_loop_(host_resolver_loop) { |
+ io_loop_(io_loop), |
+ forwarding_net_log_( |
+ net_log ? new ForwardingNetLog(net_log, io_loop) : NULL) { |
} |
virtual ProxyResolver* CreateProxyResolver() { |
// Create a synchronous host resolver wrapper that operates |
- // |async_host_resolver_| on |host_resolver_loop_|. |
+ // |async_host_resolver_| on |io_loop_|. |
SyncHostResolverBridge* sync_host_resolver = |
- new SyncHostResolverBridge(async_host_resolver_, host_resolver_loop_); |
+ new SyncHostResolverBridge(async_host_resolver_, io_loop_); |
ProxyResolverJSBindings* js_bindings = |
- ProxyResolverJSBindings::CreateDefault(sync_host_resolver); |
+ ProxyResolverJSBindings::CreateDefault(sync_host_resolver, |
+ forwarding_net_log_.get()); |
// ProxyResolverV8 takes ownership of |js_bindings|. |
return new ProxyResolverV8(js_bindings); |
@@ -103,7 +110,11 @@ |
private: |
scoped_refptr<HostResolver> async_host_resolver_; |
- MessageLoop* host_resolver_loop_; |
+ MessageLoop* io_loop_; |
+ |
+ // Thread-safe wrapper around a non-threadsafe NetLog implementation. This |
+ // enables the proxy resolver to emit log messages from the PAC thread. |
+ scoped_ptr<ForwardingNetLog> forwarding_net_log_; |
}; |
// Creates ProxyResolvers using a non-V8 implementation. |
@@ -277,7 +288,8 @@ |
sync_resolver_factory = |
new ProxyResolverFactoryForV8( |
url_request_context->host_resolver(), |
- io_loop); |
+ io_loop, |
+ net_log); |
} else { |
sync_resolver_factory = new ProxyResolverFactoryForNonV8(); |
} |