summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-16 21:41:10 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-16 21:41:10 +0000
commit4c2464b49571049ad7128343bfafa9abb3be7e0c (patch)
tree720f5a9c678057babcfed67f3b7f6f2bb972a35f /chrome/browser
parent778b07162832ede8794dc72f859534d7ff6849a2 (diff)
downloadchromium_src-4c2464b49571049ad7128343bfafa9abb3be7e0c.zip
chromium_src-4c2464b49571049ad7128343bfafa9abb3be7e0c.tar.gz
chromium_src-4c2464b49571049ad7128343bfafa9abb3be7e0c.tar.bz2
Move over another legacy "LoadLog-style" event generator to routing its messages through the NetLog.
BUG=37421 Review URL: http://codereview.chromium.org/1052002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41768 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc3
-rw-r--r--chrome/browser/net/passive_log_collector.cc35
-rw-r--r--chrome/browser/net/passive_log_collector.h21
-rw-r--r--chrome/browser/net/resolve_proxy_msg_helper_unittest.cc6
-rw-r--r--chrome/browser/net/view_net_internals_job_factory.cc8
5 files changed, 68 insertions, 5 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index 7ad6ecf..81b9fb5 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -82,6 +82,7 @@ net::ProxyConfigService* CreateProxyConfigService(
// Create a proxy service according to the options on command line.
net::ProxyService* CreateProxyService(
net::NetworkChangeNotifier* network_change_notifier,
+ net::NetLog* net_log,
URLRequestContext* context,
net::ProxyConfigService* proxy_config_service,
const CommandLine& command_line,
@@ -101,6 +102,7 @@ net::ProxyService* CreateProxyService(
use_v8,
context,
network_change_notifier,
+ net_log,
io_loop);
}
@@ -150,6 +152,7 @@ ChromeURLRequestContext* FactoryForOriginal::Create() {
context->set_proxy_service(
CreateProxyService(io_thread()->globals()->network_change_notifier.get(),
+ io_thread()->globals()->net_log.get(),
context,
proxy_config_service_.release(),
command_line,
diff --git a/chrome/browser/net/passive_log_collector.cc b/chrome/browser/net/passive_log_collector.cc
index 2fb4e33..33cc8d1 100644
--- a/chrome/browser/net/passive_log_collector.cc
+++ b/chrome/browser/net/passive_log_collector.cc
@@ -65,6 +65,9 @@ void PassiveLogCollector::OnAddEntry(const net::NetLog::Entry& entry) {
case net::NetLog::SOURCE_CONNECT_JOB:
connect_job_tracker_.OnAddEntry(entry);
break;
+ case net::NetLog::SOURCE_INIT_PROXY_RESOLVER:
+ init_proxy_resolver_tracker_.OnAddEntry(entry);
+ break;
default:
// Drop all other logged events.
break;
@@ -316,3 +319,35 @@ void PassiveLogCollector::RequestTracker::AddConnectJobInfo(
AddEntryToRequestInfo(e, is_unbounded(), live_entry);
}
}
+
+//----------------------------------------------------------------------------
+// InitProxyResolverTracker
+//----------------------------------------------------------------------------
+
+PassiveLogCollector::InitProxyResolverTracker::InitProxyResolverTracker() {}
+
+void PassiveLogCollector::InitProxyResolverTracker::OnAddEntry(
+ const net::NetLog::Entry& entry) {
+ if (entry.type == net::NetLog::Entry::TYPE_EVENT &&
+ entry.event.type == net::NetLog::TYPE_INIT_PROXY_RESOLVER &&
+ entry.event.phase == net::NetLog::PHASE_BEGIN) {
+ // If this is the start of a new InitProxyResolver, overwrite the old data.
+ entries_.clear();
+ entries_.push_back(entry);
+ } else {
+ // Otherwise append it to the log for the latest InitProxyResolver.
+ if (!entries_.empty() && entries_[0].source.id != entry.source.id) {
+ // If this entry doesn't match what we think was the latest
+ // InitProxyResolver, drop it. (This shouldn't happen, but we will guard
+ // against it).
+ return;
+ }
+ entries_.push_back(entry);
+ }
+
+ // Safety net: INIT_PROXY_RESOLVER shouldn't generate many messages, but in
+ // case something goes wrong, avoid exploding the memory usage.
+ if (entries_.size() > kMaxNumEntriesPerLog)
+ entries_.clear();
+}
+
diff --git a/chrome/browser/net/passive_log_collector.h b/chrome/browser/net/passive_log_collector.h
index 2539c27..cfa0d21 100644
--- a/chrome/browser/net/passive_log_collector.h
+++ b/chrome/browser/net/passive_log_collector.h
@@ -110,6 +110,22 @@ class PassiveLogCollector : public ChromeNetLog::Observer {
DISALLOW_COPY_AND_ASSIGN(RequestTracker);
};
+ // Tracks the log entries for the last seen SOURCE_INIT_PROXY_RESOLVER.
+ class InitProxyResolverTracker {
+ public:
+ InitProxyResolverTracker();
+
+ void OnAddEntry(const net::NetLog::Entry& entry);
+
+ const std::vector<net::NetLog::Entry>& entries() const {
+ return entries_;
+ }
+
+ private:
+ std::vector<net::NetLog::Entry> entries_;
+ DISALLOW_COPY_AND_ASSIGN(InitProxyResolverTracker);
+ };
+
PassiveLogCollector();
~PassiveLogCollector();
@@ -127,10 +143,15 @@ class PassiveLogCollector : public ChromeNetLog::Observer {
return &socket_stream_tracker_;
}
+ InitProxyResolverTracker* init_proxy_resolver_tracker() {
+ return &init_proxy_resolver_tracker_;
+ }
+
private:
ConnectJobTracker connect_job_tracker_;
RequestTracker url_request_tracker_;
RequestTracker socket_stream_tracker_;
+ InitProxyResolverTracker init_proxy_resolver_tracker_;
DISALLOW_COPY_AND_ASSIGN(PassiveLogCollector);
};
diff --git a/chrome/browser/net/resolve_proxy_msg_helper_unittest.cc b/chrome/browser/net/resolve_proxy_msg_helper_unittest.cc
index 4d2eeb8..9017f59 100644
--- a/chrome/browser/net/resolve_proxy_msg_helper_unittest.cc
+++ b/chrome/browser/net/resolve_proxy_msg_helper_unittest.cc
@@ -55,7 +55,7 @@ class MyDelegate : public ResolveProxyMsgHelper::Delegate {
TEST(ResolveProxyMsgHelperTest, Sequential) {
net::MockAsyncProxyResolver* resolver = new net::MockAsyncProxyResolver;
scoped_refptr<net::ProxyService> service(
- new net::ProxyService(new MockProxyConfigService, resolver, NULL));
+ new net::ProxyService(new MockProxyConfigService, resolver, NULL, NULL));
MyDelegate delegate;
ResolveProxyMsgHelper helper(&delegate, service);
@@ -118,7 +118,7 @@ TEST(ResolveProxyMsgHelperTest, Sequential) {
TEST(ResolveProxyMsgHelperTest, QueueRequests) {
net::MockAsyncProxyResolver* resolver = new net::MockAsyncProxyResolver;
scoped_refptr<net::ProxyService> service(
- new net::ProxyService(new MockProxyConfigService, resolver, NULL));
+ new net::ProxyService(new MockProxyConfigService, resolver, NULL, NULL));
MyDelegate delegate;
ResolveProxyMsgHelper helper(&delegate, service);
@@ -185,7 +185,7 @@ TEST(ResolveProxyMsgHelperTest, QueueRequests) {
TEST(ResolveProxyMsgHelperTest, CancelPendingRequests) {
net::MockAsyncProxyResolver* resolver = new net::MockAsyncProxyResolver;
scoped_refptr<net::ProxyService> service(
- new net::ProxyService(new MockProxyConfigService, resolver, NULL));
+ new net::ProxyService(new MockProxyConfigService, resolver, NULL, NULL));
MyDelegate delegate;
scoped_ptr<ResolveProxyMsgHelper> helper(
diff --git a/chrome/browser/net/view_net_internals_job_factory.cc b/chrome/browser/net/view_net_internals_job_factory.cc
index 987a54b..aa39f1f 100644
--- a/chrome/browser/net/view_net_internals_job_factory.cc
+++ b/chrome/browser/net/view_net_internals_job_factory.cc
@@ -50,6 +50,11 @@ PassiveLogCollector::RequestTracker* GetSocketStreamTracker(
return GetPassiveLogCollector(context)->socket_stream_tracker();
}
+PassiveLogCollector::InitProxyResolverTracker* GetInitProxyResolverTracker(
+ URLRequestContext* context) {
+ return GetPassiveLogCollector(context)->init_proxy_resolver_tracker();
+}
+
std::string GetDetails(const GURL& url) {
DCHECK(ViewNetInternalsJobFactory::IsSupportedURL(url));
size_t start = strlen(chrome::kNetworkViewInternalsURL);
@@ -254,9 +259,8 @@ class ProxyServiceLastInitLogSubSection : public SubSection {
}
virtual void OutputBody(URLRequestContext* context, std::string* out) {
- net::ProxyService* proxy_service = context->proxy_service();
OutputTextInPre(net::NetLogUtil::PrettyPrintAsEventTree(
- proxy_service->init_proxy_resolver_log().entries(), 0), out);
+ GetInitProxyResolverTracker(context)->entries(), 0), out);
}
};