diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-16 07:03:53 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-16 07:03:53 +0000 |
commit | 9e743cddfd631038fe6f1cdde050e18d61319ec6 (patch) | |
tree | 7ef974e43b23f570433fe819bcd07966165c517f /net/proxy/proxy_resolver_v8.cc | |
parent | 2e7aff66fe443c29b2fc14a776dca5512b0b4729 (diff) | |
download | chromium_src-9e743cddfd631038fe6f1cdde050e18d61319ec6.zip chromium_src-9e743cddfd631038fe6f1cdde050e18d61319ec6.tar.gz chromium_src-9e743cddfd631038fe6f1cdde050e18d61319ec6.tar.bz2 |
Generalize the net module's LoadLog facility from a passive container, to an event stream (NetLog).
This makes it possible to associate a single NetLog with a URLRequestContext, and then attach observers to that log to watch the stream of events.
This changelist attempts to do the most direct translation, so there will be subsequent iterations to clean up.
The user-visible behavior should remain unchanged.
BUG=37421
Review URL: http://codereview.chromium.org/848006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41689 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_resolver_v8.cc')
-rw-r--r-- | net/proxy/proxy_resolver_v8.cc | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/net/proxy/proxy_resolver_v8.cc b/net/proxy/proxy_resolver_v8.cc index 4db6bc3..7687fe7 100644 --- a/net/proxy/proxy_resolver_v8.cc +++ b/net/proxy/proxy_resolver_v8.cc @@ -1,14 +1,14 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this -// source code is governed by a BSD-style license that can be found in the -// LICENSE file. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #include "net/proxy/proxy_resolver_v8.h" #include "base/logging.h" #include "base/string_util.h" #include "googleurl/src/gurl.h" -#include "net/base/load_log.h" #include "net/base/net_errors.h" +#include "net/base/net_log.h" #include "net/proxy/proxy_info.h" #include "net/proxy/proxy_resolver_js_bindings.h" #include "net/proxy/proxy_resolver_script.h" @@ -102,7 +102,7 @@ bool V8ObjectToString(v8::Handle<v8::Value> object, std::string* result) { class ProxyResolverV8::Context { public: explicit Context(ProxyResolverJSBindings* js_bindings) - : js_bindings_(js_bindings), current_request_load_log_(NULL) { + : js_bindings_(js_bindings), current_request_net_log_(NULL) { DCHECK(js_bindings != NULL); } @@ -214,8 +214,8 @@ class ProxyResolverV8::Context { return OK; } - void SetCurrentRequestLoadLog(LoadLog* load_log) { - current_request_load_log_ = load_log; + void SetCurrentRequestNetLog(BoundNetLog* net_log) { + current_request_net_log_ = net_log; } void PurgeMemory() { @@ -293,15 +293,15 @@ class ProxyResolverV8::Context { Context* context = static_cast<Context*>(v8::External::Cast(*args.Data())->Value()); - LoadLog::BeginEvent(context->current_request_load_log_, - LoadLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS); + context->current_request_net_log_->BeginEvent( + NetLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS); // We shouldn't be called with any arguments, but will not complain if // we are. std::string result = context->js_bindings_->MyIpAddress(); - LoadLog::EndEvent(context->current_request_load_log_, - LoadLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS); + context->current_request_net_log_->EndEvent( + NetLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS); if (result.empty()) result = "127.0.0.1"; @@ -314,15 +314,15 @@ class ProxyResolverV8::Context { Context* context = static_cast<Context*>(v8::External::Cast(*args.Data())->Value()); - LoadLog::BeginEvent(context->current_request_load_log_, - LoadLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS_EX); + context->current_request_net_log_->BeginEvent( + NetLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS_EX); // We shouldn't be called with any arguments, but will not complain if // we are. std::string result = context->js_bindings_->MyIpAddressEx(); - LoadLog::EndEvent(context->current_request_load_log_, - LoadLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS_EX); + context->current_request_net_log_->EndEvent( + NetLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS_EX); return StdStringToV8String(result); } @@ -341,13 +341,13 @@ class ProxyResolverV8::Context { return v8::Undefined(); } - LoadLog::BeginEvent(context->current_request_load_log_, - LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE); + context->current_request_net_log_->BeginEvent( + NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE); std::string result = context->js_bindings_->DnsResolve(host); - LoadLog::EndEvent(context->current_request_load_log_, - LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE); + context->current_request_net_log_->EndEvent( + NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE); // DnsResolve() returns empty string on failure. return result.empty() ? v8::Null() : StdStringToV8String(result); @@ -367,19 +367,19 @@ class ProxyResolverV8::Context { return v8::Undefined(); } - LoadLog::BeginEvent(context->current_request_load_log_, - LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE_EX); + context->current_request_net_log_->BeginEvent( + NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE_EX); std::string result = context->js_bindings_->DnsResolveEx(host); - LoadLog::EndEvent(context->current_request_load_log_, - LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE_EX); + context->current_request_net_log_->EndEvent( + NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE_EX); return StdStringToV8String(result); } ProxyResolverJSBindings* js_bindings_; - LoadLog* current_request_load_log_; + BoundNetLog* current_request_net_log_; v8::Persistent<v8::External> v8_this_; v8::Persistent<v8::Context> v8_context_; }; @@ -398,16 +398,18 @@ int ProxyResolverV8::GetProxyForURL(const GURL& query_url, ProxyInfo* results, CompletionCallback* /*callback*/, RequestHandle* /*request*/, - LoadLog* load_log) { + const BoundNetLog& net_log) { // If the V8 instance has not been initialized (either because // SetPacScript() wasn't called yet, or because it failed. if (!context_.get()) return ERR_FAILED; + BoundNetLog log(net_log); + // Otherwise call into V8. - context_->SetCurrentRequestLoadLog(load_log); + context_->SetCurrentRequestNetLog(&log); int rv = context_->ResolveProxy(query_url, results); - context_->SetCurrentRequestLoadLog(NULL); + context_->SetCurrentRequestNetLog(NULL); return rv; } |