summaryrefslogtreecommitdiffstats
path: root/net/base
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-12 00:25:12 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-12 00:25:12 +0000
commitec08bb23238e41b66daa676c3c55f23544a0de14 (patch)
treeaef939a8d5cccb67d037d8d055380a82e95bbfaa /net/base
parentdb471b330fc82a9f450807ec1f4307c29dda23c4 (diff)
downloadchromium_src-ec08bb23238e41b66daa676c3c55f23544a0de14.zip
chromium_src-ec08bb23238e41b66daa676c3c55f23544a0de14.tar.gz
chromium_src-ec08bb23238e41b66daa676c3c55f23544a0de14.tar.bz2
Add a "LoadLog" parameter to transactions, hostresolver, clientsocketpool and proyxservice.This dependency comes from the parent URLRequest, and is used as a container for per-request profiling data.This change is strictly a no-op refactor -- the parameter is unused, and LoadLog does nothing.BUG=http://crbug.com/14478TEST=none -- just needs to compile and pass existing tests.DESIGN=<http://docs.google.com/Doc?id=dfhcnb2v_21gbtrcpr3&hl=en>
Review URL: http://codereview.chromium.org/126303 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23127 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r--net/base/host_resolver.cc6
-rw-r--r--net/base/host_resolver.h16
-rw-r--r--net/base/host_resolver_impl.cc3
-rw-r--r--net/base/host_resolver_impl.h7
-rw-r--r--net/base/host_resolver_impl_unittest.cc30
-rw-r--r--net/base/load_log.h24
-rw-r--r--net/base/mock_host_resolver.cc5
-rw-r--r--net/base/mock_host_resolver.h7
8 files changed, 70 insertions, 28 deletions
diff --git a/net/base/host_resolver.cc b/net/base/host_resolver.cc
index 1d17296..4208492 100644
--- a/net/base/host_resolver.cc
+++ b/net/base/host_resolver.cc
@@ -25,7 +25,8 @@ SingleRequestHostResolver::~SingleRequestHostResolver() {
}
}
-int SingleRequestHostResolver::Resolve(const HostResolver::RequestInfo& info,
+int SingleRequestHostResolver::Resolve(LoadLog* load_log,
+ const HostResolver::RequestInfo& info,
AddressList* addresses,
CompletionCallback* callback) {
DCHECK(!cur_request_ && !cur_request_callback_) << "resolver already in use";
@@ -36,7 +37,8 @@ int SingleRequestHostResolver::Resolve(const HostResolver::RequestInfo& info,
// we can clear out |cur_request_*|.
CompletionCallback* transient_callback = callback ? &callback_ : NULL;
- int rv = resolver_->Resolve(info, addresses, transient_callback, &request);
+ int rv = resolver_->Resolve(
+ load_log, info, addresses, transient_callback, &request);
if (rv == ERR_IO_PENDING) {
// Cleared in OnResolveCompletion().
diff --git a/net/base/host_resolver.h b/net/base/host_resolver.h
index 7bdd70e..b6b4180 100644
--- a/net/base/host_resolver.h
+++ b/net/base/host_resolver.h
@@ -16,6 +16,7 @@ class MessageLoop;
namespace net {
class AddressList;
+class LoadLog;
// This class represents the task of resolving hostnames (or IP address
// literal) to an AddressList object.
@@ -111,8 +112,13 @@ class HostResolver : public base::RefCounted<HostResolver> {
// result code will be passed to the completion callback. If |req| is
// non-NULL, then |*req| will be filled with a handle to the async request.
// This handle is not valid after the request has completed.
- virtual int Resolve(const RequestInfo& info, AddressList* addresses,
- CompletionCallback* callback, RequestHandle* out_req) = 0;
+ //
+ // Profiling information for the request is saved to |load_log| if non-NULL.
+ virtual int Resolve(LoadLog* load_log,
+ const RequestInfo& info,
+ AddressList* addresses,
+ CompletionCallback* callback,
+ RequestHandle* out_req) = 0;
// Cancels the specified request. |req| is the handle returned by Resolve().
// After a request is cancelled, its completion callback will not be called.
@@ -146,8 +152,10 @@ class SingleRequestHostResolver {
// Resolves the given hostname (or IP address literal), filling out the
// |addresses| object upon success. See HostResolver::Resolve() for details.
- int Resolve(const HostResolver::RequestInfo& info,
- AddressList* addresses, CompletionCallback* callback);
+ int Resolve(LoadLog* load_log,
+ const HostResolver::RequestInfo& info,
+ AddressList* addresses,
+ CompletionCallback* callback);
private:
// Callback for when the request to |resolver_| completes, so we dispatch
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc
index 702f2f0..111e8da 100644
--- a/net/base/host_resolver_impl.cc
+++ b/net/base/host_resolver_impl.cc
@@ -289,7 +289,8 @@ HostResolverImpl::~HostResolverImpl() {
// TODO(eroman): Don't create cache entries for hostnames which are simply IP
// address literals.
-int HostResolverImpl::Resolve(const RequestInfo& info,
+int HostResolverImpl::Resolve(LoadLog* load_log,
+ const RequestInfo& info,
AddressList* addresses,
CompletionCallback* callback,
RequestHandle* out_req) {
diff --git a/net/base/host_resolver_impl.h b/net/base/host_resolver_impl.h
index 6ece456..ff9e4e7 100644
--- a/net/base/host_resolver_impl.h
+++ b/net/base/host_resolver_impl.h
@@ -57,8 +57,11 @@ class HostResolverImpl : public HostResolver {
virtual ~HostResolverImpl();
// HostResolver methods:
- virtual int Resolve(const RequestInfo& info, AddressList* addresses,
- CompletionCallback* callback, RequestHandle* out_req);
+ virtual int Resolve(LoadLog* load_log,
+ const RequestInfo& info,
+ AddressList* addresses,
+ CompletionCallback* callback,
+ RequestHandle* out_req);
virtual void CancelRequest(RequestHandle req);
virtual void AddObserver(Observer* observer);
virtual void RemoveObserver(Observer* observer);
diff --git a/net/base/host_resolver_impl_unittest.cc b/net/base/host_resolver_impl_unittest.cc
index 350a25d..e33bbf4e 100644
--- a/net/base/host_resolver_impl_unittest.cc
+++ b/net/base/host_resolver_impl_unittest.cc
@@ -91,7 +91,7 @@ class ResolveRequest {
ALLOW_THIS_IN_INITIALIZER_LIST(
callback_(this, &ResolveRequest::OnLookupFinished)) {
// Start the request.
- int err = resolver->Resolve(info_, &addrlist_, &callback_, &req_);
+ int err = resolver->Resolve(NULL, info_, &addrlist_, &callback_, &req_);
EXPECT_EQ(net::ERR_IO_PENDING, err);
}
@@ -102,7 +102,7 @@ class ResolveRequest {
ALLOW_THIS_IN_INITIALIZER_LIST(
callback_(this, &ResolveRequest::OnLookupFinished)) {
// Start the request.
- int err = resolver->Resolve(info, &addrlist_, &callback_, &req_);
+ int err = resolver->Resolve(NULL, info, &addrlist_, &callback_, &req_);
EXPECT_EQ(net::ERR_IO_PENDING, err);
}
@@ -187,7 +187,7 @@ TEST_F(HostResolverImplTest, SynchronousLookup) {
new HostResolverImpl(resolver_proc, kMaxCacheEntries, kMaxCacheAgeMs));
net::HostResolver::RequestInfo info("just.testing", kPortnum);
- int err = host_resolver->Resolve(info, &adrlist, NULL, NULL);
+ int err = host_resolver->Resolve(NULL, info, &adrlist, NULL, NULL);
EXPECT_EQ(net::OK, err);
const struct addrinfo* ainfo = adrlist.head();
@@ -212,7 +212,7 @@ TEST_F(HostResolverImplTest, AsynchronousLookup) {
new HostResolverImpl(resolver_proc, kMaxCacheEntries, kMaxCacheAgeMs));
net::HostResolver::RequestInfo info("just.testing", kPortnum);
- int err = host_resolver->Resolve(info, &adrlist, &callback_, NULL);
+ int err = host_resolver->Resolve(NULL, info, &adrlist, &callback_, NULL);
EXPECT_EQ(net::ERR_IO_PENDING, err);
MessageLoop::current()->Run();
@@ -241,7 +241,7 @@ TEST_F(HostResolverImplTest, CanceledAsynchronousLookup) {
const int kPortnum = 80;
net::HostResolver::RequestInfo info("just.testing", kPortnum);
- int err = host_resolver->Resolve(info, &adrlist, &callback_, NULL);
+ int err = host_resolver->Resolve(NULL, info, &adrlist, &callback_, NULL);
EXPECT_EQ(net::ERR_IO_PENDING, err);
// Make sure we will exit the queue even when callback is not called.
@@ -268,7 +268,7 @@ TEST_F(HostResolverImplTest, NumericIPv4Address) {
net::AddressList adrlist;
const int kPortnum = 5555;
net::HostResolver::RequestInfo info("127.1.2.3", kPortnum);
- int err = host_resolver->Resolve(info, &adrlist, NULL, NULL);
+ int err = host_resolver->Resolve(NULL, info, &adrlist, NULL, NULL);
EXPECT_EQ(net::OK, err);
const struct addrinfo* ainfo = adrlist.head();
@@ -293,7 +293,7 @@ TEST_F(HostResolverImplTest, NumericIPv6Address) {
net::AddressList adrlist;
const int kPortnum = 5555;
net::HostResolver::RequestInfo info("2001:db8::1", kPortnum);
- int err = host_resolver->Resolve(info, &adrlist, NULL, NULL);
+ int err = host_resolver->Resolve(NULL, info, &adrlist, NULL, NULL);
// On computers without IPv6 support, getaddrinfo cannot convert IPv6
// address literals to addresses (getaddrinfo returns EAI_NONAME). So this
// test has to allow host_resolver->Resolve to fail.
@@ -333,7 +333,7 @@ TEST_F(HostResolverImplTest, DISABLED_EmptyHost) {
net::AddressList adrlist;
const int kPortnum = 5555;
net::HostResolver::RequestInfo info("", kPortnum);
- int err = host_resolver->Resolve(info, &adrlist, NULL, NULL);
+ int err = host_resolver->Resolve(NULL, info, &adrlist, NULL, NULL);
EXPECT_EQ(net::ERR_NAME_NOT_RESOLVED, err);
}
@@ -684,7 +684,7 @@ class BypassCacheVerifier : public ResolveRequest::Delegate {
net::AddressList addrlist;
net::HostResolver::RequestInfo info("a", 70);
- int error = resolver->Resolve(info, &addrlist, junk_callback, NULL);
+ int error = resolver->Resolve(NULL, info, &addrlist, junk_callback, NULL);
EXPECT_EQ(net::OK, error);
// Ok good. Now make sure that if we ask to bypass the cache, it can no
@@ -801,7 +801,7 @@ TEST_F(HostResolverImplTest, Observers) {
// Resolve "host1".
net::HostResolver::RequestInfo info1("host1", 70);
- int rv = host_resolver->Resolve(info1, &addrlist, NULL, NULL);
+ int rv = host_resolver->Resolve(NULL, info1, &addrlist, NULL, NULL);
EXPECT_EQ(net::OK, rv);
EXPECT_EQ(1U, observer.start_log.size());
@@ -815,7 +815,7 @@ TEST_F(HostResolverImplTest, Observers) {
// Resolve "host1" again -- this time it will be served from cache, but it
// should still notify of completion.
TestCompletionCallback callback;
- rv = host_resolver->Resolve(info1, &addrlist, &callback, NULL);
+ rv = host_resolver->Resolve(NULL, info1, &addrlist, &callback, NULL);
ASSERT_EQ(net::OK, rv); // Should complete synchronously.
EXPECT_EQ(2U, observer.start_log.size());
@@ -829,7 +829,7 @@ TEST_F(HostResolverImplTest, Observers) {
// Resolve "host2", setting referrer to "http://foobar.com"
net::HostResolver::RequestInfo info2("host2", 70);
info2.set_referrer(GURL("http://foobar.com"));
- rv = host_resolver->Resolve(info2, &addrlist, NULL, NULL);
+ rv = host_resolver->Resolve(NULL, info2, &addrlist, NULL, NULL);
EXPECT_EQ(net::OK, rv);
EXPECT_EQ(3U, observer.start_log.size());
@@ -845,7 +845,7 @@ TEST_F(HostResolverImplTest, Observers) {
// Resolve "host3"
net::HostResolver::RequestInfo info3("host3", 70);
- host_resolver->Resolve(info3, &addrlist, NULL, NULL);
+ host_resolver->Resolve(NULL, info3, &addrlist, NULL, NULL);
// No effect this time, since observer was removed.
EXPECT_EQ(3U, observer.start_log.size());
@@ -875,7 +875,7 @@ TEST_F(HostResolverImplTest, CancellationObserver) {
net::HostResolver::RequestInfo info1("host1", 70);
net::HostResolver::RequestHandle req = NULL;
net::AddressList addrlist;
- int rv = host_resolver->Resolve(info1, &addrlist, &callback, &req);
+ int rv = host_resolver->Resolve(NULL, info1, &addrlist, &callback, &req);
EXPECT_EQ(net::ERR_IO_PENDING, rv);
EXPECT_TRUE(NULL != req);
@@ -898,7 +898,7 @@ TEST_F(HostResolverImplTest, CancellationObserver) {
// Start an async request for (host2:60)
net::HostResolver::RequestInfo info2("host2", 60);
- rv = host_resolver->Resolve(info2, &addrlist, &callback, NULL);
+ rv = host_resolver->Resolve(NULL, info2, &addrlist, &callback, NULL);
EXPECT_EQ(net::ERR_IO_PENDING, rv);
EXPECT_TRUE(NULL != req);
diff --git a/net/base/load_log.h b/net/base/load_log.h
new file mode 100644
index 0000000..0efe242
--- /dev/null
+++ b/net/base/load_log.h
@@ -0,0 +1,24 @@
+// 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.
+
+#ifndef NET_BASE_LOAD_LOG_H_
+#define NET_BASE_LOAD_LOG_H_
+
+#include "base/ref_counted.h"
+
+namespace net {
+
+// LoadLog stores profiling information on where time was spent while servicing
+// a request (waiting in queues, resolving hosts, resolving proxy, etc...).
+class LoadLog : public base::RefCounted<LoadLog> {
+ public:
+// TODO(eroman): Add an API similar to:
+// void TrackEnterState(LoadState state);
+// void TrackLeaveState(LoadState state);
+// void Merge(const LoadLog* other);
+};
+
+} // namespace net
+
+#endif // NET_BASE_LOAD_LOG_H_
diff --git a/net/base/mock_host_resolver.cc b/net/base/mock_host_resolver.cc
index c83f3c8..32a66d1 100644
--- a/net/base/mock_host_resolver.cc
+++ b/net/base/mock_host_resolver.cc
@@ -42,7 +42,8 @@ MockHostResolverBase::MockHostResolverBase(bool use_caching)
Reset(NULL);
}
-int MockHostResolverBase::Resolve(const RequestInfo& info,
+int MockHostResolverBase::Resolve(LoadLog* load_log,
+ const RequestInfo& info,
AddressList* addresses,
CompletionCallback* callback,
RequestHandle* out_req) {
@@ -50,7 +51,7 @@ int MockHostResolverBase::Resolve(const RequestInfo& info,
callback = NULL;
out_req = NULL;
}
- return impl_->Resolve(info, addresses, callback, out_req);
+ return impl_->Resolve(load_log, info, addresses, callback, out_req);
}
void MockHostResolverBase::CancelRequest(RequestHandle req) {
diff --git a/net/base/mock_host_resolver.h b/net/base/mock_host_resolver.h
index d3d3f44..2dd97b9 100644
--- a/net/base/mock_host_resolver.h
+++ b/net/base/mock_host_resolver.h
@@ -41,8 +41,11 @@ class MockHostResolverBase : public HostResolver {
virtual ~MockHostResolverBase() {}
// HostResolver methods:
- virtual int Resolve(const RequestInfo& info, AddressList* addresses,
- CompletionCallback* callback, RequestHandle* out_req);
+ virtual int Resolve(LoadLog* load_log,
+ const RequestInfo& info,
+ AddressList* addresses,
+ CompletionCallback* callback,
+ RequestHandle* out_req);
virtual void CancelRequest(RequestHandle req);
virtual void AddObserver(Observer* observer);
virtual void RemoveObserver(Observer* observer);