summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/io_thread.cc7
-rw-r--r--chrome/browser/io_thread.h2
-rw-r--r--chrome/browser/net/chrome_net_log.cc53
-rw-r--r--chrome/browser/net/chrome_net_log.h54
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc13
-rw-r--r--chrome/browser/net/chrome_url_request_context.h7
-rw-r--r--chrome/browser/net/dns_master.cc3
-rw-r--r--chrome/browser/net/passive_log_collector.cc318
-rw-r--r--chrome/browser/net/passive_log_collector.h138
-rw-r--r--chrome/browser/net/passive_log_collector_unittest.cc213
-rw-r--r--chrome/browser/net/view_net_internals_job_factory.cc101
-rw-r--r--chrome/browser/sync/notifier/communicator/ssl_socket_adapter.cc2
-rw-r--r--chrome/browser/sync/notifier/communicator/ssl_socket_adapter.h4
-rwxr-xr-xchrome/chrome_browser.gypi4
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--net/base/host_resolver.cc4
-rw-r--r--net/base/host_resolver.h8
-rw-r--r--net/base/host_resolver_impl.cc96
-rw-r--r--net/base/host_resolver_impl.h13
-rw-r--r--net/base/host_resolver_impl_unittest.cc63
-rw-r--r--net/base/load_log.cc48
-rw-r--r--net/base/load_log.h196
-rw-r--r--net/base/load_log_unittest.cc185
-rw-r--r--net/base/load_log_util_unittest.cc138
-rw-r--r--net/base/mapped_host_resolver.cc4
-rw-r--r--net/base/mapped_host_resolver.h2
-rw-r--r--net/base/mapped_host_resolver_unittest.cc17
-rw-r--r--net/base/mock_host_resolver.cc4
-rw-r--r--net/base/mock_host_resolver.h2
-rw-r--r--net/base/net_log.cc154
-rw-r--r--net/base/net_log.h238
-rw-r--r--net/base/net_log_event_type_list.h (renamed from net/base/load_log_event_type_list.h)11
-rw-r--r--net/base/net_log_unittest.h (renamed from net/base/load_log_unittest.h)78
-rw-r--r--net/base/net_log_util.cc (renamed from net/base/load_log_util.cc)61
-rw-r--r--net/base/net_log_util.h (renamed from net/base/load_log_util.h)21
-rw-r--r--net/base/net_log_util_unittest.cc145
-rw-r--r--net/ftp/ftp_network_transaction.cc12
-rw-r--r--net/ftp/ftp_network_transaction.h5
-rw-r--r--net/ftp/ftp_transaction.h6
-rw-r--r--net/http/http_basic_stream.cc5
-rw-r--r--net/http/http_basic_stream.h4
-rw-r--r--net/http/http_cache_transaction.cc36
-rw-r--r--net/http/http_cache_transaction.h8
-rw-r--r--net/http/http_cache_unittest.cc86
-rw-r--r--net/http/http_network_layer_unittest.cc3
-rw-r--r--net/http/http_network_transaction.cc66
-rw-r--r--net/http/http_network_transaction.h7
-rw-r--r--net/http/http_network_transaction_unittest.cc24
-rw-r--r--net/http/http_stream_parser.cc10
-rw-r--r--net/http/http_stream_parser.h6
-rw-r--r--net/http/http_transaction.h6
-rw-r--r--net/http/http_transaction_unittest.h7
-rw-r--r--net/net.gyp17
-rw-r--r--net/proxy/init_proxy_resolver.cc42
-rw-r--r--net/proxy/init_proxy_resolver.h7
-rw-r--r--net/proxy/init_proxy_resolver_unittest.cc74
-rw-r--r--net/proxy/mock_proxy_resolver.h2
-rw-r--r--net/proxy/proxy_resolver.h4
-rw-r--r--net/proxy/proxy_resolver_js_bindings.cc12
-rw-r--r--net/proxy/proxy_resolver_js_bindings_unittest.cc9
-rw-r--r--net/proxy/proxy_resolver_mac.cc2
-rw-r--r--net/proxy/proxy_resolver_mac.h2
-rw-r--r--net/proxy/proxy_resolver_v8.cc56
-rw-r--r--net/proxy/proxy_resolver_v8.h2
-rw-r--r--net/proxy/proxy_resolver_v8_unittest.cc44
-rw-r--r--net/proxy/proxy_resolver_winhttp.cc2
-rw-r--r--net/proxy/proxy_resolver_winhttp.h2
-rw-r--r--net/proxy/proxy_service.cc101
-rw-r--r--net/proxy/proxy_service.h28
-rw-r--r--net/proxy/proxy_service_unittest.cc57
-rw-r--r--net/proxy/single_threaded_proxy_resolver.cc45
-rw-r--r--net/proxy/single_threaded_proxy_resolver.h2
-rw-r--r--net/proxy/single_threaded_proxy_resolver_unittest.cc56
-rw-r--r--net/socket/client_socket.h5
-rw-r--r--net/socket/client_socket_handle.h8
-rw-r--r--net/socket/client_socket_pool.h4
-rw-r--r--net/socket/client_socket_pool_base.cc91
-rw-r--r--net/socket/client_socket_pool_base.h34
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc157
-rw-r--r--net/socket/socket_test_util.cc6
-rw-r--r--net/socket/socket_test_util.h10
-rw-r--r--net/socket/socks5_client_socket.cc68
-rw-r--r--net/socket/socks5_client_socket.h7
-rw-r--r--net/socket/socks5_client_socket_unittest.cc44
-rw-r--r--net/socket/socks_client_socket.cc22
-rw-r--r--net/socket/socks_client_socket.h7
-rw-r--r--net/socket/socks_client_socket_unittest.cc76
-rw-r--r--net/socket/ssl_client_socket_mac.cc20
-rw-r--r--net/socket/ssl_client_socket_mac.h6
-rw-r--r--net/socket/ssl_client_socket_nss.cc16
-rw-r--r--net/socket/ssl_client_socket_nss.h7
-rw-r--r--net/socket/ssl_client_socket_unittest.cc34
-rw-r--r--net/socket/ssl_client_socket_win.cc16
-rw-r--r--net/socket/ssl_client_socket_win.h7
-rw-r--r--net/socket/tcp_client_socket_libevent.cc24
-rw-r--r--net/socket/tcp_client_socket_libevent.h7
-rw-r--r--net/socket/tcp_client_socket_pool.cc28
-rw-r--r--net/socket/tcp_client_socket_pool.h6
-rw-r--r--net/socket/tcp_client_socket_pool_unittest.cc6
-rw-r--r--net/socket/tcp_client_socket_unittest.cc14
-rw-r--r--net/socket/tcp_client_socket_win.cc28
-rw-r--r--net/socket/tcp_client_socket_win.h7
-rw-r--r--net/socket_stream/socket_stream.cc49
-rw-r--r--net/socket_stream/socket_stream.h13
-rw-r--r--net/socket_stream/socket_stream_unittest.cc11
-rw-r--r--net/spdy/spdy_network_transaction.cc32
-rw-r--r--net/spdy/spdy_network_transaction.h5
-rw-r--r--net/spdy/spdy_network_transaction_unittest.cc60
-rw-r--r--net/spdy/spdy_session.cc14
-rw-r--r--net/spdy/spdy_session.h6
-rw-r--r--net/spdy/spdy_stream.cc28
-rw-r--r--net/spdy/spdy_stream.h6
-rw-r--r--net/url_request/request_tracker.h192
-rw-r--r--net/url_request/request_tracker_unittest.cc266
-rw-r--r--net/url_request/url_request.cc39
-rw-r--r--net/url_request/url_request.h14
-rw-r--r--net/url_request/url_request_context.h26
-rw-r--r--net/url_request/url_request_http_job.cc2
-rw-r--r--net/url_request/url_request_new_ftp_job.cc2
-rw-r--r--net/url_request/url_request_unittest.cc15
120 files changed, 2543 insertions, 2267 deletions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index cda63ef..2ea8195 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -8,7 +8,9 @@
#include "base/logging.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/net/dns_global.h"
+#include "chrome/browser/net/passive_log_collector.h"
#include "chrome/browser/net/url_fetcher.h"
#include "chrome/common/chrome_switches.h"
#include "net/base/mapped_host_resolver.h"
@@ -124,6 +126,7 @@ void IOThread::Init() {
DCHECK(!globals_);
globals_ = new Globals;
+ globals_->net_log.reset(new ChromeNetLog());
globals_->network_change_notifier.reset(
net::NetworkChangeNotifier::CreateDefaultNetworkChangeNotifier());
globals_->host_resolver =
@@ -241,4 +244,8 @@ void IOThread::ChangedToOnTheRecordOnIOThread() {
if (host_cache)
host_cache->clear();
}
+ // Clear all of the passively logged data.
+ // TODO(eroman): this is a bit heavy handed, really all we need to do is
+ // clear the data pertaining to off the record context.
+ globals_->net_log->passive_collector()->Clear();
}
diff --git a/chrome/browser/io_thread.h b/chrome/browser/io_thread.h
index 6de1bae..404f69e 100644
--- a/chrome/browser/io_thread.h
+++ b/chrome/browser/io_thread.h
@@ -13,6 +13,7 @@
#include "chrome/common/net/dns.h"
#include "net/base/host_resolver.h"
+class ChromeNetLog;
class ListValue;
namespace chrome_browser_net {
@@ -27,6 +28,7 @@ class NetworkChangeNotifier;
class IOThread : public BrowserProcessSubThread {
public:
struct Globals {
+ scoped_ptr<ChromeNetLog> net_log;
scoped_ptr<net::NetworkChangeNotifier> network_change_notifier;
// TODO(willchan): Stop reference counting HostResolver. It's owned by
// IOThread now.
diff --git a/chrome/browser/net/chrome_net_log.cc b/chrome/browser/net/chrome_net_log.cc
new file mode 100644
index 0000000..6abf58a
--- /dev/null
+++ b/chrome/browser/net/chrome_net_log.cc
@@ -0,0 +1,53 @@
+// 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 "chrome/browser/net/chrome_net_log.h"
+
+#include <algorithm>
+
+#include "base/logging.h"
+#include "base/string_util.h"
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/net/passive_log_collector.h"
+
+ChromeNetLog::ChromeNetLog()
+ : next_id_(0),
+ passive_collector_(new PassiveLogCollector) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+ AddObserver(passive_collector_.get());
+}
+
+ChromeNetLog::~ChromeNetLog() {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+ RemoveObserver(passive_collector_.get());
+}
+
+void ChromeNetLog::AddEntry(const Entry& entry) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+
+ // Notify all of the log observers.
+ FOR_EACH_OBSERVER(Observer, observers_, OnAddEntry(entry));
+}
+
+int ChromeNetLog::NextID() {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+ return next_id_++;
+}
+
+bool ChromeNetLog::HasListener() const {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+ // TODO(eroman): Hack to get refactor working.
+ return passive_collector_->url_request_tracker()->IsUnbounded();
+}
+
+void ChromeNetLog::AddObserver(Observer* observer) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+ observers_.AddObserver(observer);
+}
+
+void ChromeNetLog::RemoveObserver(Observer* observer) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+ observers_.RemoveObserver(observer);
+}
+
diff --git a/chrome/browser/net/chrome_net_log.h b/chrome/browser/net/chrome_net_log.h
new file mode 100644
index 0000000..d27c8d0
--- /dev/null
+++ b/chrome/browser/net/chrome_net_log.h
@@ -0,0 +1,54 @@
+// 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.
+
+#ifndef CHROME_BROWSER_NET_CHROME_NET_LOG_H_
+#define CHROME_BROWSER_NET_CHROME_NET_LOG_H_
+
+#include "base/observer_list.h"
+#include "net/base/net_log.h"
+
+class PassiveLogCollector;
+
+// ChromeNetLog is an implementation of NetLog that dispatches network log
+// messages to a list of observers.
+//
+// By default, ChromeNetLog will attach the observer PassiveLogCollector which
+// will keep track of recent request information (which used when displaying
+// the about:net-internals page).
+//
+// TODO(eroman): Move this default observer out of ChromeNetLog.
+//
+class ChromeNetLog : public net::NetLog {
+ public:
+ // Interface for observing the events logged by the network stack.
+ class Observer {
+ public:
+ virtual ~Observer() {}
+ virtual void OnAddEntry(const Entry& entry) = 0;
+ };
+
+ ChromeNetLog();
+ ~ChromeNetLog();
+
+ // NetLog implementation:
+ virtual void AddEntry(const Entry& entry);
+ virtual int NextID();
+ virtual bool HasListener() const;
+
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ PassiveLogCollector* passive_collector() {
+ return passive_collector_.get();
+ }
+
+ private:
+ int next_id_;
+ scoped_ptr<PassiveLogCollector> passive_collector_;
+ ObserverList<Observer, true> observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeNetLog);
+};
+
+#endif // CHROME_BROWSER_NET_CHROME_NET_LOG_H_
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index cc19e5b..7ad6ecf 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/extensions/user_script_master.h"
#include "chrome/browser/io_thread.h"
+#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/net/sqlite_persistent_cookie_store.h"
#include "chrome/browser/net/dns_global.h"
#include "chrome/browser/privacy_blacklist/blacklist.h"
@@ -201,6 +202,7 @@ ChromeURLRequestContext* FactoryForOriginal::Create() {
net::SetURLRequestContextForOCSP(context);
#endif
+ context->set_net_log(io_thread()->globals()->net_log.get());
return context;
}
@@ -293,6 +295,7 @@ ChromeURLRequestContext* FactoryForOffTheRecord::Create() {
context->set_appcache_service(
new ChromeAppCacheService(profile_dir_path_, context));
+ context->set_net_log(io_thread()->globals()->net_log.get());
return context;
}
@@ -595,9 +598,6 @@ void ChromeURLRequestContextGetter::GetCookieStoreAsyncHelper(
ChromeURLRequestContext::ChromeURLRequestContext() {
CheckCurrentlyOnIOThread();
-
- url_request_tracker()->SetGraveyardFilter(
- &ChromeURLRequestContext::ShouldTrackRequest);
}
ChromeURLRequestContext::~ChromeURLRequestContext() {
@@ -752,6 +752,7 @@ ChromeURLRequestContext::ChromeURLRequestContext(
CheckCurrentlyOnIOThread();
// Set URLRequestContext members
+ net_log_ = other->net_log_;
host_resolver_ = other->host_resolver_;
proxy_service_ = other->proxy_service_;
ssl_config_service_ = other->ssl_config_service_;
@@ -798,12 +799,6 @@ void ChromeURLRequestContext::OnDefaultCharsetChange(
net::HttpUtil::GenerateAcceptCharsetHeader(default_charset);
}
-// static
-bool ChromeURLRequestContext::ShouldTrackRequest(const GURL& url) {
- // Exclude "chrome://" URLs from our recent requests circular buffer.
- return !url.SchemeIs("chrome");
-}
-
// ----------------------------------------------------------------------------
// ChromeURLRequestContextFactory
// ----------------------------------------------------------------------------
diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h
index 8f3c260..7e44d04 100644
--- a/chrome/browser/net/chrome_url_request_context.h
+++ b/chrome/browser/net/chrome_url_request_context.h
@@ -201,6 +201,9 @@ class ChromeURLRequestContext : public URLRequestContext {
void set_appcache_service(ChromeAppCacheService* service) {
appcache_service_ = service;
}
+ void set_net_log(net::NetLog* net_log) {
+ net_log_ = net_log;
+ }
// Callback for when the accept language changes.
void OnAcceptLanguageChange(const std::string& accept_language);
@@ -230,10 +233,6 @@ class ChromeURLRequestContext : public URLRequestContext {
bool InterceptCookie(const URLRequest* request,
const std::string& cookie) const;
- // Filter for url_request_tracker(), that prevents "chrome://" requests from
- // being tracked by "about:net-internals".
- static bool ShouldTrackRequest(const GURL& url);
-
DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContext);
};
diff --git a/chrome/browser/net/dns_master.cc b/chrome/browser/net/dns_master.cc
index 9ac9a0a..431842d 100644
--- a/chrome/browser/net/dns_master.cc
+++ b/chrome/browser/net/dns_master.cc
@@ -18,6 +18,7 @@
#include "net/base/completion_callback.h"
#include "net/base/host_resolver.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log.h"
using base::TimeDelta;
@@ -48,7 +49,7 @@ class DnsMaster::LookupRequest {
// lets the HostResolver know it can de-prioritize it.
resolve_info.set_is_speculative(true);
return resolver_.Resolve(
- resolve_info, &addresses_, &net_callback_, NULL);
+ resolve_info, &addresses_, &net_callback_, net::BoundNetLog());
}
private:
diff --git a/chrome/browser/net/passive_log_collector.cc b/chrome/browser/net/passive_log_collector.cc
new file mode 100644
index 0000000..456ae1b
--- /dev/null
+++ b/chrome/browser/net/passive_log_collector.cc
@@ -0,0 +1,318 @@
+// 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 "chrome/browser/net/passive_log_collector.h"
+
+#include <algorithm>
+
+#include "base/string_util.h"
+#include "chrome/browser/chrome_thread.h"
+
+namespace {
+const size_t kMaxNumEntriesPerLog = 50;
+const size_t kMaxConnectJobGraveyardSize = 3;
+const size_t kMaxRequestGraveyardSize = 25;
+const size_t kMaxLiveRequests = 200;
+
+// Sort function on source ID.
+bool OrderBySourceID(const PassiveLogCollector::RequestInfo& a,
+ const PassiveLogCollector::RequestInfo& b) {
+ return a.entries[0].source.id < b.entries[0].source.id;
+}
+
+void AddEntryToRequestInfo(const net::NetLog::Entry& entry,
+ bool is_unbounded,
+ PassiveLogCollector::RequestInfo* out_info) {
+ // Start dropping new entries when the log has gotten too big.
+ if (out_info->entries.size() + 1 <= kMaxNumEntriesPerLog || is_unbounded) {
+ out_info->entries.push_back(entry);
+ } else {
+ out_info->num_entries_truncated += 1;
+ out_info->entries[kMaxNumEntriesPerLog - 1] = entry;
+ }
+}
+
+void AppendToRequestInfo(const PassiveLogCollector::RequestInfo& info,
+ bool is_unbounded,
+ PassiveLogCollector::RequestInfo* out_info) {
+ for (size_t i = 0; i < info.entries.size(); ++i)
+ AddEntryToRequestInfo(info.entries[i], is_unbounded, out_info);
+}
+
+} // namespace
+
+//----------------------------------------------------------------------------
+// PassiveLogCollector
+//----------------------------------------------------------------------------
+
+PassiveLogCollector::PassiveLogCollector()
+ : url_request_tracker_(&connect_job_tracker_),
+ socket_stream_tracker_(&connect_job_tracker_) {
+}
+
+PassiveLogCollector::~PassiveLogCollector() {
+}
+
+void PassiveLogCollector::OnAddEntry(const net::NetLog::Entry& entry) {
+ switch (entry.source.type) {
+ case net::NetLog::SOURCE_URL_REQUEST:
+ url_request_tracker_.OnAddEntry(entry);
+ break;
+ case net::NetLog::SOURCE_SOCKET_STREAM:
+ socket_stream_tracker_.OnAddEntry(entry);
+ break;
+ case net::NetLog::SOURCE_CONNECT_JOB:
+ connect_job_tracker_.OnAddEntry(entry);
+ break;
+ default:
+ // Drop all other logged events.
+ break;
+ }
+}
+
+void PassiveLogCollector::Clear() {
+ connect_job_tracker_.Clear();
+ url_request_tracker_.Clear();
+ socket_stream_tracker_.Clear();
+}
+
+//----------------------------------------------------------------------------
+// RequestTrackerBase
+//----------------------------------------------------------------------------
+
+PassiveLogCollector::RequestTrackerBase::RequestTrackerBase(
+ size_t max_graveyard_size)
+ : max_graveyard_size_(max_graveyard_size),
+ next_graveyard_index_(0),
+ is_unbounded_(false) {
+}
+
+void PassiveLogCollector::RequestTrackerBase::OnAddEntry(
+ const net::NetLog::Entry& entry) {
+ RequestInfo& info = live_requests_[entry.source.id];
+ Action result = DoAddEntry(entry, &info);
+
+ switch (result) {
+ case ACTION_MOVE_TO_GRAVEYARD:
+ InsertIntoGraveyard(info);
+ // (fall-through)
+ case ACTION_DELETE:
+ RemoveFromLiveRequests(info);
+ break;
+ default:
+ break;
+ }
+
+ if (live_requests_.size() > kMaxLiveRequests) {
+ // This is a safety net in case something went wrong, to avoid continually
+ // growing memory.
+ LOG(WARNING) << "The passive log data has grown larger "
+ "than expected, resetting";
+ live_requests_.clear();
+ }
+}
+
+PassiveLogCollector::RequestInfoList
+PassiveLogCollector::RequestTrackerBase::GetLiveRequests() const {
+ RequestInfoList list;
+
+ // Copy all of the live requests into the vector.
+ for (SourceIDToInfoMap::const_iterator it = live_requests_.begin();
+ it != live_requests_.end();
+ ++it) {
+ list.push_back(it->second);
+ }
+
+ std::sort(list.begin(), list.end(), OrderBySourceID);
+ return list;
+}
+
+void PassiveLogCollector::RequestTrackerBase::ClearRecentlyDeceased() {
+ next_graveyard_index_ = 0;
+ graveyard_.clear();
+}
+
+// Returns a list of recently completed Requests.
+PassiveLogCollector::RequestInfoList
+PassiveLogCollector::RequestTrackerBase::GetRecentlyDeceased() const {
+ RequestInfoList list;
+
+ // Copy the items from |graveyard_| (our circular queue of recently
+ // deceased request infos) into a vector, ordered from oldest to newest.
+ for (size_t i = 0; i < graveyard_.size(); ++i) {
+ size_t index = (next_graveyard_index_ + i) % graveyard_.size();
+ list.push_back(graveyard_[index]);
+ }
+ return list;
+}
+
+const PassiveLogCollector::RequestInfo*
+PassiveLogCollector::RequestTrackerBase::GetRequestInfoFromGraveyard(
+ int source_id) const {
+ // Scan through the graveyard to find an entry for |source_id|.
+ for (size_t i = 0; i < graveyard_.size(); ++i) {
+ if (graveyard_[i].entries[0].source.id == source_id) {
+ return &graveyard_[i];
+ }
+ }
+ return NULL;
+}
+
+void PassiveLogCollector::RequestTrackerBase::RemoveFromLiveRequests(
+ const RequestInfo& info) {
+ // Remove from |live_requests_|.
+ SourceIDToInfoMap::iterator it = live_requests_.find(
+ info.entries[0].source.id);
+ DCHECK(it != live_requests_.end());
+ live_requests_.erase(it);
+}
+
+void PassiveLogCollector::RequestTrackerBase::SetUnbounded(
+ bool unbounded) {
+ // No change.
+ if (is_unbounded_ == unbounded)
+ return;
+
+ // If we are going from unbounded to bounded, we need to trim the
+ // graveyard. For simplicity we will simply clear it.
+ if (is_unbounded_ && !unbounded)
+ ClearRecentlyDeceased();
+
+ is_unbounded_ = unbounded;
+}
+
+void PassiveLogCollector::RequestTrackerBase::Clear() {
+ ClearRecentlyDeceased();
+ live_requests_.clear();
+}
+
+void PassiveLogCollector::RequestTrackerBase::InsertIntoGraveyard(
+ const RequestInfo& info) {
+ if (is_unbounded_) {
+ graveyard_.push_back(info);
+ return;
+ }
+
+ // Otherwise enforce a bound on the graveyard size, by treating it as a
+ // circular buffer.
+ if (graveyard_.size() < max_graveyard_size_) {
+ // Still growing to maximum capacity.
+ DCHECK_EQ(next_graveyard_index_, graveyard_.size());
+ graveyard_.push_back(info);
+ } else {
+ // At maximum capacity, overwite the oldest entry.
+ graveyard_[next_graveyard_index_] = info;
+ }
+ next_graveyard_index_ = (next_graveyard_index_ + 1) % max_graveyard_size_;
+}
+
+//----------------------------------------------------------------------------
+// ConnectJobTracker
+//----------------------------------------------------------------------------
+
+const size_t PassiveLogCollector::ConnectJobTracker::kMaxGraveyardSize = 3;
+
+PassiveLogCollector::ConnectJobTracker::ConnectJobTracker()
+ : RequestTrackerBase(kMaxGraveyardSize) {
+}
+
+PassiveLogCollector::RequestTrackerBase::Action
+PassiveLogCollector::ConnectJobTracker::DoAddEntry(
+ const net::NetLog::Entry& entry,
+ RequestInfo* out_info) {
+ // Save the entry (possibly truncating).
+ AddEntryToRequestInfo(entry, is_unbounded(), out_info);
+
+ // If this is the end of the connect job, move the request to the graveyard.
+ if (entry.type == net::NetLog::Entry::TYPE_EVENT &&
+ entry.event.type == net::NetLog::TYPE_SOCKET_POOL_CONNECT_JOB &&
+ entry.event.phase == net::NetLog::PHASE_END) {
+ return ACTION_MOVE_TO_GRAVEYARD;
+ }
+
+ return ACTION_NONE;
+}
+
+//----------------------------------------------------------------------------
+// RequestTracker
+//----------------------------------------------------------------------------
+
+const size_t PassiveLogCollector::RequestTracker::kMaxGraveyardSize = 25;
+const size_t PassiveLogCollector::RequestTracker::kMaxGraveyardURLSize = 1000;
+
+PassiveLogCollector::RequestTracker::RequestTracker(
+ ConnectJobTracker* connect_job_tracker)
+ : RequestTrackerBase(kMaxGraveyardSize),
+ connect_job_tracker_(connect_job_tracker) {
+}
+
+PassiveLogCollector::RequestTrackerBase::Action
+PassiveLogCollector::RequestTracker::DoAddEntry(
+ const net::NetLog::Entry& entry,
+ RequestInfo* out_info) {
+
+ if (entry.type == net::NetLog::Entry::TYPE_EVENT &&
+ entry.event.type == net::NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID) {
+ // If this was notification that a ConnectJob was bound to the request,
+ // copy all the logged data for that ConnectJob.
+ AddConnectJobInfo(entry, out_info);
+ } else {
+ // Otherwise just append this entry to the request info.
+ AddEntryToRequestInfo(entry, is_unbounded(), out_info);
+ }
+
+ // If this was the start of a URLRequest/SocketStream, extract the URL.
+ if (out_info->entries.size() == 1 &&
+ entry.type == net::NetLog::Entry::TYPE_EVENT &&
+ entry.event.type == net::NetLog::TYPE_REQUEST_ALIVE &&
+ entry.event.phase == net::NetLog::PHASE_BEGIN) {
+ out_info->url = entry.string;
+ out_info->entries[0].string = std::string();
+
+ // Paranoia check: truncate the URL if it is really big.
+ if (out_info->url.size() > kMaxGraveyardURLSize)
+ out_info->url = out_info->url.substr(0, kMaxGraveyardURLSize);
+ }
+
+ // If the request has ended, move it to the graveyard.
+ if (entry.type == net::NetLog::Entry::TYPE_EVENT &&
+ entry.event.type == net::NetLog::TYPE_REQUEST_ALIVE &&
+ entry.event.phase == net::NetLog::PHASE_END) {
+ if (StartsWithASCII(out_info->url, "chrome://", false)) {
+ // Avoid sending "chrome://" requests to the graveyard, since it just
+ // adds to clutter.
+ return ACTION_DELETE;
+ }
+ return ACTION_MOVE_TO_GRAVEYARD;
+ }
+
+ return ACTION_NONE;
+}
+
+void PassiveLogCollector::RequestTracker::AddConnectJobInfo(
+ const net::NetLog::Entry& entry,
+ RequestInfo* live_entry) {
+ // We have just been notified of which ConnectJob the
+ // URLRequest/SocketStream was assigned. Lookup all the data we captured
+ // for the ConnectJob, and append it to the URLRequest/SocketStream's
+ // RequestInfo.
+
+ // TODO(eroman): This should NOT be plumbed through via |error_code| !
+ int connect_job_id = entry.error_code;
+
+ const RequestInfo* connect_job_info =
+ connect_job_tracker_->GetRequestInfoFromGraveyard(connect_job_id);
+
+ if (connect_job_info) {
+ // Append the ConnectJob information we found.
+ AppendToRequestInfo(*connect_job_info, is_unbounded(), live_entry);
+ } else {
+ // If we couldn't find the information for the ConnectJob, append a
+ // generic message instead.
+ net::NetLog::Entry e(entry);
+ e.type = net::NetLog::Entry::TYPE_STRING;
+ e.string = StringPrintf("Used ConnectJob id=%d", connect_job_id);
+ AddEntryToRequestInfo(e, is_unbounded(), live_entry);
+ }
+}
diff --git a/chrome/browser/net/passive_log_collector.h b/chrome/browser/net/passive_log_collector.h
new file mode 100644
index 0000000..c8f6977
--- /dev/null
+++ b/chrome/browser/net/passive_log_collector.h
@@ -0,0 +1,138 @@
+// 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.
+
+#ifndef CHROME_BROWSER_NET_PASSIVE_LOG_COLLECTOR_H_
+#define CHROME_BROWSER_NET_PASSIVE_LOG_COLLECTOR_H_
+
+#include <vector>
+
+#include "base/hash_tables.h"
+#include "chrome/browser/net/chrome_net_log.h"
+#include "net/base/net_log.h"
+
+class PassiveLogCollector : public ChromeNetLog::Observer {
+ public:
+ struct RequestInfo {
+ RequestInfo() : num_entries_truncated(0) {}
+ std::string url;
+ std::vector<net::NetLog::Entry> entries;
+ size_t num_entries_truncated;
+ };
+
+ typedef std::vector<RequestInfo> RequestInfoList;
+
+ // This class stores and manages the passively logged information for
+ // URLRequests/SocketStreams/ConnectJobs.
+ class RequestTrackerBase {
+ public:
+ explicit RequestTrackerBase(size_t max_graveyard_size);
+
+ void OnAddEntry(const net::NetLog::Entry& entry);
+
+ RequestInfoList GetLiveRequests() const;
+ void ClearRecentlyDeceased();
+ RequestInfoList GetRecentlyDeceased() const;
+ void SetUnbounded(bool unbounded);
+
+ bool IsUnbounded() const { return is_unbounded_; }
+
+ void Clear();
+
+ const RequestInfo* GetRequestInfoFromGraveyard(int id) const;
+
+ protected:
+ enum Action {
+ ACTION_NONE,
+ ACTION_DELETE,
+ ACTION_MOVE_TO_GRAVEYARD,
+ };
+
+ // Updates |out_info| with the information from |entry|. Returns an action
+ // to perform for this map entry on completion.
+ virtual Action DoAddEntry(const net::NetLog::Entry& entry,
+ RequestInfo* out_info) = 0;
+
+ bool is_unbounded() const { return is_unbounded_; }
+
+ private:
+ typedef base::hash_map<int, RequestInfo> SourceIDToInfoMap;
+
+ bool HandleNotificationOfConnectJobID(const net::NetLog::Entry& entry,
+ RequestInfo* live_entry);
+
+ void RemoveFromLiveRequests(const RequestInfo& info);
+ void InsertIntoGraveyard(const RequestInfo& info);
+
+ SourceIDToInfoMap live_requests_;
+ size_t max_graveyard_size_;
+ size_t next_graveyard_index_;
+ RequestInfoList graveyard_;
+ bool is_unbounded_;
+
+ DISALLOW_COPY_AND_ASSIGN(RequestTrackerBase);
+ };
+
+ // Specialization of RequestTrackerBase for handling ConnectJobs.
+ class ConnectJobTracker : public RequestTrackerBase {
+ public:
+ static const size_t kMaxGraveyardSize;
+
+ ConnectJobTracker();
+
+ protected:
+ virtual Action DoAddEntry(const net::NetLog::Entry& entry,
+ RequestInfo* out_info);
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ConnectJobTracker);
+ };
+
+ // Specialization of RequestTrackerBase for handling URLRequest/SocketStream.
+ class RequestTracker : public RequestTrackerBase {
+ public:
+ static const size_t kMaxGraveyardSize;
+ static const size_t kMaxGraveyardURLSize;
+
+ explicit RequestTracker(ConnectJobTracker* connect_job_tracker);
+
+ protected:
+ virtual Action DoAddEntry(const net::NetLog::Entry& entry,
+ RequestInfo* out_info);
+
+ private:
+ // Searches through |connect_job_tracker_| for information on the
+ // ConnectJob specified in |entry|, and appends it to |live_entry|.
+ void AddConnectJobInfo(const net::NetLog::Entry& entry,
+ RequestInfo* live_entry);
+
+ ConnectJobTracker* connect_job_tracker_;
+
+ DISALLOW_COPY_AND_ASSIGN(RequestTracker);
+ };
+
+ PassiveLogCollector();
+ ~PassiveLogCollector();
+
+ // Observer implementation:
+ virtual void OnAddEntry(const net::NetLog::Entry& entry);
+
+ // Clears all of the passively logged data.
+ void Clear();
+
+ RequestTracker* url_request_tracker() {
+ return &url_request_tracker_;
+ }
+
+ RequestTracker* socket_stream_tracker() {
+ return &socket_stream_tracker_;
+ }
+
+ private:
+ ConnectJobTracker connect_job_tracker_;
+ RequestTracker url_request_tracker_;
+ RequestTracker socket_stream_tracker_;
+
+ DISALLOW_COPY_AND_ASSIGN(PassiveLogCollector);
+};
+
+#endif // CHROME_BROWSER_NET_PASSIVE_LOG_COLLECTOR_H_
diff --git a/chrome/browser/net/passive_log_collector_unittest.cc b/chrome/browser/net/passive_log_collector_unittest.cc
new file mode 100644
index 0000000..ae18839
--- /dev/null
+++ b/chrome/browser/net/passive_log_collector_unittest.cc
@@ -0,0 +1,213 @@
+// 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 "chrome/browser/net/passive_log_collector.h"
+
+#include "base/compiler_specific.h"
+#include "base/format_macros.h"
+#include "base/string_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+typedef PassiveLogCollector::RequestTracker RequestTracker;
+typedef PassiveLogCollector::RequestInfoList RequestInfoList;
+
+const net::NetLog::SourceType kSourceType = net::NetLog::SOURCE_NONE;
+
+net::NetLog::Entry MakeStartLogEntryWithURL(int source_id,
+ const std::string& url) {
+ net::NetLog::Entry entry;
+ entry.source.type = kSourceType;
+ entry.source.id = source_id;
+ entry.type = net::NetLog::Entry::TYPE_EVENT;
+ entry.event = net::NetLog::Event(net::NetLog::TYPE_REQUEST_ALIVE,
+ net::NetLog::PHASE_BEGIN);
+ entry.string = url;
+ return entry;
+}
+
+net::NetLog::Entry MakeStartLogEntry(int source_id) {
+ return MakeStartLogEntryWithURL(source_id,
+ StringPrintf("http://req%d", source_id));
+}
+
+net::NetLog::Entry MakeEndLogEntry(int source_id) {
+ net::NetLog::Entry entry;
+ entry.source.type = kSourceType;
+ entry.source.id = source_id;
+ entry.type = net::NetLog::Entry::TYPE_EVENT;
+ entry.event = net::NetLog::Event(net::NetLog::TYPE_REQUEST_ALIVE,
+ net::NetLog::PHASE_END);
+ return entry;
+}
+
+static const int kMaxNumLoadLogEntries = 1;
+
+TEST(RequestTrackerTest, BasicBounded) {
+ RequestTracker tracker(NULL);
+ EXPECT_FALSE(tracker.IsUnbounded());
+ EXPECT_EQ(0u, tracker.GetLiveRequests().size());
+ EXPECT_EQ(0u, tracker.GetRecentlyDeceased().size());
+
+ tracker.OnAddEntry(MakeStartLogEntry(1));
+ tracker.OnAddEntry(MakeStartLogEntry(2));
+ tracker.OnAddEntry(MakeStartLogEntry(3));
+ tracker.OnAddEntry(MakeStartLogEntry(4));
+ tracker.OnAddEntry(MakeStartLogEntry(5));
+
+ RequestInfoList live_reqs = tracker.GetLiveRequests();
+
+ ASSERT_EQ(5u, live_reqs.size());
+ EXPECT_EQ("http://req1", live_reqs[0].url);
+ EXPECT_EQ("http://req2", live_reqs[1].url);
+ EXPECT_EQ("http://req3", live_reqs[2].url);
+ EXPECT_EQ("http://req4", live_reqs[3].url);
+ EXPECT_EQ("http://req5", live_reqs[4].url);
+
+ tracker.OnAddEntry(MakeEndLogEntry(1));
+ tracker.OnAddEntry(MakeEndLogEntry(5));
+ tracker.OnAddEntry(MakeEndLogEntry(3));
+
+ ASSERT_EQ(3u, tracker.GetRecentlyDeceased().size());
+
+ live_reqs = tracker.GetLiveRequests();
+
+ ASSERT_EQ(2u, live_reqs.size());
+ EXPECT_EQ("http://req2", live_reqs[0].url);
+ EXPECT_EQ("http://req4", live_reqs[1].url);
+}
+
+TEST(RequestTrackerTest, GraveyardBounded) {
+ RequestTracker tracker(NULL);
+ EXPECT_FALSE(tracker.IsUnbounded());
+ EXPECT_EQ(0u, tracker.GetLiveRequests().size());
+ EXPECT_EQ(0u, tracker.GetRecentlyDeceased().size());
+
+ // Add twice as many requests as will fit in the graveyard.
+ for (size_t i = 0; i < RequestTracker::kMaxGraveyardSize * 2; ++i) {
+ tracker.OnAddEntry(MakeStartLogEntry(i));
+ tracker.OnAddEntry(MakeEndLogEntry(i));
+ }
+
+ // Check that only the last |kMaxGraveyardSize| requests are in-memory.
+
+ RequestInfoList recent_reqs = tracker.GetRecentlyDeceased();
+
+ ASSERT_EQ(RequestTracker::kMaxGraveyardSize, recent_reqs.size());
+
+ for (size_t i = 0; i < RequestTracker::kMaxGraveyardSize; ++i) {
+ size_t req_number = i + RequestTracker::kMaxGraveyardSize;
+ std::string url = StringPrintf("http://req%" PRIuS, req_number);
+ EXPECT_EQ(url, recent_reqs[i].url);
+ }
+}
+
+TEST(RequestTrackerTest, GraveyardUnbounded) {
+ RequestTracker tracker(NULL);
+ EXPECT_FALSE(tracker.IsUnbounded());
+ EXPECT_EQ(0u, tracker.GetLiveRequests().size());
+ EXPECT_EQ(0u, tracker.GetRecentlyDeceased().size());
+
+ tracker.SetUnbounded(true);
+
+ EXPECT_TRUE(tracker.IsUnbounded());
+
+ // Add twice as many requests as would fit in the bounded graveyard.
+
+ size_t kMaxSize = RequestTracker::kMaxGraveyardSize * 2;
+ for (size_t i = 0; i < kMaxSize; ++i) {
+ tracker.OnAddEntry(MakeStartLogEntry(i));
+ tracker.OnAddEntry(MakeEndLogEntry(i));
+ }
+
+ // Check that all of them got saved.
+
+ RequestInfoList recent_reqs = tracker.GetRecentlyDeceased();
+
+ ASSERT_EQ(kMaxSize, recent_reqs.size());
+
+ for (size_t i = 0; i < kMaxSize; ++i) {
+ std::string url = StringPrintf("http://req%" PRIuS, i);
+ EXPECT_EQ(url, recent_reqs[i].url);
+ }
+}
+
+// Check that very long URLs are truncated.
+TEST(RequestTrackerTest, GraveyardURLBounded) {
+ RequestTracker tracker(NULL);
+ EXPECT_FALSE(tracker.IsUnbounded());
+
+ std::string big_url("http://");
+ big_url.resize(2 * RequestTracker::kMaxGraveyardURLSize, 'x');
+
+ tracker.OnAddEntry(MakeStartLogEntryWithURL(1, big_url));
+ tracker.OnAddEntry(MakeEndLogEntry(1));
+
+ ASSERT_EQ(1u, tracker.GetRecentlyDeceased().size());
+ EXPECT_EQ(RequestTracker::kMaxGraveyardURLSize,
+ tracker.GetRecentlyDeceased()[0].url.size());
+}
+
+// Check that we exclude "chrome://" URLs from being saved into the recent
+// requests list (graveyard).
+TEST(RequestTrackerTest, GraveyardIsFiltered) {
+ RequestTracker tracker(NULL);
+ EXPECT_FALSE(tracker.IsUnbounded());
+
+ // This will be excluded.
+ std::string url1 = "chrome://dontcare/";
+ tracker.OnAddEntry(MakeStartLogEntryWithURL(1, url1));
+ tracker.OnAddEntry(MakeEndLogEntry(1));
+
+ // This will be be added to graveyard.
+ std::string url2 = "chrome2://dontcare/";
+ tracker.OnAddEntry(MakeStartLogEntryWithURL(2, url2));
+ tracker.OnAddEntry(MakeEndLogEntry(2));
+
+ // This will be be added to graveyard.
+ std::string url3 = "http://foo/";
+ tracker.OnAddEntry(MakeStartLogEntryWithURL(3, url3));
+ tracker.OnAddEntry(MakeEndLogEntry(3));
+
+ ASSERT_EQ(2u, tracker.GetRecentlyDeceased().size());
+ EXPECT_EQ(url2, tracker.GetRecentlyDeceased()[0].url);
+ EXPECT_EQ(url3, tracker.GetRecentlyDeceased()[1].url);
+}
+
+// Convert an unbounded tracker back to being bounded.
+TEST(RequestTrackerTest, ConvertUnboundedToBounded) {
+ RequestTracker tracker(NULL);
+ EXPECT_FALSE(tracker.IsUnbounded());
+ EXPECT_EQ(0u, tracker.GetLiveRequests().size());
+ EXPECT_EQ(0u, tracker.GetRecentlyDeceased().size());
+
+ tracker.SetUnbounded(true);
+ EXPECT_TRUE(tracker.IsUnbounded());
+
+ // Add twice as many requests as would fit in the bounded graveyard.
+
+ size_t kMaxSize = RequestTracker::kMaxGraveyardSize * 2;
+ for (size_t i = 0; i < kMaxSize; ++i) {
+ tracker.OnAddEntry(MakeStartLogEntry(i));
+ tracker.OnAddEntry(MakeEndLogEntry(i));
+ }
+
+ // Check that all of them got saved.
+ ASSERT_EQ(kMaxSize, tracker.GetRecentlyDeceased().size());
+
+ // Now make the tracker bounded, and add more entries to its graveyard.
+ tracker.SetUnbounded(false);
+
+ kMaxSize = RequestTracker::kMaxGraveyardSize;
+ for (size_t i = kMaxSize; i < 2 * kMaxSize; ++i) {
+ tracker.OnAddEntry(MakeStartLogEntry(i));
+ tracker.OnAddEntry(MakeEndLogEntry(i));
+ }
+
+ // We should only have kMaxGraveyardSize entries now.
+ ASSERT_EQ(kMaxSize, tracker.GetRecentlyDeceased().size());
+}
+
+} // namespace
diff --git a/chrome/browser/net/view_net_internals_job_factory.cc b/chrome/browser/net/view_net_internals_job_factory.cc
index ab58dfcf..987a54b 100644
--- a/chrome/browser/net/view_net_internals_job_factory.cc
+++ b/chrome/browser/net/view_net_internals_job_factory.cc
@@ -9,11 +9,14 @@
#include "base/format_macros.h"
#include "base/stl_util-inl.h"
#include "base/string_util.h"
+#include "chrome/browser/net/chrome_net_log.h"
+#include "chrome/browser/net/chrome_url_request_context.h"
+#include "chrome/browser/net/passive_log_collector.h"
#include "chrome/common/url_constants.h"
#include "net/base/escape.h"
#include "net/base/host_resolver_impl.h"
-#include "net/base/load_log_util.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log_util.h"
#include "net/base/net_util.h"
#include "net/base/sys_addrinfo.h"
#include "net/proxy/proxy_service.h"
@@ -27,6 +30,26 @@ namespace {
const char kViewHttpCacheSubPath[] = "view-cache";
+PassiveLogCollector* GetPassiveLogCollector(URLRequestContext* context) {
+ // Really this is the same as:
+ // g_browser_process->io_thread()->globals()->
+ // net_log.get()
+ // (But we can't access g_browser_process from the IO thread).
+ ChromeNetLog* chrome_net_log = static_cast<ChromeNetLog*>(
+ static_cast<ChromeURLRequestContext*>(context)->net_log());
+ return chrome_net_log->passive_collector();
+}
+
+PassiveLogCollector::RequestTracker* GetURLRequestTracker(
+ URLRequestContext* context) {
+ return GetPassiveLogCollector(context)->url_request_tracker();
+}
+
+PassiveLogCollector::RequestTracker* GetSocketStreamTracker(
+ URLRequestContext* context) {
+ return GetPassiveLogCollector(context)->socket_stream_tracker();
+}
+
std::string GetDetails(const GURL& url) {
DCHECK(ViewNetInternalsJobFactory::IsSupportedURL(url));
size_t start = strlen(chrome::kNetworkViewInternalsURL);
@@ -232,12 +255,8 @@ class ProxyServiceLastInitLogSubSection : public SubSection {
virtual void OutputBody(URLRequestContext* context, std::string* out) {
net::ProxyService* proxy_service = context->proxy_service();
- net::LoadLog* log = proxy_service->init_proxy_resolver_log();
- if (log) {
- OutputTextInPre(net::LoadLogUtil::PrettyPrintAsEventTree(log), out);
- } else {
- out->append("<i>None.</i>");
- }
+ OutputTextInPre(net::NetLogUtil::PrettyPrintAsEventTree(
+ proxy_service->init_proxy_resolver_log().entries(), 0), out);
}
};
@@ -418,15 +437,15 @@ class HostResolverTraceSubSection : public SubSection {
DrawCommandButton("Enable tracing", "hostresolver-trace-enable", out);
}
- scoped_refptr<net::LoadLog> log = resolver->GetRequestsTrace();
-
- if (log) {
+ std::vector<net::NetLog::Entry> entries;
+ if (resolver->GetRequestsTrace(&entries)) {
out->append(
"<p>To make sense of this trace, process it with the Python script "
"formatter.py at "
"<a href='http://src.chromium.org/viewvc/chrome/trunk/src/net/tools/"
"dns_trace_formatter/'>net/tools/dns_trace_formatter</a></p>");
- OutputTextInPre(net::LoadLogUtil::PrettyPrintAsEventTree(log), out);
+ OutputTextInPre(net::NetLogUtil::PrettyPrintAsEventTree(entries, 0),
+ out);
} else {
out->append("<p><i>No trace information, must enable tracing.</i></p>");
}
@@ -443,15 +462,17 @@ class HostResolverSubSection : public SubSection {
};
// Helper for the URLRequest "outstanding" and "live" sections.
-void OutputURLAndLoadLog(const GURL& url,
- const net::LoadLog* log,
+void OutputURLAndLoadLog(const PassiveLogCollector::RequestInfo& request,
std::string* out) {
out->append("<li>");
out->append("<nobr>");
- out->append(EscapeForHTML(url.possibly_invalid_spec()));
+ out->append(EscapeForHTML(request.url));
out->append("</nobr>");
- if (log)
- OutputTextInPre(net::LoadLogUtil::PrettyPrintAsEventTree(log), out);
+ OutputTextInPre(
+ net::NetLogUtil::PrettyPrintAsEventTree(
+ request.entries,
+ request.num_entries_truncated),
+ out);
out->append("</li>");
}
@@ -462,16 +483,14 @@ class URLRequestLiveSubSection : public SubSection {
}
virtual void OutputBody(URLRequestContext* context, std::string* out) {
- std::vector<URLRequest*> requests =
- context->url_request_tracker()->GetLiveRequests();
+ PassiveLogCollector::RequestInfoList requests =
+ GetURLRequestTracker(context)->GetLiveRequests();
out->append("<ol>");
for (size_t i = 0; i < requests.size(); ++i) {
// Reverse the list order, so we dispay from most recent to oldest.
size_t index = requests.size() - i - 1;
- OutputURLAndLoadLog(requests[index]->original_url(),
- requests[index]->load_log(),
- out);
+ OutputURLAndLoadLog(requests[index], out);
}
out->append("</ol>");
}
@@ -484,8 +503,8 @@ class URLRequestRecentSubSection : public SubSection {
}
virtual void OutputBody(URLRequestContext* context, std::string* out) {
- RequestTracker<URLRequest>::RecentRequestInfoList recent =
- context->url_request_tracker()->GetRecentlyDeceased();
+ PassiveLogCollector::RequestInfoList recent =
+ GetURLRequestTracker(context)->GetRecentlyDeceased();
DrawCommandButton("Clear", "clear-urlrequest-graveyard", out);
@@ -493,8 +512,7 @@ class URLRequestRecentSubSection : public SubSection {
for (size_t i = 0; i < recent.size(); ++i) {
// Reverse the list order, so we dispay from most recent to oldest.
size_t index = recent.size() - i - 1;
- OutputURLAndLoadLog(recent[index].original_url,
- recent[index].load_log, out);
+ OutputURLAndLoadLog(recent[index], out);
}
out->append("</ol>");
}
@@ -542,16 +560,14 @@ class SocketStreamLiveSubSection : public SubSection {
}
virtual void OutputBody(URLRequestContext* context, std::string* out) {
- std::vector<net::SocketStream*> sockets =
- context->socket_stream_tracker()->GetLiveRequests();
+ PassiveLogCollector::RequestInfoList sockets =
+ GetSocketStreamTracker(context)->GetLiveRequests();
out->append("<ol>");
for (size_t i = 0; i < sockets.size(); ++i) {
// Reverse the list order, so we dispay from most recent to oldest.
size_t index = sockets.size() - i - 1;
- OutputURLAndLoadLog(sockets[index]->url(),
- sockets[index]->load_log(),
- out);
+ OutputURLAndLoadLog(sockets[index], out);
}
out->append("</ol>");
}
@@ -564,8 +580,8 @@ class SocketStreamRecentSubSection : public SubSection {
}
virtual void OutputBody(URLRequestContext* context, std::string* out) {
- RequestTracker<net::SocketStream>::RecentRequestInfoList recent =
- context->socket_stream_tracker()->GetRecentlyDeceased();
+ PassiveLogCollector::RequestInfoList recent =
+ GetSocketStreamTracker(context)->GetRecentlyDeceased();
DrawCommandButton("Clear", "clear-socketstream-graveyard", out);
@@ -573,8 +589,7 @@ class SocketStreamRecentSubSection : public SubSection {
for (size_t i = 0; i < recent.size(); ++i) {
// Reverse the list order, so we dispay from most recent to oldest.
size_t index = recent.size() - i - 1;
- OutputURLAndLoadLog(recent[index].original_url,
- recent[index].load_log, out);
+ OutputURLAndLoadLog(recent[index], out);
}
out->append("</ol>");
}
@@ -600,11 +615,12 @@ class AllSubSections : public SubSection {
}
};
-bool HandleCommand(const std::string& command, URLRequestContext* context) {
+bool HandleCommand(const std::string& command,
+ URLRequestContext* context) {
if (StartsWithASCII(command, "full-logging-", true)) {
bool enable_full_logging = (command == "full-logging-enable");
- context->url_request_tracker()->SetUnbounded(enable_full_logging);
- context->socket_stream_tracker()->SetUnbounded(enable_full_logging);
+ GetURLRequestTracker(context)->SetUnbounded(enable_full_logging);
+ GetSocketStreamTracker(context)->SetUnbounded(enable_full_logging);
return true;
}
@@ -616,12 +632,12 @@ bool HandleCommand(const std::string& command, URLRequestContext* context) {
}
if (command == "clear-urlrequest-graveyard") {
- context->url_request_tracker()->ClearRecentlyDeceased();
+ GetURLRequestTracker(context)->ClearRecentlyDeceased();
return true;
}
if (command == "clear-socketstream-graveyard") {
- context->socket_stream_tracker()->ClearRecentlyDeceased();
+ GetSocketStreamTracker(context)->ClearRecentlyDeceased();
return true;
}
@@ -674,8 +690,8 @@ void ProcessQueryStringCommands(URLRequestContext* context,
// logging, and clear some of the already logged data.
void DrawControlsHeader(URLRequestContext* context, std::string* data) {
bool is_full_logging_enabled =
- context->url_request_tracker()->IsUnbounded() &&
- context->socket_stream_tracker()->IsUnbounded();
+ GetURLRequestTracker(context)->IsUnbounded() &&
+ GetSocketStreamTracker(context)->IsUnbounded();
data->append("<div style='margin-bottom: 10px'>");
@@ -703,7 +719,8 @@ bool ViewNetInternalsJob::GetData(std::string* mime_type,
mime_type->assign("text/html");
charset->assign("UTF-8");
- URLRequestContext* context = request_->context();
+ URLRequestContext* context =
+ static_cast<URLRequestContext*>(request_->context());
data->clear();
diff --git a/chrome/browser/sync/notifier/communicator/ssl_socket_adapter.cc b/chrome/browser/sync/notifier/communicator/ssl_socket_adapter.cc
index 14f4392..875052b 100644
--- a/chrome/browser/sync/notifier/communicator/ssl_socket_adapter.cc
+++ b/chrome/browser/sync/notifier/communicator/ssl_socket_adapter.cc
@@ -237,7 +237,7 @@ TransportSocket::TransportSocket(talk_base::AsyncSocket* socket,
}
int TransportSocket::Connect(net::CompletionCallback* callback,
- net::LoadLog* /* load_log */) {
+ const net::BoundNetLog& /* net_log */) {
connect_callback_ = callback;
return socket_->Connect(addr_);
}
diff --git a/chrome/browser/sync/notifier/communicator/ssl_socket_adapter.h b/chrome/browser/sync/notifier/communicator/ssl_socket_adapter.h
index 12dfc74..2e7d618 100644
--- a/chrome/browser/sync/notifier/communicator/ssl_socket_adapter.h
+++ b/chrome/browser/sync/notifier/communicator/ssl_socket_adapter.h
@@ -15,7 +15,7 @@
#include "talk/base/ssladapter.h"
namespace net {
-class LoadLog;
+class BoundNetLog;
} // namespace net
namespace notifier {
@@ -38,7 +38,7 @@ class TransportSocket : public net::ClientSocket, public sigslot::has_slots<> {
// net::ClientSocket implementation
virtual int Connect(net::CompletionCallback* callback,
- net::LoadLog* /* load_log */);
+ const net::BoundNetLog& /* net_log */);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 22010e6..761a351 100755
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1477,6 +1477,8 @@
'browser/net/browser_url_util.h',
'browser/net/chrome_cookie_policy.cc',
'browser/net/chrome_cookie_policy.h',
+ 'browser/net/chrome_net_log.cc',
+ 'browser/net/chrome_net_log.h',
'browser/net/chrome_url_request_context.cc',
'browser/net/chrome_url_request_context.h',
'browser/net/url_request_context_getter.cc',
@@ -1489,6 +1491,8 @@
'browser/net/dns_master.h',
'browser/net/metadata_url_request.cc',
'browser/net/metadata_url_request.h',
+ 'browser/net/passive_log_collector.cc',
+ 'browser/net/passive_log_collector.h',
'browser/net/referrer.cc',
'browser/net/referrer.h',
'browser/net/resolve_proxy_msg_helper.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 9cb92f7..3693f06 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -800,6 +800,7 @@
'browser/net/chrome_url_request_context_unittest.cc',
'browser/net/dns_host_info_unittest.cc',
'browser/net/dns_master_unittest.cc',
+ 'browser/net/passive_log_collector_unittest.cc',
'browser/net/resolve_proxy_msg_helper_unittest.cc',
'browser/net/test_url_fetcher_factory.cc',
'browser/net/test_url_fetcher_factory.h',
diff --git a/net/base/host_resolver.cc b/net/base/host_resolver.cc
index ebad57e..320406c 100644
--- a/net/base/host_resolver.cc
+++ b/net/base/host_resolver.cc
@@ -26,7 +26,7 @@ SingleRequestHostResolver::~SingleRequestHostResolver() {
int SingleRequestHostResolver::Resolve(const HostResolver::RequestInfo& info,
AddressList* addresses,
CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
DCHECK(!cur_request_ && !cur_request_callback_) << "resolver already in use";
HostResolver::RequestHandle request = NULL;
@@ -36,7 +36,7 @@ int SingleRequestHostResolver::Resolve(const HostResolver::RequestInfo& info,
CompletionCallback* transient_callback = callback ? &callback_ : NULL;
int rv = resolver_->Resolve(
- info, addresses, transient_callback, &request, load_log);
+ info, addresses, transient_callback, &request, net_log);
if (rv == ERR_IO_PENDING) {
// Cleared in OnResolveCompletion().
diff --git a/net/base/host_resolver.h b/net/base/host_resolver.h
index c4cdef6..8f7bd09 100644
--- a/net/base/host_resolver.h
+++ b/net/base/host_resolver.h
@@ -18,9 +18,9 @@ class MessageLoop;
namespace net {
class AddressList;
+class BoundNetLog;
class HostCache;
class HostResolverImpl;
-class LoadLog;
class NetworkChangeNotifier;
// This class represents the task of resolving hostnames (or IP address
@@ -137,12 +137,12 @@ class HostResolver : public base::RefCountedThreadSafe<HostResolver> {
// the async request. This handle is not valid after the request has
// completed.
//
- // Profiling information for the request is saved to |load_log| if non-NULL.
+ // Profiling information for the request is saved to |net_log| if non-NULL.
virtual int Resolve(const RequestInfo& info,
AddressList* addresses,
CompletionCallback* callback,
RequestHandle* out_req,
- LoadLog* load_log) = 0;
+ const BoundNetLog& net_log) = 0;
// Cancels the specified request. |req| is the handle returned by Resolve().
// After a request is cancelled, its completion callback will not be called.
@@ -198,7 +198,7 @@ class SingleRequestHostResolver {
int Resolve(const HostResolver::RequestInfo& info,
AddressList* addresses,
CompletionCallback* callback,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
// Cancels the in-progress request, if any. This prevents the callback
// from being invoked. Resolve() can be called again after cancelling.
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc
index 6af3079..d5dce2f 100644
--- a/net/base/host_resolver_impl.cc
+++ b/net/base/host_resolver_impl.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "net/base/host_resolver_impl.h"
+#include "net/base/net_log.h"
#include <cmath>
#include <deque>
@@ -18,7 +19,7 @@
#include "base/worker_pool.h"
#include "net/base/address_list.h"
#include "net/base/host_resolver_proc.h"
-#include "net/base/load_log.h"
+#include "net/base/net_log.h"
#include "net/base/net_errors.h"
#include "net/base/network_change_notifier.h"
@@ -72,12 +73,12 @@ static int ResolveAddrInfo(HostResolverProc* resolver_proc,
class HostResolverImpl::Request {
public:
- Request(LoadLog* load_log,
+ Request(const BoundNetLog& net_log,
int id,
const RequestInfo& info,
CompletionCallback* callback,
AddressList* addresses)
- : load_log_(load_log),
+ : net_log_(net_log),
id_(id),
info_(info),
job_(NULL),
@@ -116,8 +117,8 @@ class HostResolverImpl::Request {
return job_;
}
- LoadLog* load_log() const {
- return load_log_;
+ const BoundNetLog& net_log() {
+ return net_log_;
}
int id() const {
@@ -129,7 +130,7 @@ class HostResolverImpl::Request {
}
private:
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
// Unique ID for this request. Used by observers to identify requests.
int id_;
@@ -155,26 +156,31 @@ class HostResolverImpl::Request {
class HostResolverImpl::RequestsTrace
: public base::RefCountedThreadSafe<HostResolverImpl::RequestsTrace> {
public:
- RequestsTrace() : log_(new LoadLog(LoadLog::kUnbounded)) {}
+ RequestsTrace() {}
void Add(const std::string& msg) {
+ NetLog::Entry entry;
+ entry.type = NetLog::Entry::TYPE_STRING;
+ entry.time = base::TimeTicks::Now();
+ entry.string = msg;
+
AutoLock l(lock_);
- LoadLog::AddString(log_, msg);
+ entries_.push_back(entry);
}
- void Get(LoadLog* out) {
+ void Get(std::vector<NetLog::Entry>* entries) {
AutoLock l(lock_);
- out->Append(log_);
+ *entries = entries_;
}
void Clear() {
AutoLock l(lock_);
- log_ = new LoadLog(LoadLog::kUnbounded);
+ entries_.clear();
}
private:
Lock lock_;
- scoped_refptr<LoadLog> log_;
+ std::vector<NetLog::Entry> entries_;
};
//-----------------------------------------------------------------------------
@@ -613,15 +619,15 @@ int HostResolverImpl::Resolve(const RequestInfo& info,
AddressList* addresses,
CompletionCallback* callback,
RequestHandle* out_req,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
if (shutdown_)
return ERR_UNEXPECTED;
// Choose a unique ID number for observers to see.
int request_id = next_request_id_++;
- // Update the load log and notify registered observers.
- OnStartRequest(load_log, request_id, info);
+ // Update the net log and notify registered observers.
+ OnStartRequest(net_log, request_id, info);
// Build a key that identifies the request in the cache and in the
// outstanding jobs map.
@@ -636,8 +642,8 @@ int HostResolverImpl::Resolve(const RequestInfo& info,
if (error == OK)
addresses->SetFrom(cache_entry->addrlist, info.port());
- // Update the load log and notify registered observers.
- OnFinishRequest(load_log, request_id, info, error);
+ // Update the net log and notify registered observers.
+ OnFinishRequest(net_log, request_id, info, error);
return error;
}
@@ -657,15 +663,15 @@ int HostResolverImpl::Resolve(const RequestInfo& info,
if (cache_.get())
cache_->Set(key, error, addrlist, base::TimeTicks::Now());
- // Update the load log and notify registered observers.
- OnFinishRequest(load_log, request_id, info, error);
+ // Update the net log and notify registered observers.
+ OnFinishRequest(net_log, request_id, info, error);
return error;
}
// Create a handle for this request, and pass it back to the user if they
// asked for it (out_req != NULL).
- Request* req = new Request(load_log, request_id, info, callback, addresses);
+ Request* req = new Request(net_log, request_id, info, callback, addresses);
if (out_req)
*out_req = reinterpret_cast<RequestHandle>(req);
@@ -719,7 +725,7 @@ void HostResolverImpl::CancelRequest(RequestHandle req_handle) {
// NULL out the fields of req, to mark it as cancelled.
req->MarkAsCancelled();
- OnCancelRequest(req->load_log(), req->id(), req->info());
+ OnCancelRequest(req->net_log(), req->id(), req->info());
}
void HostResolverImpl::AddObserver(HostResolver::Observer* observer) {
@@ -804,13 +810,11 @@ bool HostResolverImpl::IsRequestsTracingEnabled() const {
return !!requests_trace_; // Cast to bool.
}
-scoped_refptr<LoadLog> HostResolverImpl::GetRequestsTrace() {
+bool HostResolverImpl::GetRequestsTrace(std::vector<NetLog::Entry>* entries) {
if (!requests_trace_)
- return NULL;
-
- scoped_refptr<LoadLog> copy_of_log = new LoadLog(LoadLog::kUnbounded);
- requests_trace_->Get(copy_of_log);
- return copy_of_log;
+ return false;
+ requests_trace_->Get(entries);
+ return true;
}
void HostResolverImpl::SetPoolConstraints(JobPoolIndex pool_index,
@@ -873,8 +877,8 @@ void HostResolverImpl::OnJobComplete(Job* job,
if (!req->was_cancelled()) {
DCHECK_EQ(job, req->job());
- // Update the load log and notify registered observers.
- OnFinishRequest(req->load_log(), req->id(), req->info(), error);
+ // Update the net log and notify registered observers.
+ OnFinishRequest(req->net_log(), req->id(), req->info(), error);
req->OnComplete(error, addrlist);
@@ -888,10 +892,10 @@ void HostResolverImpl::OnJobComplete(Job* job,
cur_completing_job_ = NULL;
}
-void HostResolverImpl::OnStartRequest(LoadLog* load_log,
+void HostResolverImpl::OnStartRequest(const BoundNetLog& net_log,
int request_id,
const RequestInfo& info) {
- LoadLog::BeginEvent(load_log, LoadLog::TYPE_HOST_RESOLVER_IMPL);
+ net_log.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL);
if (requests_trace_) {
requests_trace_->Add(StringPrintf(
@@ -909,20 +913,18 @@ void HostResolverImpl::OnStartRequest(LoadLog* load_log,
// Notify the observers of the start.
if (!observers_.empty()) {
- LoadLog::BeginEvent(
- load_log, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART);
+ net_log.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART);
for (ObserversList::iterator it = observers_.begin();
it != observers_.end(); ++it) {
(*it)->OnStartResolution(request_id, info);
}
- LoadLog::EndEvent(
- load_log, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART);
+ net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART);
}
}
-void HostResolverImpl::OnFinishRequest(LoadLog* load_log,
+void HostResolverImpl::OnFinishRequest(const BoundNetLog& net_log,
int request_id,
const RequestInfo& info,
int error) {
@@ -933,8 +935,7 @@ void HostResolverImpl::OnFinishRequest(LoadLog* load_log,
// Notify the observers of the completion.
if (!observers_.empty()) {
- LoadLog::BeginEvent(
- load_log, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONFINISH);
+ net_log.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONFINISH);
bool was_resolved = error == OK;
for (ObserversList::iterator it = observers_.begin();
@@ -942,36 +943,33 @@ void HostResolverImpl::OnFinishRequest(LoadLog* load_log,
(*it)->OnFinishResolutionWithStatus(request_id, was_resolved, info);
}
- LoadLog::EndEvent(
- load_log, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONFINISH);
+ net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONFINISH);
}
- LoadLog::EndEvent(load_log, LoadLog::TYPE_HOST_RESOLVER_IMPL);
+ net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL);
}
-void HostResolverImpl::OnCancelRequest(LoadLog* load_log,
+void HostResolverImpl::OnCancelRequest(const BoundNetLog& net_log,
int request_id,
const RequestInfo& info) {
- LoadLog::AddEvent(load_log, LoadLog::TYPE_CANCELLED);
+ net_log.AddEvent(NetLog::TYPE_CANCELLED);
if (requests_trace_)
requests_trace_->Add(StringPrintf("Cancelled request r%d", request_id));
// Notify the observers of the cancellation.
if (!observers_.empty()) {
- LoadLog::BeginEvent(
- load_log, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONCANCEL);
+ net_log.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONCANCEL);
for (ObserversList::iterator it = observers_.begin();
it != observers_.end(); ++it) {
(*it)->OnCancelResolution(request_id, info);
}
- LoadLog::EndEvent(
- load_log, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONCANCEL);
+ net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONCANCEL);
}
- LoadLog::EndEvent(load_log, LoadLog::TYPE_HOST_RESOLVER_IMPL);
+ net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL);
}
void HostResolverImpl::OnIPAddressChanged() {
@@ -1052,7 +1050,7 @@ int HostResolverImpl::EnqueueRequest(JobPool* pool, Request* req) {
if (requests_trace_)
requests_trace_->Add(StringPrintf("Evicted request r%d", r->id()));
- OnFinishRequest(r->load_log(), r->id(), r->info(), error);
+ OnFinishRequest(r->net_log(), r->id(), r->info(), error);
if (r == req)
return error;
diff --git a/net/base/host_resolver_impl.h b/net/base/host_resolver_impl.h
index 3e273cd..de2cc14 100644
--- a/net/base/host_resolver_impl.h
+++ b/net/base/host_resolver_impl.h
@@ -12,6 +12,7 @@
#include "net/base/host_cache.h"
#include "net/base/host_resolver.h"
#include "net/base/host_resolver_proc.h"
+#include "net/base/net_log.h"
#include "net/base/network_change_notifier.h"
namespace net {
@@ -83,7 +84,7 @@ class HostResolverImpl : public HostResolver,
AddressList* addresses,
CompletionCallback* callback,
RequestHandle* out_req,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
virtual void CancelRequest(RequestHandle req);
virtual void AddObserver(HostResolver::Observer* observer);
virtual void RemoveObserver(HostResolver::Observer* observer);
@@ -108,8 +109,8 @@ class HostResolverImpl : public HostResolver,
bool IsRequestsTracingEnabled() const;
- // Returns a copy of the requests trace log, or NULL if there is none.
- scoped_refptr<LoadLog> GetRequestsTrace();
+ // Gets a copy of the requests trace log.
+ bool GetRequestsTrace(std::vector<NetLog::Entry>* entries);
// Applies a set of constraints for requests that belong to the specified
// pool. NOTE: Don't call this after requests have been already been started.
@@ -160,18 +161,18 @@ class HostResolverImpl : public HostResolver,
void OnJobComplete(Job* job, int error, const AddressList& addrlist);
// Called when a request has just been started.
- void OnStartRequest(LoadLog* load_log,
+ void OnStartRequest(const BoundNetLog& net_log,
int request_id,
const RequestInfo& info);
// Called when a request has just completed (before its callback is run).
- void OnFinishRequest(LoadLog* load_log,
+ void OnFinishRequest(const BoundNetLog& net_log,
int request_id,
const RequestInfo& info,
int error);
// Called when a request has been cancelled.
- void OnCancelRequest(LoadLog* load_log,
+ void OnCancelRequest(const BoundNetLog& net_log,
int request_id,
const RequestInfo& info);
diff --git a/net/base/host_resolver_impl_unittest.cc b/net/base/host_resolver_impl_unittest.cc
index ee44528..bd19f0b 100644
--- a/net/base/host_resolver_impl_unittest.cc
+++ b/net/base/host_resolver_impl_unittest.cc
@@ -12,10 +12,10 @@
#include "base/string_util.h"
#include "net/base/address_list.h"
#include "net/base/completion_callback.h"
-#include "net/base/load_log_unittest.h"
#include "net/base/mock_host_resolver.h"
#include "net/base/mock_network_change_notifier.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log_unittest.h"
#include "net/base/net_util.h"
#include "net/base/sys_addrinfo.h"
#include "net/base/test_completion_callback.h"
@@ -262,13 +262,15 @@ TEST_F(HostResolverImplTest, SynchronousLookup) {
CreateHostResolverImpl(resolver_proc));
HostResolver::RequestInfo info("just.testing", kPortnum);
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- int err = host_resolver->Resolve(info, &adrlist, NULL, NULL, log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ int err = host_resolver->Resolve(info, &adrlist, NULL, NULL, log.bound());
EXPECT_EQ(OK, err);
- EXPECT_EQ(2u, log->entries().size());
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_HOST_RESOLVER_IMPL));
- EXPECT_TRUE(LogContainsEndEvent(*log, 1, LoadLog::TYPE_HOST_RESOLVER_IMPL));
+ EXPECT_EQ(2u, log.entries().size());
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log.entries(), 0, NetLog::TYPE_HOST_RESOLVER_IMPL));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), 1, NetLog::TYPE_HOST_RESOLVER_IMPL));
const struct addrinfo* ainfo = adrlist.head();
EXPECT_EQ(static_cast<addrinfo*>(NULL), ainfo->ai_next);
@@ -292,20 +294,23 @@ TEST_F(HostResolverImplTest, AsynchronousLookup) {
CreateHostResolverImpl(resolver_proc));
HostResolver::RequestInfo info("just.testing", kPortnum);
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- int err = host_resolver->Resolve(info, &adrlist, &callback_, NULL, log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ int err = host_resolver->Resolve(info, &adrlist, &callback_, NULL,
+ log.bound());
EXPECT_EQ(ERR_IO_PENDING, err);
- EXPECT_EQ(1u, log->entries().size());
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_HOST_RESOLVER_IMPL));
+ EXPECT_EQ(1u, log.entries().size());
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log.entries(), 0, NetLog::TYPE_HOST_RESOLVER_IMPL));
MessageLoop::current()->Run();
ASSERT_TRUE(callback_called_);
ASSERT_EQ(OK, callback_result_);
- EXPECT_EQ(2u, log->entries().size());
- EXPECT_TRUE(LogContainsEndEvent(*log, 1, LoadLog::TYPE_HOST_RESOLVER_IMPL));
+ EXPECT_EQ(2u, log.entries().size());
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), 1, NetLog::TYPE_HOST_RESOLVER_IMPL));
const struct addrinfo* ainfo = adrlist.head();
EXPECT_EQ(static_cast<addrinfo*>(NULL), ainfo->ai_next);
@@ -321,7 +326,7 @@ TEST_F(HostResolverImplTest, CanceledAsynchronousLookup) {
scoped_refptr<WaitingHostResolverProc> resolver_proc =
new WaitingHostResolverProc(NULL);
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
{
scoped_refptr<HostResolver> host_resolver(
CreateHostResolverImpl(resolver_proc));
@@ -329,7 +334,8 @@ TEST_F(HostResolverImplTest, CanceledAsynchronousLookup) {
const int kPortnum = 80;
HostResolver::RequestInfo info("just.testing", kPortnum);
- int err = host_resolver->Resolve(info, &adrlist, &callback_, NULL, log);
+ int err = host_resolver->Resolve(info, &adrlist, &callback_, NULL,
+ log.bound());
EXPECT_EQ(ERR_IO_PENDING, err);
// Make sure we will exit the queue even when callback is not called.
@@ -341,11 +347,13 @@ TEST_F(HostResolverImplTest, CanceledAsynchronousLookup) {
resolver_proc->Signal();
- EXPECT_EQ(3u, log->entries().size());
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_HOST_RESOLVER_IMPL));
+ EXPECT_EQ(3u, log.entries().size());
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log.entries(), 0, NetLog::TYPE_HOST_RESOLVER_IMPL));
EXPECT_TRUE(LogContainsEvent(
- *log, 1, LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE));
- EXPECT_TRUE(LogContainsEndEvent(*log, 2, LoadLog::TYPE_HOST_RESOLVER_IMPL));
+ log.entries(), 1, NetLog::TYPE_CANCELLED, NetLog::PHASE_NONE));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), 2, NetLog::TYPE_HOST_RESOLVER_IMPL));
EXPECT_FALSE(callback_called_);
}
@@ -892,22 +900,23 @@ TEST_F(HostResolverImplTest, Observers) {
// Resolve "host1".
HostResolver::RequestInfo info1("host1", 70);
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- int rv = host_resolver->Resolve(info1, &addrlist, NULL, NULL, log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ int rv = host_resolver->Resolve(info1, &addrlist, NULL, NULL, log.bound());
EXPECT_EQ(OK, rv);
- EXPECT_EQ(6u, log->entries().size());
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_HOST_RESOLVER_IMPL));
+ EXPECT_EQ(6u, log.entries().size());
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log.entries(), 0, NetLog::TYPE_HOST_RESOLVER_IMPL));
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 1, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART));
+ log.entries(), 1, NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 2, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART));
+ log.entries(), 2, NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART));
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 3, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONFINISH));
+ log.entries(), 3, NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONFINISH));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 4, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONFINISH));
+ log.entries(), 4, NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONFINISH));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 5, LoadLog::TYPE_HOST_RESOLVER_IMPL));
+ log.entries(), 5, NetLog::TYPE_HOST_RESOLVER_IMPL));
EXPECT_EQ(1U, observer.start_log.size());
EXPECT_EQ(1U, observer.finish_log.size());
diff --git a/net/base/load_log.cc b/net/base/load_log.cc
deleted file mode 100644
index ec7f59b..0000000
--- a/net/base/load_log.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-// 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.
-
-#include "net/base/load_log.h"
-#include "base/logging.h"
-
-namespace net {
-
-LoadLog::LoadLog(size_t max_num_entries)
- : num_entries_truncated_(0), max_num_entries_(max_num_entries) {
- DCHECK_GT(max_num_entries, 0u);
-}
-
-// static
-const char* LoadLog::EventTypeToString(EventType event) {
- switch (event) {
-#define EVENT_TYPE(label) case TYPE_ ## label: return #label;
-#include "net/base/load_log_event_type_list.h"
-#undef EVENT_TYPE
- }
- return NULL;
-}
-
-void LoadLog::Add(const Entry& entry) {
- // Minor optimization. TODO(eroman): use StackVector instead.
- if (entries_.empty())
- entries_.reserve(10); // It is likely we will have at least 10 entries.
-
- // Enforce a bound of |max_num_entries_| -- once we reach it, keep overwriting
- // the final entry in the log.
-
- if (entries_.size() + 1 <= max_num_entries_ ||
- max_num_entries_ == kUnbounded) {
- entries_.push_back(entry);
- } else {
- num_entries_truncated_ += 1;
- entries_[max_num_entries_ - 1] = entry;
- }
-}
-
-void LoadLog::Append(const LoadLog* log) {
- for (size_t i = 0; i < log->entries().size(); ++i)
- Add(log->entries()[i]);
- num_entries_truncated_ += log->num_entries_truncated();
-}
-
-} // namespace net
diff --git a/net/base/load_log.h b/net/base/load_log.h
deleted file mode 100644
index 49e0ef5..0000000
--- a/net/base/load_log.h
+++ /dev/null
@@ -1,196 +0,0 @@
-// 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 <string>
-#include <vector>
-
-#include "base/ref_counted.h"
-#include "base/time.h"
-
-namespace net {
-
-// LoadLog stores information associated with an individual request. This
-// includes event traces (used to build up profiling information), error
-// return codes from network modules, and arbitrary text messages.
-//
-// Note that LoadLog is NOT THREADSAFE, however it is RefCountedThreadSafe so
-// that it can be AddRef() / Release() across threads.
-class LoadLog : public base::RefCountedThreadSafe<LoadLog> {
- public:
- // TODO(eroman): Really, EventType and EventPhase should be
- // Event::Type and Event::Phase, to be consisent with Entry.
- // But there lots of consumers to change!
- enum EventType {
-#define EVENT_TYPE(label) TYPE_ ## label,
-#include "net/base/load_log_event_type_list.h"
-#undef EVENT_TYPE
- };
-
- // The 'phase' of an event trace (whether it marks the beginning or end
- // of an event.).
- enum EventPhase {
- PHASE_NONE,
- PHASE_BEGIN,
- // TODO(eroman): DEPRECATED: Use TYPE_STRING_LITERAL instead.
- PHASE_END,
- };
-
- struct Event {
- Event(EventType type, EventPhase phase) : type(type), phase(phase) {}
- Event() {}
-
- EventType type;
- EventPhase phase;
- };
-
- struct Entry {
- enum Type {
- // This entry describes an event trace.
- TYPE_EVENT,
-
- // This entry describes a network error code that was returned.
- TYPE_ERROR_CODE,
-
- // This entry is a free-form std::string.
- TYPE_STRING,
-
- // This entry is a C-string literal.
- TYPE_STRING_LITERAL,
- };
-
- Entry(base::TimeTicks time, int error_code)
- : type(TYPE_ERROR_CODE), time(time), error_code(error_code) {
- }
-
- Entry(base::TimeTicks time, const Event& event)
- : type(TYPE_EVENT), time(time), event(event) {
- }
-
- Entry(base::TimeTicks time, const std::string& string)
- : type(TYPE_STRING), time(time), string(string) {
- }
-
- Entry(base::TimeTicks time, const char* literal)
- : type(TYPE_STRING_LITERAL), time(time), literal(literal) {
- }
-
- Type type;
- base::TimeTicks time;
-
- // The following is basically a union, only one of them should be
- // used depending on what |type| is.
- Event event; // valid when (type == TYPE_EVENT).
- int error_code; // valid when (type == TYPE_ERROR_CODE).
- std::string string; // valid when (type == TYPE_STRING).
- const char* literal; // valid when (type == TYPE_STRING_LITERAL).
- };
-
- // Ordered set of entries that were logged.
- // TODO(eroman): use a StackVector or array to avoid allocations.
- typedef std::vector<Entry> EntryList;
-
- // Value for max_num_entries to indicate the LoadLog has no size limit.
- static const size_t kUnbounded = static_cast<size_t>(-1);
-
- // Creates a log, which can hold up to |max_num_entries| entries.
- // If |max_num_entries| is |kUnbounded|, then the log can grow arbitrarily
- // large.
- //
- // If entries are dropped because the log has grown too large, the final entry
- // will be overwritten.
- explicit LoadLog(size_t max_num_entries);
-
- // --------------------------------------------------------------------------
-
- // The public interface for adding events to the log are static methods.
- // This makes it easier to deal with optionally NULL LoadLog.
-
- // Adds an instantaneous event to the log.
- // TODO(eroman): DEPRECATED: use AddStringLiteral() instead.
- static void AddEvent(LoadLog* log, EventType event_type) {
- if (log)
- log->Add(Entry(base::TimeTicks::Now(), Event(event_type, PHASE_NONE)));
- }
-
- // Adds the start of an event to the log. Presumably this event type measures
- // a time duration, and will be matched by a call to EndEvent(event_type).
- static void BeginEvent(LoadLog* log, EventType event_type) {
- if (log)
- log->Add(Entry(base::TimeTicks::Now(), Event(event_type, PHASE_BEGIN)));
- }
-
- // Adds the end of an event to the log. Presumably this event type measures
- // a time duration, and we are matching an earlier call to
- // BeginEvent(event_type).
- static void EndEvent(LoadLog* log, EventType event_type) {
- if (log)
- log->Add(Entry(base::TimeTicks::Now(), Event(event_type, PHASE_END)));
- }
-
- // |literal| should be a string literal (i.e. lives in static storage).
- static void AddStringLiteral(LoadLog* log, const char* literal) {
- if (log)
- log->Add(Entry(base::TimeTicks::Now(), literal));
- }
-
- static void AddString(LoadLog* log, const std::string& string) {
- if (log)
- log->Add(Entry(base::TimeTicks::Now(), string));
- }
-
- static void AddErrorCode(LoadLog* log, int error) {
- if (log)
- log->Add(Entry(base::TimeTicks::Now(), error));
- }
-
- static bool IsUnbounded(const LoadLog* log) {
- return log && log->is_unbounded();
- }
-
- // --------------------------------------------------------------------------
-
- // Returns the list of all entries in the log.
- const EntryList& entries() const {
- return entries_;
- }
-
- // Returns the number of entries that were dropped from the log because the
- // maximum size had been reached.
- size_t num_entries_truncated() const {
- return num_entries_truncated_;
- }
-
- // Returns the bound on the size of the log.
- size_t max_num_entries() const {
- return max_num_entries_;
- }
-
- bool is_unbounded() const {
- return max_num_entries_ == kUnbounded;
- }
-
- // Returns a C-String symbolic name for |event|.
- static const char* EventTypeToString(EventType event_type);
-
- void Add(const Entry& entry);
-
- // Copies all entries from |log|, appending it to the end of |this|.
- void Append(const LoadLog* log);
-
- private:
- friend class base::RefCountedThreadSafe<LoadLog>;
-
- ~LoadLog() {}
-
- EntryList entries_;
- size_t num_entries_truncated_;
- size_t max_num_entries_;;
-};
-
-} // namespace net
-
-#endif // NET_BASE_LOAD_LOG_H_
diff --git a/net/base/load_log_unittest.cc b/net/base/load_log_unittest.cc
deleted file mode 100644
index c55cf9b..0000000
--- a/net/base/load_log_unittest.cc
+++ /dev/null
@@ -1,185 +0,0 @@
-// 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.
-
-#include "net/base/load_log_unittest.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace net {
-
-namespace {
-
-TEST(LoadLogTest, Nullable) {
- // Make sure that the static methods can be called with NULL (no-op).
- // (Should not crash).
- LoadLog::BeginEvent(NULL, LoadLog::TYPE_HOST_RESOLVER_IMPL);
- LoadLog::AddEvent(NULL, LoadLog::TYPE_HOST_RESOLVER_IMPL);
- LoadLog::EndEvent(NULL, LoadLog::TYPE_HOST_RESOLVER_IMPL);
-}
-
-TEST(LoadLogTest, Basic) {
- scoped_refptr<LoadLog> log(new LoadLog(10));
-
- // Logs start off empty.
- EXPECT_EQ(0u, log->entries().size());
- EXPECT_EQ(0u, log->num_entries_truncated());
-
- // Add 3 entries.
-
- log->Add(LoadLog::Entry(MakeTime(0),
- LoadLog::Event(LoadLog::TYPE_HOST_RESOLVER_IMPL,
- LoadLog::PHASE_BEGIN)));
- log->Add(LoadLog::Entry(MakeTime(2),
- LoadLog::Event(LoadLog::TYPE_CANCELLED,
- LoadLog::PHASE_NONE)));
- log->Add(
- LoadLog::Entry(
- MakeTime(11),
- LoadLog::Event(LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART,
- LoadLog::PHASE_END)));
-
- EXPECT_EQ(3u, log->entries().size());
- EXPECT_EQ(0u, log->num_entries_truncated());
-
- EXPECT_TRUE(LogContainsEventAtTime(
- *log, 0, MakeTime(0), LoadLog::TYPE_HOST_RESOLVER_IMPL,
- LoadLog::PHASE_BEGIN));
-
- EXPECT_TRUE(LogContainsEventAtTime(
- *log, 1, MakeTime(2), LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE));
-
- EXPECT_TRUE(LogContainsEventAtTime(
- *log, 2, MakeTime(11), LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART,
- LoadLog::PHASE_END));
-}
-
-// Test that the log's size is strictly bounded.
-TEST(LoadLogTest, Truncation) {
- size_t kMaxNumEntries = 10;
- scoped_refptr<LoadLog> log(new LoadLog(kMaxNumEntries));
-
- // Max it out.
- for (size_t i = 0; i < kMaxNumEntries; ++i) {
- log->Add(LoadLog::Entry(MakeTime(i),
- LoadLog::Event(LoadLog::TYPE_CANCELLED,
- LoadLog::PHASE_NONE)));
- }
-
- EXPECT_EQ(kMaxNumEntries, log->entries().size());
- EXPECT_EQ(0u, log->num_entries_truncated());
-
- // Check the last entry.
- EXPECT_TRUE(LogContainsEventAtTime(
- *log, 9, MakeTime(9), LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE));
-
- // Add three entries while maxed out (will cause truncation)
- log->Add(LoadLog::Entry(MakeTime(0),
- LoadLog::Event(LoadLog::TYPE_CANCELLED,
- LoadLog::PHASE_NONE)));
- log->Add(LoadLog::Entry(MakeTime(1),
- LoadLog::Event(LoadLog::TYPE_CANCELLED,
- LoadLog::PHASE_NONE)));
- log->Add(LoadLog::Entry(MakeTime(2),
- LoadLog::Event(LoadLog::TYPE_CANCELLED,
- LoadLog::PHASE_NONE)));
-
- EXPECT_EQ(kMaxNumEntries, log->entries().size());
- EXPECT_EQ(3u, log->num_entries_truncated());
-
- // Check the last entry -- it should be the final entry we added.
- EXPECT_TRUE(LogContainsEventAtTime(
- *log, 9, MakeTime(2), LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE));
-}
-
-TEST(LoadLogTest, Append) {
- scoped_refptr<LoadLog> log1(new LoadLog(10));
- scoped_refptr<LoadLog> log2(new LoadLog(10));
-
- log1->Add(LoadLog::Entry(MakeTime(0),
- LoadLog::Event(LoadLog::TYPE_HOST_RESOLVER_IMPL,
- LoadLog::PHASE_BEGIN)));
-
- log2->Add(LoadLog::Entry(MakeTime(3),
- LoadLog::Event(LoadLog::TYPE_CANCELLED,
- LoadLog::PHASE_NONE)));
- log2->Add(LoadLog::Entry(MakeTime(9),
- LoadLog::Event(LoadLog::TYPE_HOST_RESOLVER_IMPL,
- LoadLog::PHASE_END)));
-
- log1->Append(log2);
-
- // Add something else to log2 (should NOT be reflected in log1).
- log2->Add(LoadLog::Entry(MakeTime(19),
- LoadLog::Event(LoadLog::TYPE_CANCELLED,
- LoadLog::PHASE_NONE)));
-
- EXPECT_EQ(3u, log1->entries().size());
- EXPECT_EQ(0u, log1->num_entries_truncated());
-
- EXPECT_TRUE(LogContainsEventAtTime(
- *log1, 0, MakeTime(0), LoadLog::TYPE_HOST_RESOLVER_IMPL,
- LoadLog::PHASE_BEGIN));
-
- EXPECT_TRUE(LogContainsEventAtTime(
- *log1, 1, MakeTime(3), LoadLog::TYPE_CANCELLED,
- LoadLog::PHASE_NONE));
-
- EXPECT_TRUE(LogContainsEventAtTime(
- *log1, 2, MakeTime(9), LoadLog::TYPE_HOST_RESOLVER_IMPL,
- LoadLog::PHASE_END));
-}
-
-TEST(LoadLogTest, AppendWithTruncation) {
- // Append() should also respect the maximum number of entries bound.
- // (This is basically the same test as LoadLogTest.Truncation).
-
- // Create two load logs, which both have 6 out of 10 entries filled.
- size_t kMaxNumEntries = 10;
- scoped_refptr<LoadLog> log1(new LoadLog(kMaxNumEntries));
- scoped_refptr<LoadLog> log2(new LoadLog(kMaxNumEntries));
- for (size_t i = 0; i < 6; ++i) {
- log1->Add(LoadLog::Entry(MakeTime(i),
- LoadLog::Event(LoadLog::TYPE_CANCELLED,
- LoadLog::PHASE_NONE)));
- log2->Add(LoadLog::Entry(MakeTime(2 * i),
- LoadLog::Event(LoadLog::TYPE_CANCELLED,
- LoadLog::PHASE_NONE)));
- }
-
- // Append log2 to log1.
- log1->Append(log2);
-
- // The combined log totalled 12 entries, so 2 must have been dropped.
- EXPECT_EQ(10u, log1->entries().size());
- EXPECT_EQ(2u, log1->num_entries_truncated());
-
- // Combined log should end with the final entry of log2.
- EXPECT_TRUE(LogContainsEventAtTime(
- *log1, 9, MakeTime(10), LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE));
-}
-
-TEST(LoadLogTest, EventTypeToString) {
- EXPECT_STREQ("HOST_RESOLVER_IMPL",
- LoadLog::EventTypeToString(LoadLog::TYPE_HOST_RESOLVER_IMPL));
- EXPECT_STREQ("HOST_RESOLVER_IMPL_OBSERVER_ONSTART",
- LoadLog::EventTypeToString(
- LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART));
-}
-
-TEST(LoadLogTest, String) {
- scoped_refptr<LoadLog> log(new LoadLog(10));
-
- // Make sure that AddStringLiteral() adds a literal and not a std::string.
- // (in case there is any funny-business with implicit conversions).
- LoadLog::AddStringLiteral(log, "This is a literal");
- log->Add(LoadLog::Entry(MakeTime(0), "Another literal"));
- log->Add(LoadLog::Entry(MakeTime(0), std::string("Now a std::string")));
-
- ASSERT_EQ(3u, log->entries().size());
- EXPECT_EQ(LoadLog::Entry::TYPE_STRING_LITERAL, log->entries()[0].type);
- EXPECT_EQ(LoadLog::Entry::TYPE_STRING_LITERAL, log->entries()[1].type);
- EXPECT_EQ(LoadLog::Entry::TYPE_STRING, log->entries()[2].type);
-}
-
-} // namespace
-} // namespace net
diff --git a/net/base/load_log_util_unittest.cc b/net/base/load_log_util_unittest.cc
deleted file mode 100644
index 7dba908..0000000
--- a/net/base/load_log_util_unittest.cc
+++ /dev/null
@@ -1,138 +0,0 @@
-// 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.
-
-#include "net/base/load_log_unittest.h"
-#include "net/base/load_log_util.h"
-#include "net/base/net_errors.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace net {
-namespace {
-
-TEST(LoadLogUtilTest, Basic) {
- scoped_refptr<LoadLog> log(new LoadLog(10));
-
- log->Add(LoadLog::Entry(MakeTime(1),
- LoadLog::Event(LoadLog::TYPE_HOST_RESOLVER_IMPL,
- LoadLog::PHASE_BEGIN)));
- log->Add(
- LoadLog::Entry(
- MakeTime(5),
- LoadLog::Event(LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART,
- LoadLog::PHASE_BEGIN)));
- log->Add(
- LoadLog::Entry(
- MakeTime(8),
- LoadLog::Event(LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART,
- LoadLog::PHASE_END)));
-
- log->Add(LoadLog::Entry(MakeTime(12),
- LoadLog::Event(LoadLog::TYPE_CANCELLED,
- LoadLog::PHASE_NONE)));
-
- log->Add(LoadLog::Entry(MakeTime(131),
- LoadLog::Event(LoadLog::TYPE_HOST_RESOLVER_IMPL,
- LoadLog::PHASE_END)));
-
- EXPECT_EQ(
- "t= 1: +HOST_RESOLVER_IMPL [dt=130]\n"
- "t= 5: HOST_RESOLVER_IMPL_OBSERVER_ONSTART [dt= 3]\n"
- "t= 12: CANCELLED\n"
- "t=131: -HOST_RESOLVER_IMPL",
- LoadLogUtil::PrettyPrintAsEventTree(log));
-}
-
-TEST(LoadLogUtilTest, Basic2) {
- scoped_refptr<LoadLog> log(new LoadLog(10));
-
- log->Add(LoadLog::Entry(MakeTime(1),
- LoadLog::Event(LoadLog::TYPE_HOST_RESOLVER_IMPL,
- LoadLog::PHASE_BEGIN)));
-
- log->Add(LoadLog::Entry(MakeTime(12), "Sup foo"));
- log->Add(LoadLog::Entry(MakeTime(12), ERR_UNEXPECTED));
- log->Add(LoadLog::Entry(MakeTime(14), "Multiline\nString"));
-
- log->Add(LoadLog::Entry(MakeTime(131),
- LoadLog::Event(LoadLog::TYPE_HOST_RESOLVER_IMPL,
- LoadLog::PHASE_END)));
-
- EXPECT_EQ(
- "t= 1: +HOST_RESOLVER_IMPL [dt=130]\n"
- "t= 12: \"Sup foo\"\n"
- "t= 12: error code: -9 (net::ERR_UNEXPECTED)\n"
- "t= 14: \"Multiline\n"
- "String\"\n"
- "t=131: -HOST_RESOLVER_IMPL",
- LoadLogUtil::PrettyPrintAsEventTree(log));
-}
-
-TEST(LoadLogUtilTest, UnmatchedOpen) {
- scoped_refptr<LoadLog> log(new LoadLog(10));
-
- log->Add(LoadLog::Entry(MakeTime(3),
- LoadLog::Event(LoadLog::TYPE_HOST_RESOLVER_IMPL,
- LoadLog::PHASE_BEGIN)));
- // Note that there is no matching call to PHASE_END for all of the following.
- log->Add(
- LoadLog::Entry(
- MakeTime(6),
- LoadLog::Event(LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART,
- LoadLog::PHASE_BEGIN)));
- log->Add(
- LoadLog::Entry(
- MakeTime(7),
- LoadLog::Event(LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART,
- LoadLog::PHASE_BEGIN)));
- log->Add(
- LoadLog::Entry(
- MakeTime(8),
- LoadLog::Event(LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART,
- LoadLog::PHASE_BEGIN)));
- log->Add(LoadLog::Entry(MakeTime(10),
- LoadLog::Event(LoadLog::TYPE_CANCELLED,
- LoadLog::PHASE_NONE)));
- log->Add(LoadLog::Entry(MakeTime(16),
- LoadLog::Event(LoadLog::TYPE_HOST_RESOLVER_IMPL,
- LoadLog::PHASE_END)));
-
- EXPECT_EQ(
- "t= 3: +HOST_RESOLVER_IMPL [dt=13]\n"
- "t= 6: +HOST_RESOLVER_IMPL_OBSERVER_ONSTART [dt=10]\n"
- "t= 7: +HOST_RESOLVER_IMPL_OBSERVER_ONSTART [dt= 9]\n"
- "t= 8: +HOST_RESOLVER_IMPL_OBSERVER_ONSTART [dt= 8]\n"
- "t=10: CANCELLED\n"
- "t=16: -HOST_RESOLVER_IMPL",
- LoadLogUtil::PrettyPrintAsEventTree(log));
-}
-
-TEST(LoadLogUtilTest, DisplayOfTruncated) {
- size_t kMaxNumEntries = 5;
- scoped_refptr<LoadLog> log(new LoadLog(kMaxNumEntries));
-
- // Add a total of 10 events. This means that 5 will be truncated.
- log->Add(LoadLog::Entry(MakeTime(0),
- LoadLog::Event(LoadLog::TYPE_TCP_CONNECT,
- LoadLog::PHASE_BEGIN)));
- for (size_t i = 1; i < 8; ++i) {
- log->Add(LoadLog::Entry(MakeTime(i),
- LoadLog::Event(LoadLog::TYPE_CANCELLED,
- LoadLog::PHASE_NONE)));
- }
- log->Add(LoadLog::Entry(MakeTime(9),
- LoadLog::Event(LoadLog::TYPE_TCP_CONNECT,
- LoadLog::PHASE_END)));
-
- EXPECT_EQ(
- "t=0: +TCP_CONNECT [dt=9]\n"
- "t=1: CANCELLED\n"
- "t=2: CANCELLED\n"
- "t=3: CANCELLED\n"
- " ... Truncated 4 entries ...\n"
- "t=9: -TCP_CONNECT",
- LoadLogUtil::PrettyPrintAsEventTree(log));
-}
-
-} // namespace
-} // namespace net
diff --git a/net/base/mapped_host_resolver.cc b/net/base/mapped_host_resolver.cc
index 164d7c6..fdd9de7 100644
--- a/net/base/mapped_host_resolver.cc
+++ b/net/base/mapped_host_resolver.cc
@@ -18,11 +18,11 @@ int MappedHostResolver::Resolve(const RequestInfo& info,
AddressList* addresses,
CompletionCallback* callback,
RequestHandle* out_req,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
// Modify the request before forwarding it to |impl_|.
RequestInfo modified_info = info;
RewriteRequest(&modified_info);
- return impl_->Resolve(modified_info, addresses, callback, out_req, load_log);
+ return impl_->Resolve(modified_info, addresses, callback, out_req, net_log);
}
void MappedHostResolver::CancelRequest(RequestHandle req) {
diff --git a/net/base/mapped_host_resolver.h b/net/base/mapped_host_resolver.h
index a637a40..7339f06 100644
--- a/net/base/mapped_host_resolver.h
+++ b/net/base/mapped_host_resolver.h
@@ -28,7 +28,7 @@ class MappedHostResolver : public HostResolver {
AddressList* addresses,
CompletionCallback* callback,
RequestHandle* out_req,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
virtual void CancelRequest(RequestHandle req);
virtual void AddObserver(Observer* observer);
virtual void RemoveObserver(Observer* observer);
diff --git a/net/base/mapped_host_resolver_unittest.cc b/net/base/mapped_host_resolver_unittest.cc
index 6da84e0..4b7281c 100644
--- a/net/base/mapped_host_resolver_unittest.cc
+++ b/net/base/mapped_host_resolver_unittest.cc
@@ -6,6 +6,7 @@
#include "net/base/mock_host_resolver.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log.h"
#include "net/base/net_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -31,7 +32,7 @@ TEST(MappedHostResolverTest, Inclusion) {
// Try resolving "www.google.com:80". There are no mappings yet, so this
// hits |resolver_impl| and fails.
rv = resolver->Resolve(HostResolver::RequestInfo("www.google.com", 80),
- &address_list, NULL, NULL, NULL);
+ &address_list, NULL, NULL, BoundNetLog());
EXPECT_EQ(ERR_NAME_NOT_RESOLVED, rv);
// Remap *.google.com to baz.com.
@@ -39,7 +40,7 @@ TEST(MappedHostResolverTest, Inclusion) {
// Try resolving "www.google.com:80". Should be remapped to "baz.com:80".
rv = resolver->Resolve(HostResolver::RequestInfo("www.google.com", 80),
- &address_list, NULL, NULL, NULL);
+ &address_list, NULL, NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("192.168.1.5", NetAddressToString(address_list.head()));
EXPECT_EQ(80, address_list.GetPort());
@@ -47,7 +48,7 @@ TEST(MappedHostResolverTest, Inclusion) {
// Try resolving "foo.com:77". This will NOT be remapped, so result
// is "foo.com:77".
rv = resolver->Resolve(HostResolver::RequestInfo("foo.com", 77),
- &address_list, NULL, NULL, NULL);
+ &address_list, NULL, NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("192.168.1.8", NetAddressToString(address_list.head()));
EXPECT_EQ(77, address_list.GetPort());
@@ -57,7 +58,7 @@ TEST(MappedHostResolverTest, Inclusion) {
// Try resolving "chromium.org:61". Should be remapped to "proxy:99".
rv = resolver->Resolve(HostResolver::RequestInfo("chromium.org", 61),
- &address_list, NULL, NULL, NULL);
+ &address_list, NULL, NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("192.168.1.11", NetAddressToString(address_list.head()));
EXPECT_EQ(99, address_list.GetPort());
@@ -85,14 +86,14 @@ TEST(MappedHostResolverTest, Exclusion) {
// Try resolving "www.google.com". Should not be remapped due to exclusion).
rv = resolver->Resolve(HostResolver::RequestInfo("www.google.com", 80),
- &address_list, NULL, NULL, NULL);
+ &address_list, NULL, NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("192.168.1.3", NetAddressToString(address_list.head()));
EXPECT_EQ(80, address_list.GetPort());
// Try resolving "chrome.com:80". Should be remapped to "baz:80".
rv = resolver->Resolve(HostResolver::RequestInfo("chrome.com", 80),
- &address_list, NULL, NULL, NULL);
+ &address_list, NULL, NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("192.168.1.5", NetAddressToString(address_list.head()));
EXPECT_EQ(80, address_list.GetPort());
@@ -116,14 +117,14 @@ TEST(MappedHostResolverTest, SetRulesFromString) {
// Try resolving "www.google.com". Should be remapped to "baz".
rv = resolver->Resolve(HostResolver::RequestInfo("www.google.com", 80),
- &address_list, NULL, NULL, NULL);
+ &address_list, NULL, NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("192.168.1.7", NetAddressToString(address_list.head()));
EXPECT_EQ(80, address_list.GetPort());
// Try resolving "chrome.net:80". Should be remapped to "bar:60".
rv = resolver->Resolve(HostResolver::RequestInfo("chrome.net", 80),
- &address_list, NULL, NULL, NULL);
+ &address_list, NULL, NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("192.168.1.9", NetAddressToString(address_list.head()));
EXPECT_EQ(60, address_list.GetPort());
diff --git a/net/base/mock_host_resolver.cc b/net/base/mock_host_resolver.cc
index 239275e..7f2512f 100644
--- a/net/base/mock_host_resolver.cc
+++ b/net/base/mock_host_resolver.cc
@@ -46,12 +46,12 @@ int MockHostResolverBase::Resolve(const RequestInfo& info,
AddressList* addresses,
CompletionCallback* callback,
RequestHandle* out_req,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
if (synchronous_mode_) {
callback = NULL;
out_req = NULL;
}
- return impl_->Resolve(info, addresses, callback, out_req, load_log);
+ return impl_->Resolve(info, addresses, callback, out_req, net_log);
}
void MockHostResolverBase::CancelRequest(RequestHandle req) {
diff --git a/net/base/mock_host_resolver.h b/net/base/mock_host_resolver.h
index c1f93f5..d08dc42 100644
--- a/net/base/mock_host_resolver.h
+++ b/net/base/mock_host_resolver.h
@@ -43,7 +43,7 @@ class MockHostResolverBase : public HostResolver {
AddressList* addresses,
CompletionCallback* callback,
RequestHandle* out_req,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
virtual void CancelRequest(RequestHandle req);
virtual void AddObserver(Observer* observer);
virtual void RemoveObserver(Observer* observer);
diff --git a/net/base/net_log.cc b/net/base/net_log.cc
new file mode 100644
index 0000000..1b1661e
--- /dev/null
+++ b/net/base/net_log.cc
@@ -0,0 +1,154 @@
+// 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/base/net_log.h"
+#include "base/logging.h"
+
+namespace net {
+
+// static
+const char* NetLog::EventTypeToString(EventType event) {
+ switch (event) {
+#define EVENT_TYPE(label) case TYPE_ ## label: return #label;
+#include "net/base/net_log_event_type_list.h"
+#undef EVENT_TYPE
+ }
+ return NULL;
+}
+
+void BoundNetLog::AddEntry(const NetLog::Entry& entry) const {
+ if (net_log_)
+ net_log_->AddEntry(entry);
+}
+
+bool BoundNetLog::HasListener() const {
+ if (net_log_)
+ return net_log_->HasListener();
+ return false;
+}
+
+void BoundNetLog::AddEvent(NetLog::EventType event_type) const {
+ if (net_log_) {
+ NetLog::Entry entry;
+ entry.source = source_;
+ entry.type = NetLog::Entry::TYPE_EVENT;
+ entry.time = base::TimeTicks::Now();
+ entry.event = NetLog::Event(event_type, NetLog::PHASE_NONE);
+ AddEntry(entry);
+ }
+}
+
+void BoundNetLog::BeginEvent(NetLog::EventType event_type) const {
+ if (net_log_) {
+ NetLog::Entry entry;
+ entry.source = source_;
+ entry.type = NetLog::Entry::TYPE_EVENT;
+ entry.time = base::TimeTicks::Now();
+ entry.event = NetLog::Event(event_type, NetLog::PHASE_BEGIN);
+ AddEntry(entry);
+ }
+}
+
+void BoundNetLog::BeginEventWithString(NetLog::EventType event_type,
+ const std::string& string) const {
+ NetLog::Entry entry;
+ entry.source = source_;
+ entry.type = NetLog::Entry::TYPE_EVENT;
+ entry.time = base::TimeTicks::Now();
+ entry.event = NetLog::Event(event_type, NetLog::PHASE_BEGIN);
+ entry.string = string;
+ AddEntry(entry);
+}
+
+void BoundNetLog::AddEventWithInteger(NetLog::EventType event_type,
+ int integer) const {
+ NetLog::Entry entry;
+ entry.source = source_;
+ entry.type = NetLog::Entry::TYPE_EVENT;
+ entry.time = base::TimeTicks::Now();
+ entry.event = NetLog::Event(event_type, NetLog::PHASE_NONE);
+ entry.error_code = integer;
+ AddEntry(entry);
+}
+
+void BoundNetLog::EndEvent(NetLog::EventType event_type) const {
+ if (net_log_) {
+ NetLog::Entry entry;
+ entry.source = source_;
+ entry.type = NetLog::Entry::TYPE_EVENT;
+ entry.time = base::TimeTicks::Now();
+ entry.event = NetLog::Event(event_type, NetLog::PHASE_END);
+ AddEntry(entry);
+ }
+}
+
+void BoundNetLog::AddStringLiteral(const char* literal) const {
+ if (net_log_) {
+ NetLog::Entry entry;
+ entry.source = source_;
+ entry.type = NetLog::Entry::TYPE_STRING_LITERAL;
+ entry.time = base::TimeTicks::Now();
+ entry.literal = literal;
+ AddEntry(entry);
+ }
+}
+
+void BoundNetLog::AddString(const std::string& string) const {
+ if (net_log_) {
+ NetLog::Entry entry;
+ entry.source = source_;
+ entry.type = NetLog::Entry::TYPE_STRING;
+ entry.time = base::TimeTicks::Now();
+ entry.string = string;
+ AddEntry(entry);
+ }
+}
+
+void BoundNetLog::AddErrorCode(int error) const {
+ if (net_log_) {
+ NetLog::Entry entry;
+ entry.source = source_;
+ entry.type = NetLog::Entry::TYPE_ERROR_CODE;
+ entry.time = base::TimeTicks::Now();
+ entry.error_code = error;
+ AddEntry(entry);
+ }
+}
+
+// static
+BoundNetLog BoundNetLog::Make(NetLog* net_log,
+ NetLog::SourceType source_type) {
+ if (!net_log)
+ return BoundNetLog();
+
+ NetLog::Source source(source_type, net_log->NextID());
+ return BoundNetLog(source, net_log);
+}
+
+void CapturingNetLog::AddEntry(const Entry& entry) {
+ if (entries_.size() + 1 < max_num_entries_)
+ entries_.push_back(entry);
+}
+
+int CapturingNetLog::NextID() {
+ return next_id_++;
+}
+
+void CapturingNetLog::Clear() {
+ entries_.clear();
+}
+
+void CapturingBoundNetLog::Clear() {
+ capturing_net_log_->Clear();
+}
+
+void CapturingBoundNetLog::AppendTo(const BoundNetLog& net_log) const {
+ for (size_t i = 0; i < entries().size(); ++i) {
+ NetLog::Entry entry = entries()[i];
+ entry.source = net_log.source();
+ net_log.AddEntry(entry);
+ }
+}
+
+} // namespace net
diff --git a/net/base/net_log.h b/net/base/net_log.h
new file mode 100644
index 0000000..79c6585
--- /dev/null
+++ b/net/base/net_log.h
@@ -0,0 +1,238 @@
+// 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.
+
+#ifndef NET_BASE_NET_LOG_H_
+#define NET_BASE_NET_LOG_H_
+
+#include <string>
+#include <vector>
+
+#include "base/scoped_ptr.h"
+#include "base/time.h"
+#include "net/base/net_log.h"
+
+namespace net {
+
+// NetLog is the destination for log messages generated by the network stack.
+// Each log message has a "source" field which identifies the specific entity
+// that generated the message (for example, which URLRequest or which
+// SocketStream).
+//
+// To avoid needing to pass in the "source id" to the logging functions, NetLog
+// is usually accessed through a BoundNetLog, which will always pass in a
+// specific source ID.
+//
+// Note that NetLog is NOT THREADSAFE.
+class NetLog {
+ public:
+ // TODO(eroman): Really, EventType and EventPhase should be
+ // Event::Type and Event::Phase, to be consisent with Entry.
+ // But there lots of consumers to change!
+ enum EventType {
+#define EVENT_TYPE(label) TYPE_ ## label,
+#include "net/base/net_log_event_type_list.h"
+#undef EVENT_TYPE
+ };
+
+ // The 'phase' of an event trace (whether it marks the beginning or end
+ // of an event.).
+ enum EventPhase {
+ PHASE_NONE,
+ PHASE_BEGIN,
+ PHASE_END,
+ };
+
+ struct Event {
+ Event(EventType type, EventPhase phase) : type(type), phase(phase) {}
+ Event() {}
+
+ EventType type;
+ EventPhase phase;
+ };
+
+ // The "source" identifies the entity that generated the log message.
+ enum SourceType {
+ SOURCE_NONE,
+ SOURCE_URL_REQUEST,
+ SOURCE_SOCKET_STREAM,
+ SOURCE_INIT_PROXY_RESOLVER,
+ SOURCE_CONNECT_JOB,
+ };
+
+ // Identifies the entity that generated this log. The |id| field should
+ // uniquely identify the source, and is used by log observers to infer
+ // message groupings. Can use NetLog::NextID() to create unique IDs.
+ struct Source {
+ Source() : type(SOURCE_NONE), id(-1) {}
+ Source(SourceType type, int id) : type(type), id(id) {}
+
+ SourceType type;
+ int id;
+ };
+
+ // TODO(eroman): generalize the entries so events can specify multiple
+ // parameters, and TYPE_STRING is rarely needed.
+ struct Entry {
+ enum Type {
+ // This entry describes an event trace.
+ TYPE_EVENT,
+
+ // This entry describes a network error code that was returned.
+ TYPE_ERROR_CODE,
+
+ // This entry is a free-form std::string.
+ TYPE_STRING,
+
+ // This entry is a C-string literal.
+ TYPE_STRING_LITERAL,
+ };
+
+ Source source;
+
+ Type type;
+ base::TimeTicks time;
+
+ // The following is basically a union, only one of them should be
+ // used depending on what |type| is.
+ Event event; // valid when (type == TYPE_EVENT).
+ int error_code; // valid when (type == TYPE_ERROR_CODE).
+ std::string string; // valid when (type == TYPE_STRING).
+ const char* literal; // valid when (type == TYPE_STRING_LITERAL).
+ };
+
+ NetLog() {}
+ virtual ~NetLog() {}
+
+ // Adds a message to the log.
+ virtual void AddEntry(const Entry& entry) = 0;
+
+ // Returns a unique ID which can be used as a source ID.
+ virtual int NextID() = 0;
+
+ // Returns true if more complicated messages should be sent to the log.
+ // TODO(eroman): This is a carry-over from refactoring; figure out
+ // something better.
+ virtual bool HasListener() const = 0;
+
+ // Returns a C-String symbolic name for |event_type|.
+ static const char* EventTypeToString(EventType event_type);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(NetLog);
+};
+
+// Helper that binds a Source to a NetLog, and exposes convenience methods to
+// output log messages without needing to pass in the source.
+class BoundNetLog {
+ public:
+ BoundNetLog() : net_log_(NULL) {}
+
+ // TODO(eroman): This is a complete hack to allow passing in NULL in
+ // place of a BoundNetLog. I added this while refactoring to simplify the
+ // task of updating all the callers.
+ BoundNetLog(int) : net_log_(NULL) {}
+
+ BoundNetLog(const NetLog::Source& source, NetLog* net_log)
+ : source_(source), net_log_(net_log) {
+ }
+
+ void AddEntry(const NetLog::Entry& entry) const;
+
+ // Convenience methods that call through to the NetLog, passing in the
+ // currently bound source.
+ void AddEvent(NetLog::EventType event_type) const;
+ bool HasListener() const;
+ void BeginEvent(NetLog::EventType event_type) const;
+ void BeginEventWithString(NetLog::EventType event_type,
+ const std::string& string) const;
+ void AddEventWithInteger(NetLog::EventType event_type, int integer) const;
+ void EndEvent(NetLog::EventType event_type) const;
+ void AddStringLiteral(const char* literal) const;
+ void AddString(const std::string& string) const;
+ void AddErrorCode(int error) const;
+
+ // Helper to create a BoundNetLog given a NetLog and a SourceType. Takes care
+ // of creating a unique source ID, and handles the case of NULL net_log.
+ static BoundNetLog Make(NetLog* net_log, NetLog::SourceType source_type);
+
+ const NetLog::Source& source() const { return source_; }
+ NetLog* net_log() const { return net_log_; }
+
+ private:
+ NetLog::Source source_;
+ NetLog* net_log_;
+};
+
+// CapturingNetLog is an implementation of NetLog that saves messages to a
+// bounded buffer.
+class CapturingNetLog : public NetLog {
+ public:
+ // Ordered set of entries that were logged.
+ typedef std::vector<Entry> EntryList;
+
+ enum { kUnbounded = -1 };
+
+ // Creates a CapturingNetLog that logs a maximum of |max_num_entries|
+ // messages.
+ explicit CapturingNetLog(size_t max_num_entries)
+ : next_id_(0), max_num_entries_(max_num_entries) {}
+
+ // NetLog implementation:
+ virtual void AddEntry(const Entry& entry);
+ virtual int NextID();
+ virtual bool HasListener() const { return true; }
+
+ // Returns the list of all entries in the log.
+ const EntryList& entries() const { return entries_; }
+
+ void Clear();
+
+ private:
+ int next_id_;
+ size_t max_num_entries_;
+ EntryList entries_;
+
+ DISALLOW_COPY_AND_ASSIGN(CapturingNetLog);
+};
+
+// Helper class that exposes a similar API as BoundNetLog, but uses a
+// CapturingNetLog rather than the more generic NetLog.
+//
+// CapturingBoundNetLog can easily be converted to a BoundNetLog using the
+// bound() method.
+class CapturingBoundNetLog {
+ public:
+ CapturingBoundNetLog(const NetLog::Source& source, CapturingNetLog* net_log)
+ : source_(source), capturing_net_log_(net_log) {
+ }
+
+ explicit CapturingBoundNetLog(size_t max_num_entries)
+ : capturing_net_log_(new CapturingNetLog(max_num_entries)) {}
+
+ // The returned BoundNetLog is only valid while |this| is alive.
+ BoundNetLog bound() const {
+ return BoundNetLog(source_, capturing_net_log_.get());
+ }
+
+ // Returns the list of all entries in the log.
+ const CapturingNetLog::EntryList& entries() const {
+ return capturing_net_log_->entries();
+ }
+
+ void Clear();
+
+ // Sends all of captured messages to |net_log|, using the same source ID
+ // as |net_log|.
+ void AppendTo(const BoundNetLog& net_log) const;
+
+ private:
+ NetLog::Source source_;
+ scoped_ptr<CapturingNetLog> capturing_net_log_;
+
+ DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog);
+};
+
+} // namespace net
+
+#endif // NET_BASE_NET_LOG_H_
diff --git a/net/base/load_log_event_type_list.h b/net/base/net_log_event_type_list.h
index be43760..cee9466 100644
--- a/net/base/load_log_event_type_list.h
+++ b/net/base/net_log_event_type_list.h
@@ -3,7 +3,7 @@
// found in the LICENSE file.
// NOTE: No header guards are used, since this file is intended to be expanded
-// directly into load_log.h. DO NOT include this file anywhere else.
+// directly into net_log.h. DO NOT include this file anywhere else.
// --------------------------------------------------------------------------
// General pseudo-events
@@ -13,6 +13,11 @@
// log context around it.)
EVENT_TYPE(CANCELLED)
+// Marks the creation/destruction of a request (URLRequest or SocketStream).
+// In the begin phase of this event, the message will contain a string which
+// is the URL.
+EVENT_TYPE(REQUEST_ALIVE)
+
// ------------------------------------------------------------------------
// HostResolverImpl
// ------------------------------------------------------------------------
@@ -124,6 +129,10 @@ EVENT_TYPE(SOCKET_BACKUP_CREATED)
// A backup socket is created due to slow connect
EVENT_TYPE(SOCKET_BACKUP_TIMER_EXTENDED)
+// Identifies the NetLog::Source() for the ConnectJob that this socket ended
+// up binding to.
+EVENT_TYPE(SOCKET_POOL_CONNECT_JOB_ID)
+
// ------------------------------------------------------------------------
// URLRequest
// ------------------------------------------------------------------------
diff --git a/net/base/load_log_unittest.h b/net/base/net_log_unittest.h
index b1922ef..39a1f36 100644
--- a/net/base/load_log_unittest.h
+++ b/net/base/net_log_unittest.h
@@ -2,11 +2,12 @@
// 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_UNITTEST_H_
-#define NET_BASE_LOAD_LOG_UNITTEST_H_
+#ifndef NET_BASE_NET_LOG_UNITTEST_H_
+#define NET_BASE_NET_LOG_UNITTEST_H_
#include <cstddef>
-#include "net/base/load_log.h"
+#include <vector>
+#include "net/base/net_log.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
@@ -19,23 +20,23 @@ inline base::TimeTicks MakeTime(int t) {
}
inline ::testing::AssertionResult LogContainsEventHelper(
- const LoadLog& log,
+ const CapturingNetLog::EntryList& entries,
int i, // Negative indices are reverse indices.
const base::TimeTicks& expected_time,
bool check_time,
- LoadLog::EventType expected_event,
- LoadLog::EventPhase expected_phase) {
+ NetLog::EventType expected_event,
+ NetLog::EventPhase expected_phase) {
// Negative indices are reverse indices.
- size_t j = (i < 0) ? log.entries().size() + i : i;
- if (j >= log.entries().size())
+ size_t j = (i < 0) ? entries.size() + i : i;
+ if (j >= entries.size())
return ::testing::AssertionFailure() << j << " is out of bounds.";
- const LoadLog::Entry& entry = log.entries()[j];
- if (entry.type != LoadLog::Entry::TYPE_EVENT)
+ const NetLog::Entry& entry = entries[j];
+ if (entry.type != NetLog::Entry::TYPE_EVENT)
return ::testing::AssertionFailure() << "Not a TYPE_EVENT entry";
if (expected_event != entry.event.type) {
return ::testing::AssertionFailure()
- << "Actual event: " << LoadLog::EventTypeToString(entry.event.type)
- << ". Expected event: " << LoadLog::EventTypeToString(expected_event)
+ << "Actual event: " << NetLog::EventTypeToString(entry.event.type)
+ << ". Expected event: " << NetLog::EventTypeToString(expected_event)
<< ".";
}
if (expected_phase != entry.event.phase) {
@@ -55,50 +56,50 @@ inline ::testing::AssertionResult LogContainsEventHelper(
}
inline ::testing::AssertionResult LogContainsEventAtTime(
- const LoadLog& log,
+ const CapturingNetLog::EntryList& log,
int i, // Negative indices are reverse indices.
const base::TimeTicks& expected_time,
- LoadLog::EventType expected_event,
- LoadLog::EventPhase expected_phase) {
+ NetLog::EventType expected_event,
+ NetLog::EventPhase expected_phase) {
return LogContainsEventHelper(log, i, expected_time, true,
expected_event, expected_phase);
}
// Version without timestamp.
inline ::testing::AssertionResult LogContainsEvent(
- const LoadLog& log,
+ const CapturingNetLog::EntryList& log,
int i, // Negative indices are reverse indices.
- LoadLog::EventType expected_event,
- LoadLog::EventPhase expected_phase) {
+ NetLog::EventType expected_event,
+ NetLog::EventPhase expected_phase) {
return LogContainsEventHelper(log, i, base::TimeTicks(), false,
expected_event, expected_phase);
}
// Version for PHASE_BEGIN (and no timestamp).
inline ::testing::AssertionResult LogContainsBeginEvent(
- const LoadLog& log,
+ const CapturingNetLog::EntryList& log,
int i, // Negative indices are reverse indices.
- LoadLog::EventType expected_event) {
- return LogContainsEvent(log, i, expected_event, LoadLog::PHASE_BEGIN);
+ NetLog::EventType expected_event) {
+ return LogContainsEvent(log, i, expected_event, NetLog::PHASE_BEGIN);
}
// Version for PHASE_END (and no timestamp).
inline ::testing::AssertionResult LogContainsEndEvent(
- const LoadLog& log,
+ const CapturingNetLog::EntryList& log,
int i, // Negative indices are reverse indices.
- LoadLog::EventType expected_event) {
- return LogContainsEvent(log, i, expected_event, LoadLog::PHASE_END);
+ NetLog::EventType expected_event) {
+ return LogContainsEvent(log, i, expected_event, NetLog::PHASE_END);
}
inline ::testing::AssertionResult LogContainsEntryWithType(
- const LoadLog& log,
+ const CapturingNetLog::EntryList& entries,
int i, // Negative indices are reverse indices.
- LoadLog::Entry::Type type) {
+ NetLog::Entry::Type type) {
// Negative indices are reverse indices.
- size_t j = (i < 0) ? log.entries().size() + i : i;
- if (j >= log.entries().size())
+ size_t j = (i < 0) ? entries.size() + i : i;
+ if (j >= entries.size())
return ::testing::AssertionFailure() << j << " is out of bounds.";
- const LoadLog::Entry& entry = log.entries()[j];
+ const NetLog::Entry& entry = entries[j];
if (entry.type != type)
return ::testing::AssertionFailure() << "Type does not match.";
return ::testing::AssertionSuccess();
@@ -108,23 +109,24 @@ inline ::testing::AssertionResult LogContainsEntryWithType(
// Expect that the log contains an event, but don't care about where
// as long as the index where it is found is greater than min_index.
// Returns the position where the event was found.
-inline size_t ExpectLogContainsSomewhere(const LoadLog* log,
- size_t min_index,
- LoadLog::EventType expected_event,
- LoadLog::EventPhase expected_phase) {
+inline size_t ExpectLogContainsSomewhere(
+ const CapturingNetLog::EntryList& entries,
+ size_t min_index,
+ NetLog::EventType expected_event,
+ NetLog::EventPhase expected_phase) {
size_t i = 0;
- for (; i < log->entries().size(); ++i) {
- const LoadLog::Entry& entry = log->entries()[i];
- if (entry.type == LoadLog::Entry::TYPE_EVENT &&
+ for (; i < entries.size(); ++i) {
+ const NetLog::Entry& entry = entries[i];
+ if (entry.type == NetLog::Entry::TYPE_EVENT &&
entry.event.type == expected_event &&
entry.event.phase == expected_phase)
break;
}
- EXPECT_LT(i, log->entries().size());
+ EXPECT_LT(i, entries.size());
EXPECT_GE(i, min_index);
return i;
}
} // namespace net
-#endif // NET_BASE_LOAD_LOG_UNITTEST_H_
+#endif // NET_BASE_NET_LOG_UNITTEST_H_
diff --git a/net/base/load_log_util.cc b/net/base/net_log_util.cc
index cad20a5..420fb2d 100644
--- a/net/base/load_log_util.cc
+++ b/net/base/net_log_util.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "net/base/load_log_util.h"
+#include "net/base/net_log_util.h"
#include "base/format_macros.h"
#include "base/string_util.h"
@@ -13,12 +13,13 @@ namespace {
class FormatHelper {
public:
- std::string ToString(const LoadLog* log) {
+ std::string ToString(const std::vector<NetLog::Entry>& entries,
+ size_t num_entries_truncated) {
entries_.clear();
// Pass 1: Match the start/end of indentation blocks. Fills |entries_|
// with the results.
- PopulateEntries(log);
+ PopulateEntries(entries);
// Pass 2: Figure out the maximum width of each column. This allows us
// to right-justify text within each column.
@@ -32,9 +33,9 @@ class FormatHelper {
const int kSpacesPerIndentation = 2;
for (size_t i = 0; i < entries_.size(); ++i) {
- if (log->num_entries_truncated() > 0 && i + 1 == entries_.size()) {
+ if (num_entries_truncated > 0 && i + 1 == entries_.size()) {
StringAppendF(&result, " ... Truncated %" PRIuS " entries ...\n",
- log->num_entries_truncated());
+ num_entries_truncated);
}
if (entries_[i].block_index != -1 &&
@@ -71,29 +72,29 @@ class FormatHelper {
private:
struct Entry {
- explicit Entry(const LoadLog::Entry* log_entry)
+ explicit Entry(const NetLog::Entry* log_entry)
: log_entry(log_entry), indentation(0), block_index(-1) {}
bool IsBeginEvent() const {
- return log_entry->type == LoadLog::Entry::TYPE_EVENT &&
- log_entry->event.phase == LoadLog::PHASE_BEGIN;
+ return log_entry->type == NetLog::Entry::TYPE_EVENT &&
+ log_entry->event.phase == NetLog::PHASE_BEGIN;
}
bool IsEndEvent() const {
- return log_entry->type == LoadLog::Entry::TYPE_EVENT &&
- log_entry->event.phase == LoadLog::PHASE_END;
+ return log_entry->type == NetLog::Entry::TYPE_EVENT &&
+ log_entry->event.phase == NetLog::PHASE_END;
}
- const LoadLog::Entry* log_entry;
+ const NetLog::Entry* log_entry;
size_t indentation;
int block_index; // The index of the matching start / end of block.
};
- void PopulateEntries(const LoadLog* log) {
+ void PopulateEntries(const std::vector<NetLog::Entry>& entries) {
int current_indentation = 0;
- for (size_t i = 0; i < log->entries().size(); ++i) {
- Entry entry(&log->entries()[i]);
+ for (size_t i = 0; i < entries.size(); ++i) {
+ Entry entry(&entries[i]);
entry.indentation = current_indentation;
@@ -140,7 +141,7 @@ class FormatHelper {
*max_time_width = *max_indentation = *max_type_width = *max_dt_width = 0;
for (size_t i = 0; i < entries_.size(); ++i) {
*max_time_width = std::max(*max_time_width, GetTimeString(i).size());
- if (entries_[i].log_entry->type == LoadLog::Entry::TYPE_EVENT)
+ if (entries_[i].log_entry->type == NetLog::Entry::TYPE_EVENT)
*max_type_width = std::max(*max_type_width, GetEntryString(i).size());
*max_indentation = std::max(*max_indentation, entries_[i].indentation);
@@ -168,32 +169,32 @@ class FormatHelper {
}
std::string GetEntryString(size_t index) {
- const LoadLog::Entry* entry = entries_[index].log_entry;
+ const NetLog::Entry* entry = entries_[index].log_entry;
std::string entry_str;
- LoadLog::EventPhase phase = LoadLog::PHASE_NONE;
+ NetLog::EventPhase phase = NetLog::PHASE_NONE;
switch (entry->type) {
- case LoadLog::Entry::TYPE_EVENT:
- entry_str = LoadLog::EventTypeToString(entry->event.type);
+ case NetLog::Entry::TYPE_EVENT:
+ entry_str = NetLog::EventTypeToString(entry->event.type);
phase = entry->event.phase;
- if (phase == LoadLog::PHASE_BEGIN &&
+ if (phase == NetLog::PHASE_BEGIN &&
index + 1 < entries_.size() &&
static_cast<size_t>(entries_[index + 1].block_index) == index) {
// If this starts an empty block, we will pretend it is a PHASE_NONE
// so we don't print the "+" prefix.
- phase = LoadLog::PHASE_NONE;
+ phase = NetLog::PHASE_NONE;
}
break;
- case LoadLog::Entry::TYPE_ERROR_CODE:
+ case NetLog::Entry::TYPE_ERROR_CODE:
entry_str = StringPrintf("error code: %d (%s)",
entry->error_code,
ErrorToString(entry->error_code));
break;
- case LoadLog::Entry::TYPE_STRING:
+ case NetLog::Entry::TYPE_STRING:
entry_str = StringPrintf("\"%s\"", entry->string.c_str());
break;
- case LoadLog::Entry::TYPE_STRING_LITERAL:
+ case NetLog::Entry::TYPE_STRING_LITERAL:
entry_str = StringPrintf("\"%s\"", entry->literal);
break;
default:
@@ -201,11 +202,11 @@ class FormatHelper {
}
switch (phase) {
- case LoadLog::PHASE_BEGIN:
+ case NetLog::PHASE_BEGIN:
return std::string("+") + entry_str;
- case LoadLog::PHASE_END:
+ case NetLog::PHASE_END:
return std::string("-") + entry_str;
- case LoadLog::PHASE_NONE:
+ case NetLog::PHASE_NONE:
return std::string(" ") + entry_str;
default:
NOTREACHED();
@@ -226,9 +227,11 @@ class FormatHelper {
} // namespace
// static
-std::string LoadLogUtil::PrettyPrintAsEventTree(const LoadLog* log) {
+std::string NetLogUtil::PrettyPrintAsEventTree(
+ const std::vector<NetLog::Entry>& entries,
+ size_t num_entries_truncated) {
FormatHelper helper;
- return helper.ToString(log);
+ return helper.ToString(entries, num_entries_truncated);
}
} // namespace net
diff --git a/net/base/load_log_util.h b/net/base/net_log_util.h
index 363e219..716a941 100644
--- a/net/base/load_log_util.h
+++ b/net/base/net_log_util.h
@@ -2,24 +2,24 @@
// 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_UTIL_H_
-#define NET_BASE_LOAD_LOG_UTIL_H_
+#ifndef NET_BASE_NET_LOG_UTIL_H_
+#define NET_BASE_NET_LOG_UTIL_H_
#include <string>
#include <vector>
#include "base/basictypes.h"
-#include "net/base/load_log.h"
+#include "net/base/net_log.h"
namespace net {
-// The LoadLogUtil utility class contains methods to analyze and visualize
-// LoadLogs.
+// The NetLogUtil utility class contains methods to analyze and visualize
+// NetLog entries.
-class LoadLogUtil {
+class NetLogUtil {
public:
struct EventDuration {
- LoadLog::EventType event;
+ NetLog::EventType event;
base::TimeDelta duration;
};
typedef std::vector<EventDuration> EventDurationList;
@@ -63,12 +63,13 @@ class LoadLogUtil {
// - Log entries added by AddEvent() have no prefix.
// - Time units are given as milliseconds.
//
- static std::string PrettyPrintAsEventTree(const LoadLog* log);
+ static std::string PrettyPrintAsEventTree(
+ const std::vector<NetLog::Entry>& entries, size_t num_entries_truncated);
private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(LoadLogUtil);
+ DISALLOW_IMPLICIT_CONSTRUCTORS(NetLogUtil);
};
} // namespace net
-#endif // NET_BASE_LOAD_LOG_UTIL_H_
+#endif // NET_BASE_NET_LOG_UTIL_H_
diff --git a/net/base/net_log_util_unittest.cc b/net/base/net_log_util_unittest.cc
new file mode 100644
index 0000000..713773d
--- /dev/null
+++ b/net/base/net_log_util_unittest.cc
@@ -0,0 +1,145 @@
+// 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.
+
+#include "net/base/net_log_unittest.h"
+#include "net/base/net_log_util.h"
+#include "net/base/net_errors.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+namespace {
+
+NetLog::Entry MakeEventEntry(int t,
+ NetLog::EventType event_type,
+ NetLog::EventPhase event_phase) {
+ NetLog::Entry entry;
+ entry.type = NetLog::Entry::TYPE_EVENT;
+ entry.time = MakeTime(t);
+ entry.event = NetLog::Event(event_type, event_phase);
+ return entry;
+}
+
+NetLog::Entry MakeStringEntry(int t, const std::string& string) {
+ NetLog::Entry entry;
+ entry.type = NetLog::Entry::TYPE_STRING;
+ entry.time = MakeTime(t);
+ entry.string = string;
+ return entry;
+}
+
+NetLog::Entry MakeErrorCodeEntry(int t, int error_code) {
+ NetLog::Entry entry;
+ entry.type = NetLog::Entry::TYPE_ERROR_CODE;
+ entry.time = MakeTime(t);
+ entry.error_code = error_code;
+ return entry;
+}
+
+TEST(NetLogUtilTest, Basic) {
+ std::vector<NetLog::Entry> log;
+
+ log.push_back(MakeEventEntry(1, NetLog::TYPE_HOST_RESOLVER_IMPL,
+ NetLog::PHASE_BEGIN));
+ log.push_back(
+ MakeEventEntry(5, NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART,
+ NetLog::PHASE_BEGIN));
+ log.push_back(
+ MakeEventEntry(8, NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART,
+ NetLog::PHASE_END));
+
+ log.push_back(MakeEventEntry(12, NetLog::TYPE_CANCELLED,
+ NetLog::PHASE_NONE));
+
+ log.push_back(MakeEventEntry(131, NetLog::TYPE_HOST_RESOLVER_IMPL,
+ NetLog::PHASE_END));
+
+ EXPECT_EQ(
+ "t= 1: +HOST_RESOLVER_IMPL [dt=130]\n"
+ "t= 5: HOST_RESOLVER_IMPL_OBSERVER_ONSTART [dt= 3]\n"
+ "t= 12: CANCELLED\n"
+ "t=131: -HOST_RESOLVER_IMPL",
+ NetLogUtil::PrettyPrintAsEventTree(log, 0));
+}
+
+TEST(NetLogUtilTest, Basic2) {
+ std::vector<NetLog::Entry> log;
+
+ log.push_back(MakeEventEntry(1, NetLog::TYPE_HOST_RESOLVER_IMPL,
+ NetLog::PHASE_BEGIN));
+
+ log.push_back(MakeStringEntry(12, "Sup foo"));
+ log.push_back(MakeErrorCodeEntry(12, ERR_UNEXPECTED));
+ log.push_back(MakeStringEntry(14, "Multiline\nString"));
+
+ log.push_back(MakeEventEntry(131, NetLog::TYPE_HOST_RESOLVER_IMPL,
+ NetLog::PHASE_END));
+
+ EXPECT_EQ(
+ "t= 1: +HOST_RESOLVER_IMPL [dt=130]\n"
+ "t= 12: \"Sup foo\"\n"
+ "t= 12: error code: -9 (net::ERR_UNEXPECTED)\n"
+ "t= 14: \"Multiline\n"
+ "String\"\n"
+ "t=131: -HOST_RESOLVER_IMPL",
+ NetLogUtil::PrettyPrintAsEventTree(log, 0));
+}
+
+TEST(NetLogUtilTest, UnmatchedOpen) {
+ std::vector<NetLog::Entry> log;
+
+ log.push_back(MakeEventEntry(3, NetLog::TYPE_HOST_RESOLVER_IMPL,
+ NetLog::PHASE_BEGIN));
+ // Note that there is no matching call to PHASE_END for all of the following.
+ log.push_back(
+ MakeEventEntry(
+ 6, NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART,
+ NetLog::PHASE_BEGIN));
+ log.push_back(
+ MakeEventEntry(7, NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART,
+ NetLog::PHASE_BEGIN));
+ log.push_back(
+ MakeEventEntry(8, NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART,
+ NetLog::PHASE_BEGIN));
+ log.push_back(MakeEventEntry(10, NetLog::TYPE_CANCELLED,
+ NetLog::PHASE_NONE));
+ log.push_back(MakeEventEntry(16, NetLog::TYPE_HOST_RESOLVER_IMPL,
+ NetLog::PHASE_END));
+
+ EXPECT_EQ(
+ "t= 3: +HOST_RESOLVER_IMPL [dt=13]\n"
+ "t= 6: +HOST_RESOLVER_IMPL_OBSERVER_ONSTART [dt=10]\n"
+ "t= 7: +HOST_RESOLVER_IMPL_OBSERVER_ONSTART [dt= 9]\n"
+ "t= 8: +HOST_RESOLVER_IMPL_OBSERVER_ONSTART [dt= 8]\n"
+ "t=10: CANCELLED\n"
+ "t=16: -HOST_RESOLVER_IMPL",
+ NetLogUtil::PrettyPrintAsEventTree(log, 0));
+}
+
+TEST(NetLogUtilTest, DisplayOfTruncated) {
+ std::vector<NetLog::Entry> log;
+
+ log.push_back(MakeEventEntry(0,
+ NetLog::TYPE_TCP_CONNECT,
+ NetLog::PHASE_BEGIN));
+ for (size_t i = 1; i <= 3; ++i) {
+ log.push_back(MakeEventEntry(i,
+ NetLog::TYPE_CANCELLED,
+ NetLog::PHASE_NONE));
+ }
+ log.push_back(MakeEventEntry(9,
+ NetLog::TYPE_TCP_CONNECT,
+ NetLog::PHASE_END));
+
+ EXPECT_EQ(
+ "t=0: +TCP_CONNECT [dt=9]\n"
+ "t=1: CANCELLED\n"
+ "t=2: CANCELLED\n"
+ "t=3: CANCELLED\n"
+ " ... Truncated 4 entries ...\n"
+ "t=9: -TCP_CONNECT",
+ NetLogUtil::PrettyPrintAsEventTree(log, 4));
+}
+
+} // namespace
+} // namespace net
diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc
index 64bd320..b244009 100644
--- a/net/ftp/ftp_network_transaction.cc
+++ b/net/ftp/ftp_network_transaction.cc
@@ -10,8 +10,8 @@
#include "base/utf_string_conversions.h"
#include "net/base/connection_type_histograms.h"
#include "net/base/escape.h"
-#include "net/base/load_log.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log.h"
#include "net/base/net_util.h"
#include "net/ftp/ftp_network_session.h"
#include "net/ftp/ftp_request_info.h"
@@ -73,8 +73,8 @@ FtpNetworkTransaction::~FtpNetworkTransaction() {
int FtpNetworkTransaction::Start(const FtpRequestInfo* request_info,
CompletionCallback* callback,
- LoadLog* load_log) {
- load_log_ = load_log;
+ const BoundNetLog& net_log) {
+ net_log_ = net_log;
request_ = request_info;
if (request_->url.has_username()) {
@@ -508,7 +508,7 @@ int FtpNetworkTransaction::DoCtrlResolveHost() {
// RFC 2428, we have to turn off IPv6 in FTP. See http://crbug.com/32945.
info.set_address_family(ADDRESS_FAMILY_IPV4);
// No known referrer.
- return resolver_.Resolve(info, &addresses_, &io_callback_, load_log_);
+ return resolver_.Resolve(info, &addresses_, &io_callback_, net_log_);
}
int FtpNetworkTransaction::DoCtrlResolveHostComplete(int result) {
@@ -520,7 +520,7 @@ int FtpNetworkTransaction::DoCtrlResolveHostComplete(int result) {
int FtpNetworkTransaction::DoCtrlConnect() {
next_state_ = STATE_CTRL_CONNECT_COMPLETE;
ctrl_socket_.reset(socket_factory_->CreateTCPClientSocket(addresses_));
- return ctrl_socket_->Connect(&io_callback_, load_log_);
+ return ctrl_socket_->Connect(&io_callback_, net_log_);
}
int FtpNetworkTransaction::DoCtrlConnectComplete(int result) {
@@ -1119,7 +1119,7 @@ int FtpNetworkTransaction::DoDataConnect() {
return Stop(rv);
data_address.SetPort(data_connection_port_);
data_socket_.reset(socket_factory_->CreateTCPClientSocket(data_address));
- return data_socket_->Connect(&io_callback_, load_log_);
+ return data_socket_->Connect(&io_callback_, net_log_);
}
int FtpNetworkTransaction::DoDataConnectComplete(int result) {
diff --git a/net/ftp/ftp_network_transaction.h b/net/ftp/ftp_network_transaction.h
index e1dcef6..4fbd204 100644
--- a/net/ftp/ftp_network_transaction.h
+++ b/net/ftp/ftp_network_transaction.h
@@ -14,6 +14,7 @@
#include "base/scoped_ptr.h"
#include "net/base/address_list.h"
#include "net/base/host_resolver.h"
+#include "net/base/net_log.h"
#include "net/ftp/ftp_ctrl_response_buffer.h"
#include "net/ftp/ftp_response_info.h"
#include "net/ftp/ftp_transaction.h"
@@ -33,7 +34,7 @@ class FtpNetworkTransaction : public FtpTransaction {
// FtpTransaction methods:
virtual int Start(const FtpRequestInfo* request_info,
CompletionCallback* callback,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
virtual int Stop(int error);
virtual int RestartWithAuth(const std::wstring& username,
const std::wstring& password,
@@ -175,7 +176,7 @@ class FtpNetworkTransaction : public FtpTransaction {
scoped_refptr<FtpNetworkSession> session_;
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
const FtpRequestInfo* request_;
FtpResponseInfo response_;
diff --git a/net/ftp/ftp_transaction.h b/net/ftp/ftp_transaction.h
index da7f73e..881a977 100644
--- a/net/ftp/ftp_transaction.h
+++ b/net/ftp/ftp_transaction.h
@@ -13,7 +13,7 @@ namespace net {
class FtpResponseInfo;
class FtpRequestInfo;
-class LoadLog;
+class BoundNetLog;
// Represents a single FTP transaction.
class FtpTransaction {
@@ -35,10 +35,10 @@ class FtpTransaction {
//
// NOTE: The transaction is not responsible for deleting the callback object.
//
- // Profiling information for the request is saved to |load_log| if non-NULL.
+ // Profiling information for the request is saved to |net_log| if non-NULL.
virtual int Start(const FtpRequestInfo* request_info,
CompletionCallback* callback,
- LoadLog* load_log) = 0;
+ const BoundNetLog& net_log) = 0;
// Restarts the FTP transaction with authentication credentials.
virtual int RestartWithAuth(const std::wstring& username,
diff --git a/net/http/http_basic_stream.cc b/net/http/http_basic_stream.cc
index f587ab4..807e4ebf 100644
--- a/net/http/http_basic_stream.cc
+++ b/net/http/http_basic_stream.cc
@@ -6,9 +6,10 @@
namespace net {
-HttpBasicStream::HttpBasicStream(ClientSocketHandle* handle, LoadLog* load_log)
+HttpBasicStream::HttpBasicStream(ClientSocketHandle* handle,
+ const BoundNetLog& net_log)
: read_buf_(new GrowableIOBuffer()),
- parser_(new HttpStreamParser(handle, read_buf_, load_log)) {
+ parser_(new HttpStreamParser(handle, read_buf_, net_log)) {
}
int HttpBasicStream::SendRequest(const HttpRequestInfo* request,
diff --git a/net/http/http_basic_stream.h b/net/http/http_basic_stream.h
index 0a12baf..cd533db 100644
--- a/net/http/http_basic_stream.h
+++ b/net/http/http_basic_stream.h
@@ -18,15 +18,15 @@
namespace net {
+class BoundNetLog;
class ClientSocketHandle;
class HttpRequestInfo;
class HttpResponseInfo;
-class LoadLog;
class UploadDataStream;
class HttpBasicStream : public HttpStream {
public:
- HttpBasicStream(ClientSocketHandle* handle, LoadLog* load_log);
+ HttpBasicStream(ClientSocketHandle* handle, const BoundNetLog& net_log);
virtual ~HttpBasicStream() {}
// HttpStream methods:
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc
index 2192342..3ca78be 100644
--- a/net/http/http_cache_transaction.cc
+++ b/net/http/http_cache_transaction.cc
@@ -16,8 +16,8 @@
#include "base/time.h"
#include "net/base/io_buffer.h"
#include "net/base/load_flags.h"
-#include "net/base/load_log.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log.h"
#include "net/base/ssl_cert_request_info.h"
#include "net/disk_cache/disk_cache.h"
#include "net/http/http_request_info.h"
@@ -165,7 +165,7 @@ HttpCache::Transaction::~Transaction() {
int HttpCache::Transaction::Start(const HttpRequestInfo* request,
CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
DCHECK(request);
DCHECK(callback);
@@ -178,7 +178,7 @@ int HttpCache::Transaction::Start(const HttpRequestInfo* request,
if (!cache_)
return ERR_UNEXPECTED;
- SetRequest(load_log, request);
+ SetRequest(net_log, request);
int rv;
@@ -580,7 +580,7 @@ int HttpCache::Transaction::DoSendRequest() {
return rv;
next_state_ = STATE_SEND_REQUEST_COMPLETE;
- rv = network_trans_->Start(request_, &io_callback_, load_log_);
+ rv = network_trans_->Start(request_, &io_callback_, net_log_);
return rv;
}
@@ -686,7 +686,7 @@ int HttpCache::Transaction::DoOpenEntry() {
DCHECK(!new_entry_);
next_state_ = STATE_OPEN_ENTRY_COMPLETE;
cache_pending_ = true;
- LoadLog::BeginEvent(load_log_, LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY);
return cache_->OpenEntry(cache_key_, &new_entry_, this);
}
@@ -694,7 +694,7 @@ int HttpCache::Transaction::DoOpenEntryComplete(int result) {
// It is important that we go to STATE_ADD_TO_ENTRY whenever the result is
// OK, otherwise the cache will end up with an active entry without any
// transaction attached.
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY);
+ net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY);
cache_pending_ = false;
if (result == OK) {
next_state_ = STATE_ADD_TO_ENTRY;
@@ -729,7 +729,7 @@ int HttpCache::Transaction::DoCreateEntry() {
DCHECK(!new_entry_);
next_state_ = STATE_CREATE_ENTRY_COMPLETE;
cache_pending_ = true;
- LoadLog::BeginEvent(load_log_, LoadLog::TYPE_HTTP_CACHE_CREATE_ENTRY);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY);
return cache_->CreateEntry(cache_key_, &new_entry_, this);
}
@@ -737,7 +737,7 @@ int HttpCache::Transaction::DoCreateEntryComplete(int result) {
// It is important that we go to STATE_ADD_TO_ENTRY whenever the result is
// OK, otherwise the cache will end up with an active entry without any
// transaction attached.
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_HTTP_CACHE_CREATE_ENTRY);
+ net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY);
cache_pending_ = false;
next_state_ = STATE_ADD_TO_ENTRY;
@@ -763,12 +763,12 @@ int HttpCache::Transaction::DoCreateEntryComplete(int result) {
int HttpCache::Transaction::DoDoomEntry() {
next_state_ = STATE_DOOM_ENTRY_COMPLETE;
cache_pending_ = true;
- LoadLog::BeginEvent(load_log_, LoadLog::TYPE_HTTP_CACHE_DOOM_ENTRY);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY);
return cache_->DoomEntry(cache_key_, this);
}
int HttpCache::Transaction::DoDoomEntryComplete(int result) {
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_HTTP_CACHE_DOOM_ENTRY);
+ net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY);
next_state_ = STATE_CREATE_ENTRY;
cache_pending_ = false;
if (result == ERR_CACHE_RACE)
@@ -781,12 +781,12 @@ int HttpCache::Transaction::DoAddToEntry() {
DCHECK(new_entry_);
cache_pending_ = true;
next_state_ = STATE_ADD_TO_ENTRY_COMPLETE;
- LoadLog::BeginEvent(load_log_, LoadLog::TYPE_HTTP_CACHE_WAITING);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WAITING);
return cache_->AddTransactionToEntry(new_entry_, this);
}
int HttpCache::Transaction::DoAddToEntryComplete(int result) {
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_HTTP_CACHE_WAITING);
+ net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_WAITING);
DCHECK(new_entry_);
cache_pending_ = false;
@@ -966,7 +966,7 @@ int HttpCache::Transaction::DoCacheReadResponse() {
io_buf_len_ = entry_->disk_entry->GetDataSize(kResponseInfoIndex);
read_buf_ = new IOBuffer(io_buf_len_);
- LoadLog::BeginEvent(load_log_, LoadLog::TYPE_HTTP_CACHE_READ_INFO);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO);
cache_callback_->AddRef(); // Balanced in DoCacheReadResponseComplete.
return entry_->disk_entry->ReadData(kResponseInfoIndex, 0, read_buf_,
io_buf_len_, cache_callback_);
@@ -974,7 +974,7 @@ int HttpCache::Transaction::DoCacheReadResponse() {
int HttpCache::Transaction::DoCacheReadResponseComplete(int result) {
cache_callback_->Release(); // Balance the AddRef from DoCacheReadResponse.
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_HTTP_CACHE_READ_INFO);
+ net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO);
if (result != io_buf_len_ ||
!HttpCache::ParseResponseInfo(read_buf_->data(), io_buf_len_,
&response_, &truncated_)) {
@@ -1044,7 +1044,7 @@ int HttpCache::Transaction::DoCacheReadMetadata() {
response_.metadata =
new IOBufferWithSize(entry_->disk_entry->GetDataSize(kMetadataIndex));
- LoadLog::BeginEvent(load_log_, LoadLog::TYPE_HTTP_CACHE_READ_INFO);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO);
cache_callback_->AddRef(); // Balanced in DoCacheReadMetadataComplete.
return entry_->disk_entry->ReadData(kMetadataIndex, 0, response_.metadata,
response_.metadata->size(),
@@ -1053,7 +1053,7 @@ int HttpCache::Transaction::DoCacheReadMetadata() {
int HttpCache::Transaction::DoCacheReadMetadataComplete(int result) {
cache_callback_->Release(); // Balance the AddRef from DoCacheReadMetadata.
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_HTTP_CACHE_READ_INFO);
+ net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO);
if (result != response_.metadata->size()) {
DLOG(ERROR) << "ReadData failed: " << result;
return ERR_CACHE_READ_FAILURE;
@@ -1142,9 +1142,9 @@ int HttpCache::Transaction::DoCacheWriteDataComplete(int result) {
//-----------------------------------------------------------------------------
-void HttpCache::Transaction::SetRequest(LoadLog* load_log,
+void HttpCache::Transaction::SetRequest(const BoundNetLog& net_log,
const HttpRequestInfo* request) {
- load_log_ = load_log;
+ net_log_ = net_log;
request_ = request;
effective_load_flags_ = request_->load_flags;
diff --git a/net/http/http_cache_transaction.h b/net/http/http_cache_transaction.h
index 936c2e3..9ad50e9 100644
--- a/net/http/http_cache_transaction.h
+++ b/net/http/http_cache_transaction.h
@@ -8,6 +8,7 @@
#ifndef NET_HTTP_HTTP_CACHE_TRANSACTION_H_
#define NET_HTTP_HTTP_CACHE_TRANSACTION_H_
+#include "net/base/net_log.h"
#include "net/http/http_cache.h"
#include "net/http/http_response_info.h"
#include "net/http/http_transaction.h"
@@ -25,7 +26,8 @@ class HttpCache::Transaction : public HttpTransaction {
virtual ~Transaction();
// HttpTransaction methods:
- virtual int Start(const HttpRequestInfo*, CompletionCallback*, LoadLog*);
+ virtual int Start(const HttpRequestInfo*, CompletionCallback*,
+ const BoundNetLog&);
virtual int RestartIgnoringLastError(CompletionCallback* callback);
virtual int RestartWithCertificate(X509Certificate* client_cert,
CompletionCallback* callback);
@@ -194,7 +196,7 @@ class HttpCache::Transaction : public HttpTransaction {
int DoCacheWriteDataComplete(int result);
// Sets request_ and fields derived from it.
- void SetRequest(LoadLog* load_log, const HttpRequestInfo* request);
+ void SetRequest(const BoundNetLog& net_log, const HttpRequestInfo* request);
// Returns true if the request should be handled exclusively by the network
// layer (skipping the cache entirely).
@@ -299,7 +301,7 @@ class HttpCache::Transaction : public HttpTransaction {
State next_state_;
const HttpRequestInfo* request_;
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
scoped_ptr<HttpRequestInfo> custom_request_;
// If extra_headers specified a "if-modified-since" or "if-none-match",
// |external_validation_| contains the value of those headers.
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index 5ad2e40..3132abe 100644
--- a/net/http/http_cache_unittest.cc
+++ b/net/http/http_cache_unittest.cc
@@ -11,7 +11,7 @@
#include "net/base/cache_type.h"
#include "net/base/net_errors.h"
#include "net/base/load_flags.h"
-#include "net/base/load_log_unittest.h"
+#include "net/base/net_log_unittest.h"
#include "net/base/ssl_cert_request_info.h"
#include "net/disk_cache/disk_cache.h"
#include "net/http/http_byte_range.h"
@@ -585,7 +585,7 @@ void RunTransactionTestWithRequestAndLog(net::HttpCache* cache,
const MockTransaction& trans_info,
const MockHttpRequest& request,
net::HttpResponseInfo* response_info,
- net::LoadLog* load_log) {
+ const net::BoundNetLog& net_log) {
TestCompletionCallback callback;
// write to the cache
@@ -595,7 +595,7 @@ void RunTransactionTestWithRequestAndLog(net::HttpCache* cache,
EXPECT_EQ(net::OK, rv);
ASSERT_TRUE(trans.get());
- rv = trans->Start(&request, &callback, load_log);
+ rv = trans->Start(&request, &callback, net_log);
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
ASSERT_EQ(net::OK, rv);
@@ -619,7 +619,7 @@ void RunTransactionTestWithRequest(net::HttpCache* cache,
void RunTransactionTestWithLog(net::HttpCache* cache,
const MockTransaction& trans_info,
- net::LoadLog* log) {
+ const net::BoundNetLog& log) {
RunTransactionTestWithRequestAndLog(
cache, trans_info, MockHttpRequest(trans_info), NULL, log);
}
@@ -913,22 +913,23 @@ TEST(HttpCache, SimpleGETNoDiskCache) {
cache.disk_cache()->set_fail_requests();
- scoped_refptr<net::LoadLog> log(new net::LoadLog(net::LoadLog::kUnbounded));
+ net::CapturingBoundNetLog log(net::CapturingNetLog::kUnbounded);
// Read from the network, and don't use the cache.
- RunTransactionTestWithLog(cache.http_cache(), kSimpleGET_Transaction, log);
+ RunTransactionTestWithLog(cache.http_cache(), kSimpleGET_Transaction,
+ log.bound());
- // Check that the LoadLog was filled as expected.
+ // Check that the NetLog was filled as expected.
// (We attempted to both Open and Create entries, but both failed).
- EXPECT_EQ(4u, log->entries().size());
+ EXPECT_EQ(4u, log.entries().size());
EXPECT_TRUE(net::LogContainsBeginEvent(
- *log, 0, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY));
+ log.entries(), 0, net::NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY));
EXPECT_TRUE(net::LogContainsEndEvent(
- *log, 1, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY));
+ log.entries(), 1, net::NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY));
EXPECT_TRUE(net::LogContainsBeginEvent(
- *log, 2, net::LoadLog::TYPE_HTTP_CACHE_CREATE_ENTRY));
+ log.entries(), 2, net::NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY));
EXPECT_TRUE(net::LogContainsEndEvent(
- *log, 3, net::LoadLog::TYPE_HTTP_CACHE_CREATE_ENTRY));
+ log.entries(), 3, net::NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY));
EXPECT_EQ(1, cache.network_layer()->transaction_count());
EXPECT_EQ(0, cache.disk_cache()->open_count());
@@ -997,48 +998,49 @@ TEST(HttpCache, SimpleGETWithDiskFailures2) {
TEST(HttpCache, SimpleGET_LoadOnlyFromCache_Hit) {
MockHttpCache cache;
- scoped_refptr<net::LoadLog> log(new net::LoadLog(net::LoadLog::kUnbounded));
+ net::CapturingBoundNetLog log(net::CapturingNetLog::kUnbounded);
// write to the cache
- RunTransactionTestWithLog(cache.http_cache(), kSimpleGET_Transaction, log);
+ RunTransactionTestWithLog(cache.http_cache(), kSimpleGET_Transaction,
+ log.bound());
- // Check that the LoadLog was filled as expected.
- EXPECT_EQ(6u, log->entries().size());
+ // Check that the NetLog was filled as expected.
+ EXPECT_EQ(6u, log.entries().size());
EXPECT_TRUE(net::LogContainsBeginEvent(
- *log, 0, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY));
+ log.entries(), 0, net::NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY));
EXPECT_TRUE(net::LogContainsEndEvent(
- *log, 1, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY));
+ log.entries(), 1, net::NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY));
EXPECT_TRUE(net::LogContainsBeginEvent(
- *log, 2, net::LoadLog::TYPE_HTTP_CACHE_CREATE_ENTRY));
+ log.entries(), 2, net::NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY));
EXPECT_TRUE(net::LogContainsEndEvent(
- *log, 3, net::LoadLog::TYPE_HTTP_CACHE_CREATE_ENTRY));
+ log.entries(), 3, net::NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY));
EXPECT_TRUE(net::LogContainsBeginEvent(
- *log, 4, net::LoadLog::TYPE_HTTP_CACHE_WAITING));
+ log.entries(), 4, net::NetLog::TYPE_HTTP_CACHE_WAITING));
EXPECT_TRUE(net::LogContainsEndEvent(
- *log, 5, net::LoadLog::TYPE_HTTP_CACHE_WAITING));
+ log.entries(), 5, net::NetLog::TYPE_HTTP_CACHE_WAITING));
// force this transaction to read from the cache
MockTransaction transaction(kSimpleGET_Transaction);
transaction.load_flags |= net::LOAD_ONLY_FROM_CACHE;
- log = new net::LoadLog(net::LoadLog::kUnbounded);
+ log.Clear();
- RunTransactionTestWithLog(cache.http_cache(), transaction, log);
+ RunTransactionTestWithLog(cache.http_cache(), transaction, log.bound());
- // Check that the LoadLog was filled as expected.
- EXPECT_EQ(6u, log->entries().size());
+ // Check that the NetLog was filled as expected.
+ EXPECT_EQ(6u, log.entries().size());
EXPECT_TRUE(net::LogContainsBeginEvent(
- *log, 0, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY));
+ log.entries(), 0, net::NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY));
EXPECT_TRUE(net::LogContainsEndEvent(
- *log, 1, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY));
+ log.entries(), 1, net::NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY));
EXPECT_TRUE(net::LogContainsBeginEvent(
- *log, 2, net::LoadLog::TYPE_HTTP_CACHE_WAITING));
+ log.entries(), 2, net::NetLog::TYPE_HTTP_CACHE_WAITING));
EXPECT_TRUE(net::LogContainsEndEvent(
- *log, 3, net::LoadLog::TYPE_HTTP_CACHE_WAITING));
+ log.entries(), 3, net::NetLog::TYPE_HTTP_CACHE_WAITING));
EXPECT_TRUE(net::LogContainsBeginEvent(
- *log, 4, net::LoadLog::TYPE_HTTP_CACHE_READ_INFO));
+ log.entries(), 4, net::NetLog::TYPE_HTTP_CACHE_READ_INFO));
EXPECT_TRUE(net::LogContainsEndEvent(
- *log, 5, net::LoadLog::TYPE_HTTP_CACHE_READ_INFO));
+ log.entries(), 5, net::NetLog::TYPE_HTTP_CACHE_READ_INFO));
EXPECT_EQ(1, cache.network_layer()->transaction_count());
EXPECT_EQ(1, cache.disk_cache()->open_count());
@@ -1113,24 +1115,24 @@ TEST(HttpCache, SimpleGET_LoadBypassCache) {
MockTransaction transaction(kSimpleGET_Transaction);
transaction.load_flags |= net::LOAD_BYPASS_CACHE;
- scoped_refptr<net::LoadLog> log(new net::LoadLog(net::LoadLog::kUnbounded));
+ net::CapturingBoundNetLog log(net::CapturingNetLog::kUnbounded);
- RunTransactionTestWithLog(cache.http_cache(), transaction, log);
+ RunTransactionTestWithLog(cache.http_cache(), transaction, log.bound());
- // Check that the LoadLog was filled as expected.
- EXPECT_EQ(6u, log->entries().size());
+ // Check that the NetLog was filled as expected.
+ EXPECT_EQ(6u, log.entries().size());
EXPECT_TRUE(net::LogContainsBeginEvent(
- *log, 0, net::LoadLog::TYPE_HTTP_CACHE_DOOM_ENTRY));
+ log.entries(), 0, net::NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY));
EXPECT_TRUE(net::LogContainsEndEvent(
- *log, 1, net::LoadLog::TYPE_HTTP_CACHE_DOOM_ENTRY));
+ log.entries(), 1, net::NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY));
EXPECT_TRUE(net::LogContainsBeginEvent(
- *log, 2, net::LoadLog::TYPE_HTTP_CACHE_CREATE_ENTRY));
+ log.entries(), 2, net::NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY));
EXPECT_TRUE(net::LogContainsEndEvent(
- *log, 3, net::LoadLog::TYPE_HTTP_CACHE_CREATE_ENTRY));
+ log.entries(), 3, net::NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY));
EXPECT_TRUE(net::LogContainsBeginEvent(
- *log, 4, net::LoadLog::TYPE_HTTP_CACHE_WAITING));
+ log.entries(), 4, net::NetLog::TYPE_HTTP_CACHE_WAITING));
EXPECT_TRUE(net::LogContainsEndEvent(
- *log, 5, net::LoadLog::TYPE_HTTP_CACHE_WAITING));
+ log.entries(), 5, net::NetLog::TYPE_HTTP_CACHE_WAITING));
EXPECT_EQ(2, cache.network_layer()->transaction_count());
EXPECT_EQ(0, cache.disk_cache()->open_count());
diff --git a/net/http/http_network_layer_unittest.cc b/net/http/http_network_layer_unittest.cc
index b1b0c8a..e8aa494 100644
--- a/net/http/http_network_layer_unittest.cc
+++ b/net/http/http_network_layer_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "net/base/mock_host_resolver.h"
+#include "net/base/net_log.h"
#include "net/base/ssl_config_service_defaults.h"
#include "net/http/http_network_layer.h"
#include "net/http/http_transaction_unittest.h"
@@ -84,7 +85,7 @@ TEST_F(HttpNetworkLayerTest, GET) {
request_info.user_agent = "Foo/1.0";
request_info.load_flags = net::LOAD_NORMAL;
- rv = trans->Start(&request_info, &callback, NULL);
+ rv = trans->Start(&request_info, &callback, net::BoundNetLog());
if (rv == net::ERR_IO_PENDING)
rv = callback.WaitForResult();
ASSERT_EQ(net::OK, rv);
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 10f32431..8c81725 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -240,10 +240,10 @@ void HttpNetworkTransaction::IgnoreCertificateErrors(bool enabled) {
int HttpNetworkTransaction::Start(const HttpRequestInfo* request_info,
CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
SIMPLE_STATS_COUNTER("HttpNetworkTransaction.Count");
- load_log_ = load_log;
+ net_log_ = net_log;
request_ = request_info;
start_time_ = base::Time::Now();
@@ -542,97 +542,83 @@ int HttpNetworkTransaction::DoLoop(int result) {
case STATE_SEND_REQUEST:
DCHECK_EQ(OK, rv);
TRACE_EVENT_BEGIN("http.send_request", request_, request_->url.spec());
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST);
rv = DoSendRequest();
break;
case STATE_SEND_REQUEST_COMPLETE:
rv = DoSendRequestComplete(rv);
TRACE_EVENT_END("http.send_request", request_, request_->url.spec());
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST);
+ net_log_.EndEvent(NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST);
break;
case STATE_READ_HEADERS:
DCHECK_EQ(OK, rv);
TRACE_EVENT_BEGIN("http.read_headers", request_, request_->url.spec());
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_HTTP_TRANSACTION_READ_HEADERS);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS);
rv = DoReadHeaders();
break;
case STATE_READ_HEADERS_COMPLETE:
rv = DoReadHeadersComplete(rv);
TRACE_EVENT_END("http.read_headers", request_, request_->url.spec());
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_HTTP_TRANSACTION_READ_HEADERS);
+ net_log_.EndEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS);
break;
case STATE_READ_BODY:
DCHECK_EQ(OK, rv);
TRACE_EVENT_BEGIN("http.read_body", request_, request_->url.spec());
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_HTTP_TRANSACTION_READ_BODY);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_BODY);
rv = DoReadBody();
break;
case STATE_READ_BODY_COMPLETE:
rv = DoReadBodyComplete(rv);
TRACE_EVENT_END("http.read_body", request_, request_->url.spec());
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_HTTP_TRANSACTION_READ_BODY);
+ net_log_.EndEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_BODY);
break;
case STATE_DRAIN_BODY_FOR_AUTH_RESTART:
DCHECK_EQ(OK, rv);
TRACE_EVENT_BEGIN("http.drain_body_for_auth_restart",
request_, request_->url.spec());
- LoadLog::BeginEvent(
- load_log_,
- LoadLog::TYPE_HTTP_TRANSACTION_DRAIN_BODY_FOR_AUTH_RESTART);
+ net_log_.BeginEvent(
+ NetLog::TYPE_HTTP_TRANSACTION_DRAIN_BODY_FOR_AUTH_RESTART);
rv = DoDrainBodyForAuthRestart();
break;
case STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE:
rv = DoDrainBodyForAuthRestartComplete(rv);
TRACE_EVENT_END("http.drain_body_for_auth_restart",
request_, request_->url.spec());
- LoadLog::EndEvent(
- load_log_,
- LoadLog::TYPE_HTTP_TRANSACTION_DRAIN_BODY_FOR_AUTH_RESTART);
+ net_log_.EndEvent(
+ NetLog::TYPE_HTTP_TRANSACTION_DRAIN_BODY_FOR_AUTH_RESTART);
break;
case STATE_SPDY_SEND_REQUEST:
DCHECK_EQ(OK, rv);
TRACE_EVENT_BEGIN("http.send_request", request_, request_->url.spec());
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST);
+ net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST);
rv = DoSpdySendRequest();
break;
case STATE_SPDY_SEND_REQUEST_COMPLETE:
rv = DoSpdySendRequestComplete(rv);
TRACE_EVENT_END("http.send_request", request_, request_->url.spec());
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST);
+ net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST);
break;
case STATE_SPDY_READ_HEADERS:
DCHECK_EQ(OK, rv);
TRACE_EVENT_BEGIN("http.read_headers", request_, request_->url.spec());
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_SPDY_TRANSACTION_READ_HEADERS);
+ net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_READ_HEADERS);
rv = DoSpdyReadHeaders();
break;
case STATE_SPDY_READ_HEADERS_COMPLETE:
rv = DoSpdyReadHeadersComplete(rv);
TRACE_EVENT_END("http.read_headers", request_, request_->url.spec());
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_SPDY_TRANSACTION_READ_HEADERS);
+ net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_READ_HEADERS);
break;
case STATE_SPDY_READ_BODY:
DCHECK_EQ(OK, rv);
TRACE_EVENT_BEGIN("http.read_body", request_, request_->url.spec());
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_SPDY_TRANSACTION_READ_BODY);
+ net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_READ_BODY);
rv = DoSpdyReadBody();
break;
case STATE_SPDY_READ_BODY_COMPLETE:
rv = DoSpdyReadBodyComplete(rv);
TRACE_EVENT_END("http.read_body", request_, request_->url.spec());
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_SPDY_TRANSACTION_READ_BODY);
+ net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_READ_BODY);
break;
default:
NOTREACHED() << "bad state";
@@ -655,7 +641,7 @@ int HttpNetworkTransaction::DoResolveProxy() {
}
return session_->proxy_service()->ResolveProxy(
- request_->url, &proxy_info_, &io_callback_, &pac_request_, load_log_);
+ request_->url, &proxy_info_, &io_callback_, &pac_request_, net_log_);
}
int HttpNetworkTransaction::DoResolveProxyComplete(int result) {
@@ -761,7 +747,7 @@ int HttpNetworkTransaction::DoInitConnection() {
int rv = connection_->Init(connection_group, tcp_params, request_->priority,
&io_callback_, session_->tcp_socket_pool(),
- load_log_);
+ net_log_);
return rv;
}
@@ -827,7 +813,7 @@ int HttpNetworkTransaction::DoSOCKSConnect() {
else
s = new SOCKSClientSocket(s, req_info, session_->host_resolver());
connection_->set_socket(s);
- return connection_->socket()->Connect(&io_callback_, load_log_);
+ return connection_->socket()->Connect(&io_callback_, net_log_);
}
int HttpNetworkTransaction::DoSOCKSConnectComplete(int result) {
@@ -858,7 +844,7 @@ int HttpNetworkTransaction::DoSSLConnect() {
s = session_->socket_factory()->CreateSSLClientSocket(
s, request_->url.HostNoBrackets(), ssl_config_);
connection_->set_socket(s);
- return connection_->socket()->Connect(&io_callback_, load_log_);
+ return connection_->socket()->Connect(&io_callback_, net_log_);
}
int HttpNetworkTransaction::DoSSLConnectComplete(int result) {
@@ -969,7 +955,7 @@ int HttpNetworkTransaction::DoSendRequest() {
}
headers_valid_ = false;
- http_stream_.reset(new HttpBasicStream(connection_.get(), load_log_));
+ http_stream_.reset(new HttpBasicStream(connection_.get(), net_log_));
return http_stream_->SendRequest(request_, request_headers_,
request_body, &response_, &io_callback_);
@@ -1069,7 +1055,7 @@ int HttpNetworkTransaction::DoReadHeadersComplete(int result) {
next_state_ = STATE_SSL_CONNECT;
// Reset for the real request and response headers.
request_headers_.clear();
- http_stream_.reset(new HttpBasicStream(connection_.get(), load_log_));
+ http_stream_.reset(new HttpBasicStream(connection_.get(), net_log_));
headers_valid_ = false;
establishing_tunnel_ = false;
return OK;
@@ -1235,7 +1221,7 @@ int HttpNetworkTransaction::DoSpdySendRequest() {
new UploadDataStream(request_->upload_data) : NULL;
headers_valid_ = false;
spdy_stream_ = spdy_session->GetOrCreateStream(
- *request_, upload_data, load_log_);
+ *request_, upload_data, net_log_);
return spdy_stream_->SendRequest(upload_data, &response_, &io_callback_);
}
@@ -1621,7 +1607,7 @@ int HttpNetworkTransaction::ReconsiderProxyAfterError(int error) {
}
int rv = session_->proxy_service()->ReconsiderProxyAfterError(
- request_->url, &proxy_info_, &io_callback_, &pac_request_, load_log_);
+ request_->url, &proxy_info_, &io_callback_, &pac_request_, net_log_);
if (rv == OK || rv == ERR_IO_PENDING) {
// If the error was during connection setup, there is no socket to
// disconnect.
diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h
index bf5327a..5e51e90 100644
--- a/net/http/http_network_transaction.h
+++ b/net/http/http_network_transaction.h
@@ -16,6 +16,7 @@
#include "net/base/io_buffer.h"
#include "net/base/load_flags.h"
#include "net/base/load_states.h"
+#include "net/base/net_log.h"
#include "net/base/ssl_config_service.h"
#include "net/http/http_alternate_protocols.h"
#include "net/http/http_auth.h"
@@ -50,7 +51,7 @@ class HttpNetworkTransaction : public HttpTransaction {
// HttpTransaction methods:
virtual int Start(const HttpRequestInfo* request_info,
CompletionCallback* callback,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
virtual int RestartIgnoringLastError(CompletionCallback* callback);
virtual int RestartWithCertificate(X509Certificate* client_cert,
CompletionCallback* callback);
@@ -295,7 +296,7 @@ class HttpNetworkTransaction : public HttpTransaction {
scoped_refptr<HttpNetworkSession> session_;
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
const HttpRequestInfo* request_;
HttpResponseInfo response_;
@@ -329,7 +330,7 @@ class HttpNetworkTransaction : public HttpTransaction {
bool using_spdy_;
AlternateProtocolMode alternate_protocol_mode_;
-
+
// Only valid if |alternate_protocol_mode_| == kUsingAlternateProtocol.
HttpAlternateProtocols::Protocol alternate_protocol_;
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index aa0bca8..caf03fd 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -194,7 +194,7 @@ class CaptureGroupNameSocketPool : public TCPClientSocketPool {
RequestPriority priority,
ClientSocketHandle* handle,
CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
last_group_name_ = group_name;
return ERR_IO_PENDING;
}
@@ -4280,7 +4280,7 @@ TEST_F(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) {
int rv = trans->Start(&request, &callback, NULL);
EXPECT_EQ(ERR_IO_PENDING, rv);
-
+
HostPortPair http_host_port_pair;
http_host_port_pair.host = "www.google.com";
http_host_port_pair.port = 80;
@@ -4380,12 +4380,12 @@ TEST_F(HttpNetworkTransactionTest, MarkBrokenAlternateProtocol) {
// on the original port.
// TEST_F(HttpNetworkTransactionTest, UseAlternateProtocol) {
// SessionDependencies session_deps;
-//
+//
// HttpRequestInfo request;
// request.method = "GET";
// request.url = GURL("http://www.google.com/");
// request.load_flags = 0;
-//
+//
// MockRead data_reads[] = {
// MockRead("HTTP/1.1 200 OK\r\n\r\n"),
// MockRead("hello world"),
@@ -4393,14 +4393,14 @@ TEST_F(HttpNetworkTransactionTest, MarkBrokenAlternateProtocol) {
// };
// StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
// session_deps.socket_factory.AddSocketDataProvider(&data);
-//
+//
// SSLSocketDataProvider ssl(true, OK);
// session_deps.socket_factory.AddSSLSocketDataProvider(&ssl);
-//
+//
// TestCompletionCallback callback;
-//
+//
// scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
-//
+//
// HostPortPair http_host_port_pair;
// http_host_port_pair.host = "www.google.com";
// http_host_port_pair.port = 80;
@@ -4409,18 +4409,18 @@ TEST_F(HttpNetworkTransactionTest, MarkBrokenAlternateProtocol) {
// alternate_protocols->SetAlternateProtocolFor(
// http_host_port_pair, 1234 /* port is ignored */,
// HttpAlternateProtocols::NPN_SPDY);
-//
+//
// scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
-//
+//
// int rv = trans->Start(&request, &callback, NULL);
// EXPECT_EQ(ERR_IO_PENDING, rv);
// EXPECT_EQ(OK, callback.WaitForResult());
-//
+//
// const HttpResponseInfo* response = trans->GetResponseInfo();
// ASSERT_TRUE(response != NULL);
// ASSERT_TRUE(response->headers != NULL);
// EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
-//
+//
// std::string response_data;
// ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
// EXPECT_EQ("hello world", response_data);
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
index 446c8ed..53c57f1 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -15,7 +15,7 @@ namespace net {
HttpStreamParser::HttpStreamParser(ClientSocketHandle* connection,
GrowableIOBuffer* read_buffer,
- LoadLog* load_log)
+ const BoundNetLog& net_log)
: io_state_(STATE_NONE),
request_(NULL),
request_headers_(NULL),
@@ -30,7 +30,7 @@ HttpStreamParser::HttpStreamParser(ClientSocketHandle* connection,
user_read_buf_len_(0),
user_callback_(NULL),
connection_(connection),
- load_log_(load_log),
+ net_log_(net_log),
ALLOW_THIS_IN_INITIALIZER_LIST(
io_callback_(this, &HttpStreamParser::OnIOComplete)) {
DCHECK_EQ(0, read_buffer->offset());
@@ -148,14 +148,12 @@ int HttpStreamParser::DoLoop(int result) {
break;
case STATE_READ_HEADERS:
TRACE_EVENT_BEGIN("http.read_headers", request_, request_->url.spec());
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_HTTP_STREAM_PARSER_READ_HEADERS);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_PARSER_READ_HEADERS);
result = DoReadHeaders();
break;
case STATE_READ_HEADERS_COMPLETE:
result = DoReadHeadersComplete(result);
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_HTTP_STREAM_PARSER_READ_HEADERS);
+ net_log_.EndEvent(NetLog::TYPE_HTTP_STREAM_PARSER_READ_HEADERS);
TRACE_EVENT_END("http.read_headers", request_, request_->url.spec());
break;
case STATE_BODY_PENDING:
diff --git a/net/http/http_stream_parser.h b/net/http/http_stream_parser.h
index c47d09e..e42b9b5 100644
--- a/net/http/http_stream_parser.h
+++ b/net/http/http_stream_parser.h
@@ -9,7 +9,7 @@
#include "base/basictypes.h"
#include "net/base/io_buffer.h"
-#include "net/base/load_log.h"
+#include "net/base/net_log.h"
#include "net/base/upload_data_stream.h"
#include "net/http/http_chunked_decoder.h"
#include "net/http/http_response_info.h"
@@ -29,7 +29,7 @@ class HttpStreamParser {
// have its capacity changed.
HttpStreamParser(ClientSocketHandle* connection,
GrowableIOBuffer* read_buffer,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
~HttpStreamParser() {}
// These functions implement the interface described in HttpStream with
@@ -162,7 +162,7 @@ class HttpStreamParser {
// The underlying socket.
ClientSocketHandle* const connection_;
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
// Callback to be used when doing IO.
CompletionCallbackImpl<HttpStreamParser> io_callback_;
diff --git a/net/http/http_transaction.h b/net/http/http_transaction.h
index 8a0d25f..a18d422 100644
--- a/net/http/http_transaction.h
+++ b/net/http/http_transaction.h
@@ -12,10 +12,10 @@
namespace net {
+class BoundNetLog;
class HttpRequestInfo;
class HttpResponseInfo;
class IOBuffer;
-class LoadLog;
class X509Certificate;
// Represents a single HTTP transaction (i.e., a single request/response pair).
@@ -39,10 +39,10 @@ class HttpTransaction {
//
// NOTE: The transaction is not responsible for deleting the callback object.
//
- // Profiling information for the request is saved to |load_log| if non-NULL.
+ // Profiling information for the request is saved to |net_log| if non-NULL.
virtual int Start(const HttpRequestInfo* request_info,
CompletionCallback* callback,
- LoadLog* load_log) = 0;
+ const BoundNetLog& net_log) = 0;
// Restarts the HTTP transaction, ignoring the last error. This call can
// only be made after a call to Start (or RestartIgnoringLastError) failed.
diff --git a/net/http/http_transaction_unittest.h b/net/http/http_transaction_unittest.h
index 3499da4..e578db2 100644
--- a/net/http/http_transaction_unittest.h
+++ b/net/http/http_transaction_unittest.h
@@ -119,9 +119,10 @@ class TestTransactionConsumer : public CallbackRunner< Tuple1<int> > {
~TestTransactionConsumer() {
}
- void Start(const net::HttpRequestInfo* request, net::LoadLog* load_log) {
+ void Start(const net::HttpRequestInfo* request,
+ const net::BoundNetLog& net_log) {
state_ = STARTING;
- int result = trans_->Start(request, this, load_log);
+ int result = trans_->Start(request, this, net_log);
if (result != net::ERR_IO_PENDING)
DidStart(result);
}
@@ -212,7 +213,7 @@ class MockNetworkTransaction : public net::HttpTransaction {
virtual int Start(const net::HttpRequestInfo* request,
net::CompletionCallback* callback,
- net::LoadLog* load_log) {
+ const net::BoundNetLog& net_log) {
const MockTransaction* t = FindMockTransaction(request->url);
if (!t)
return net::ERR_FAILED;
diff --git a/net/net.gyp b/net/net.gyp
index ddb42d5..c85a614 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -83,11 +83,6 @@
'base/listen_socket.cc',
'base/listen_socket.h',
'base/load_flags.h',
- 'base/load_log.h',
- 'base/load_log.cc',
- 'base/load_log_event_type_list.h',
- 'base/load_log_util.cc',
- 'base/load_log_util.h',
'base/load_states.h',
'base/mapped_host_resolver.cc',
'base/mapped_host_resolver.h',
@@ -101,6 +96,11 @@
'base/net_error_list.h',
'base/net_errors.cc',
'base/net_errors.h',
+ 'base/net_log.cc',
+ 'base/net_log.h',
+ 'base/net_log_event_type_list.h',
+ 'base/net_log_util.cc',
+ 'base/net_log_util.h',
'base/net_module.cc',
'base/net_module.h',
'base/net_util.cc',
@@ -470,7 +470,6 @@
'spdy/spdy_stream.cc',
'spdy/spdy_stream.h',
'spdy/spdy_transaction_factory.h',
- 'url_request/request_tracker.h',
'url_request/url_request.cc',
'url_request/url_request.h',
'url_request/url_request_about_job.cc',
@@ -607,15 +606,14 @@
'base/host_cache_unittest.cc',
'base/host_resolver_impl_unittest.cc',
'base/keygen_handler_unittest.cc',
- 'base/load_log_unittest.cc',
- 'base/load_log_unittest.h',
- 'base/load_log_util_unittest.cc',
'base/listen_socket_unittest.cc',
'base/listen_socket_unittest.h',
'base/mapped_host_resolver_unittest.cc',
'base/mime_sniffer_unittest.cc',
'base/mime_util_unittest.cc',
'base/mock_network_change_notifier.h',
+ 'base/net_log_unittest.h',
+ 'base/net_log_util_unittest.cc',
'base/net_test_constants.h',
'base/net_util_unittest.cc',
'base/registry_controlled_domain_unittest.cc',
@@ -696,7 +694,6 @@
'spdy/spdy_protocol_test.cc',
'spdy/spdy_session_unittest.cc',
'spdy/spdy_stream_unittest.cc',
- 'url_request/request_tracker_unittest.cc',
'url_request/url_request_unittest.cc',
'url_request/url_request_unittest.h',
'websockets/websocket_job_unittest.cc',
diff --git a/net/proxy/init_proxy_resolver.cc b/net/proxy/init_proxy_resolver.cc
index dd6d28e..0ca39d4 100644
--- a/net/proxy/init_proxy_resolver.cc
+++ b/net/proxy/init_proxy_resolver.cc
@@ -8,7 +8,7 @@
#include "base/format_macros.h"
#include "base/logging.h"
#include "base/string_util.h"
-#include "net/base/load_log.h"
+#include "net/base/net_log.h"
#include "net/base/net_errors.h"
#include "net/proxy/proxy_config.h"
#include "net/proxy/proxy_resolver.h"
@@ -34,15 +34,15 @@ InitProxyResolver::~InitProxyResolver() {
int InitProxyResolver::Init(const ProxyConfig& config,
CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
DCHECK_EQ(STATE_NONE, next_state_);
DCHECK(callback);
DCHECK(config.MayRequirePACResolver());
- DCHECK(!load_log_);
+ DCHECK(!net_log_.net_log());
- load_log_ = load_log;
+ net_log_ = net_log;
- LoadLog::BeginEvent(load_log_, LoadLog::TYPE_INIT_PROXY_RESOLVER);
+ net_log_.BeginEvent(NetLog::TYPE_INIT_PROXY_RESOLVER);
pac_urls_ = BuildPacUrlsFallbackList(config);
DCHECK(!pac_urls_.empty());
@@ -122,17 +122,16 @@ void InitProxyResolver::DoCallback(int result) {
int InitProxyResolver::DoFetchPacScript() {
DCHECK(resolver_->expects_pac_bytes());
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT);
+ net_log_.BeginEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT);
next_state_ = STATE_FETCH_PAC_SCRIPT_COMPLETE;
const GURL& pac_url = current_pac_url();
- LoadLog::AddString(load_log_, pac_url.spec());
+ net_log_.AddString(pac_url.spec());
if (!proxy_script_fetcher_) {
- LoadLog::AddStringLiteral(load_log_,
+ net_log_.AddStringLiteral(
"Can't download PAC script, because no fetcher was specified");
return ERR_UNEXPECTED;
}
@@ -143,14 +142,12 @@ int InitProxyResolver::DoFetchPacScript() {
int InitProxyResolver::DoFetchPacScriptComplete(int result) {
DCHECK(resolver_->expects_pac_bytes());
- LoadLog::AddString(load_log_,
- StringPrintf(
+ net_log_.AddString(StringPrintf(
"Completed fetch with result %s. Received %" PRIuS " bytes",
ErrorToString(result),
pac_bytes_.size()));
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT);
+ net_log_.EndEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT);
if (result != OK)
return TryToFallbackPacUrl(result);
@@ -160,8 +157,7 @@ int InitProxyResolver::DoFetchPacScriptComplete(int result) {
}
int InitProxyResolver::DoSetPacScript() {
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT);
+ net_log_.BeginEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT);
const GURL& pac_url = current_pac_url();
@@ -174,18 +170,16 @@ int InitProxyResolver::DoSetPacScript() {
int InitProxyResolver::DoSetPacScriptComplete(int result) {
if (result != OK) {
- LoadLog::AddString(load_log_,
+ net_log_.AddString(
StringPrintf("Failed initializing the PAC script with error: %s",
ErrorToString(result)));
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT);
+ net_log_.EndEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT);
return TryToFallbackPacUrl(result);
}
- LoadLog::AddStringLiteral(load_log_, "Successfully initialized PAC script.");
+ net_log_.AddStringLiteral("Successfully initialized PAC script.");
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT);
+ net_log_.EndEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT);
return result;
}
@@ -200,7 +194,7 @@ int InitProxyResolver::TryToFallbackPacUrl(int error) {
// Advance to next URL in our list.
++current_pac_url_index_;
- LoadLog::AddStringLiteral(load_log_, "Falling back to next PAC URL...");
+ net_log_.AddStringLiteral("Falling back to next PAC URL...");
next_state_ = GetStartState();
@@ -218,13 +212,13 @@ const GURL& InitProxyResolver::current_pac_url() const {
}
void InitProxyResolver::DidCompleteInit() {
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_INIT_PROXY_RESOLVER);
+ net_log_.EndEvent(NetLog::TYPE_INIT_PROXY_RESOLVER);
}
void InitProxyResolver::Cancel() {
DCHECK_NE(STATE_NONE, next_state_);
- LoadLog::AddEvent(load_log_, LoadLog::TYPE_CANCELLED);
+ net_log_.AddEvent(NetLog::TYPE_CANCELLED);
switch (next_state_) {
case STATE_FETCH_PAC_SCRIPT_COMPLETE:
diff --git a/net/proxy/init_proxy_resolver.h b/net/proxy/init_proxy_resolver.h
index 0bec8e9..031fef3 100644
--- a/net/proxy/init_proxy_resolver.h
+++ b/net/proxy/init_proxy_resolver.h
@@ -10,10 +10,11 @@
#include "googleurl/src/gurl.h"
#include "net/base/completion_callback.h"
+#include "net/base/net_log.h"
namespace net {
-class LoadLog;
+class BoundNetLog;
class ProxyConfig;
class ProxyResolver;
class ProxyScriptFetcher;
@@ -47,7 +48,7 @@ class InitProxyResolver {
// Apply the PAC settings of |config| to |resolver_|.
int Init(const ProxyConfig& config,
CompletionCallback* callback,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
private:
enum State {
@@ -102,7 +103,7 @@ class InitProxyResolver {
UrlList pac_urls_;
State next_state_;
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
DISALLOW_COPY_AND_ASSIGN(InitProxyResolver);
};
diff --git a/net/proxy/init_proxy_resolver_unittest.cc b/net/proxy/init_proxy_resolver_unittest.cc
index 1ed62e8..d6ca4af 100644
--- a/net/proxy/init_proxy_resolver_unittest.cc
+++ b/net/proxy/init_proxy_resolver_unittest.cc
@@ -5,9 +5,8 @@
#include <vector>
#include "net/base/net_errors.h"
-#include "net/base/load_log.h"
-#include "net/base/load_log_util.h"
-#include "net/base/load_log_unittest.h"
+#include "net/base/net_log.h"
+#include "net/base/net_log_unittest.h"
#include "net/base/test_completion_callback.h"
#include "net/proxy/init_proxy_resolver.h"
#include "net/proxy/proxy_config.h"
@@ -120,7 +119,7 @@ class RuleBasedProxyResolver : public ProxyResolver {
ProxyInfo* /*results*/,
CompletionCallback* /*callback*/,
RequestHandle* /*request_handle*/,
- LoadLog* /*load_log*/) {
+ const BoundNetLog& /*net_log*/) {
NOTREACHED();
return ERR_UNEXPECTED;
}
@@ -172,24 +171,25 @@ TEST(InitProxyResolverTest, CustomPacSucceeds) {
Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac");
TestCompletionCallback callback;
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
InitProxyResolver init(&resolver, &fetcher);
- EXPECT_EQ(OK, init.Init(config, &callback, log));
+ EXPECT_EQ(OK, init.Init(config, &callback, log.bound()));
EXPECT_EQ(rule.bytes(), resolver.pac_bytes());
- // Check the LoadLog was filled correctly.
- EXPECT_EQ(9u, log->entries().size());
+ // Check the NetLog was filled correctly.
+ EXPECT_EQ(9u, log.entries().size());
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER));
+ log.entries(), 0, NetLog::TYPE_INIT_PROXY_RESOLVER));
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
+ log.entries(), 1, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 4, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
+ log.entries(), 4, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 5, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
+ log.entries(), 5, NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 7, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
- EXPECT_TRUE(LogContainsEndEvent(*log, 8, LoadLog::TYPE_INIT_PROXY_RESOLVER));
+ log.entries(), 7, NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), 8, NetLog::TYPE_INIT_PROXY_RESOLVER));
}
// Fail downloading the custom PAC script.
@@ -204,20 +204,21 @@ TEST(InitProxyResolverTest, CustomPacFails1) {
rules.AddFailDownloadRule("http://custom/proxy.pac");
TestCompletionCallback callback;
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
InitProxyResolver init(&resolver, &fetcher);
- EXPECT_EQ(kFailedDownloading, init.Init(config, &callback, log));
+ EXPECT_EQ(kFailedDownloading, init.Init(config, &callback, log.bound()));
EXPECT_EQ("", resolver.pac_bytes());
- // Check the LoadLog was filled correctly.
- EXPECT_EQ(6u, log->entries().size());
+ // Check the NetLog was filled correctly.
+ EXPECT_EQ(6u, log.entries().size());
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER));
+ log.entries(), 0, NetLog::TYPE_INIT_PROXY_RESOLVER));
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
+ log.entries(), 1, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), 4, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 4, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
- EXPECT_TRUE(LogContainsEndEvent(*log, 5, LoadLog::TYPE_INIT_PROXY_RESOLVER));
+ log.entries(), 5, NetLog::TYPE_INIT_PROXY_RESOLVER));
}
// Fail parsing the custom PAC script.
@@ -301,34 +302,35 @@ TEST(InitProxyResolverTest, AutodetectFailCustomSuccess2) {
Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac");
TestCompletionCallback callback;
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
InitProxyResolver init(&resolver, &fetcher);
- EXPECT_EQ(OK, init.Init(config, &callback, log));
+ EXPECT_EQ(OK, init.Init(config, &callback, log.bound()));
EXPECT_EQ(rule.bytes(), resolver.pac_bytes());
- // Check the LoadLog was filled correctly.
+ // Check the NetLog was filled correctly.
// (Note that the Fetch and Set states are repeated since both WPAD and custom
// PAC scripts are tried).
- EXPECT_EQ(17u, log->entries().size());
+ EXPECT_EQ(17u, log.entries().size());
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER));
+ log.entries(), 0, NetLog::TYPE_INIT_PROXY_RESOLVER));
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
+ log.entries(), 1, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 4, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
+ log.entries(), 4, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 5, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
+ log.entries(), 5, NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 7, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
+ log.entries(), 7, NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 9, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
+ log.entries(), 9, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 12, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
+ log.entries(), 12, NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT));
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 13, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
+ log.entries(), 13, NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), 15, NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 15, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT));
- EXPECT_TRUE(LogContainsEndEvent(*log, 16, LoadLog::TYPE_INIT_PROXY_RESOLVER));
+ log.entries(), 16, NetLog::TYPE_INIT_PROXY_RESOLVER));
}
// Fails at WPAD (downloading), and fails at custom PAC (downloading).
diff --git a/net/proxy/mock_proxy_resolver.h b/net/proxy/mock_proxy_resolver.h
index c284eb1..88d3246 100644
--- a/net/proxy/mock_proxy_resolver.h
+++ b/net/proxy/mock_proxy_resolver.h
@@ -97,7 +97,7 @@ class MockAsyncProxyResolverBase : public ProxyResolver {
ProxyInfo* results,
CompletionCallback* callback,
RequestHandle* request_handle,
- LoadLog* /*load_log*/) {
+ const BoundNetLog& /*net_log*/) {
scoped_refptr<Request> request = new Request(this, url, results, callback);
pending_requests_.push_back(request);
diff --git a/net/proxy/proxy_resolver.h b/net/proxy/proxy_resolver.h
index 2e83097b..50f855a 100644
--- a/net/proxy/proxy_resolver.h
+++ b/net/proxy/proxy_resolver.h
@@ -13,7 +13,7 @@
namespace net {
-class LoadLog;
+class BoundNetLog;
class ProxyInfo;
// Interface for "proxy resolvers". A ProxyResolver fills in a list of proxies
@@ -41,7 +41,7 @@ class ProxyResolver {
ProxyInfo* results,
CompletionCallback* callback,
RequestHandle* request,
- LoadLog* load_log) = 0;
+ const BoundNetLog& net_log) = 0;
// Cancels |request|.
virtual void CancelRequest(RequestHandle request) = 0;
diff --git a/net/proxy/proxy_resolver_js_bindings.cc b/net/proxy/proxy_resolver_js_bindings.cc
index eb7e4f8..0906e7a 100644
--- a/net/proxy/proxy_resolver_js_bindings.cc
+++ b/net/proxy/proxy_resolver_js_bindings.cc
@@ -1,6 +1,6 @@
-// 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_js_bindings.h"
@@ -11,6 +11,7 @@
#include "net/base/address_list.h"
#include "net/base/host_resolver.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log.h"
#include "net/base/net_util.h"
#include "net/base/sys_addrinfo.h"
@@ -42,7 +43,8 @@ class SyncHostResolverBridge
// Hack for tests -- run synchronously on current thread.
if (!host_resolver_loop_)
- return host_resolver_->Resolve(info, addresses, NULL, NULL, NULL);
+ return host_resolver_->Resolve(info, addresses, NULL, NULL,
+ BoundNetLog());
// Otherwise start an async resolve on the resolver's thread.
host_resolver_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
@@ -63,7 +65,7 @@ class SyncHostResolverBridge
net::AddressList* addresses) {
DCHECK_EQ(host_resolver_loop_, MessageLoop::current());
int error = host_resolver_->Resolve(
- info, addresses, &callback_, NULL, NULL);
+ info, addresses, &callback_, NULL, BoundNetLog());
if (error != ERR_IO_PENDING)
OnResolveCompletion(error); // Completed synchronously.
}
diff --git a/net/proxy/proxy_resolver_js_bindings_unittest.cc b/net/proxy/proxy_resolver_js_bindings_unittest.cc
index 9231f93..3271e92 100644
--- a/net/proxy/proxy_resolver_js_bindings_unittest.cc
+++ b/net/proxy/proxy_resolver_js_bindings_unittest.cc
@@ -6,6 +6,7 @@
#include "net/base/address_list.h"
#include "net/base/mock_host_resolver.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log.h"
#include "net/base/net_util.h"
#include "net/base/sys_addrinfo.h"
#include "net/proxy/proxy_resolver_js_bindings.h"
@@ -26,7 +27,7 @@ class MockHostResolverWithMultipleResults : public HostResolver {
AddressList* addresses,
CompletionCallback* callback,
RequestHandle* out_req,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
// Build up the result list (in reverse).
AddressList temp_list = ResolveIPLiteral("200.100.1.2");
temp_list = PrependAddressToList("172.22.34.1", temp_list);
@@ -149,11 +150,13 @@ TEST(ProxyResolverJSBindingsTest, RestrictAddressFamily) {
// depending if the address family was IPV4_ONLY or not.
HostResolver::RequestInfo info("foo", 80);
AddressList address_list;
- EXPECT_EQ(OK, host_resolver->Resolve(info, &address_list, NULL, NULL, NULL));
+ EXPECT_EQ(OK, host_resolver->Resolve(info, &address_list, NULL, NULL,
+ BoundNetLog()));
EXPECT_EQ("192.168.2.1", NetAddressToString(address_list.head()));
info.set_address_family(ADDRESS_FAMILY_IPV4);
- EXPECT_EQ(OK, host_resolver->Resolve(info, &address_list, NULL, NULL, NULL));
+ EXPECT_EQ(OK, host_resolver->Resolve(info, &address_list, NULL, NULL,
+ BoundNetLog()));
EXPECT_EQ("192.168.1.1", NetAddressToString(address_list.head()));
// Now the actual test.
diff --git a/net/proxy/proxy_resolver_mac.cc b/net/proxy/proxy_resolver_mac.cc
index 6baf78f..b052d3d 100644
--- a/net/proxy/proxy_resolver_mac.cc
+++ b/net/proxy/proxy_resolver_mac.cc
@@ -59,7 +59,7 @@ int ProxyResolverMac::GetProxyForURL(const GURL& query_url,
ProxyInfo* results,
CompletionCallback* /*callback*/,
RequestHandle* /*request*/,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
scoped_cftyperef<CFStringRef> query_ref(
base::SysUTF8ToCFStringRef(query_url.spec()));
scoped_cftyperef<CFURLRef> query_url_ref(
diff --git a/net/proxy/proxy_resolver_mac.h b/net/proxy/proxy_resolver_mac.h
index 6676b2f..43de83c 100644
--- a/net/proxy/proxy_resolver_mac.h
+++ b/net/proxy/proxy_resolver_mac.h
@@ -24,7 +24,7 @@ class ProxyResolverMac : public ProxyResolver {
ProxyInfo* results,
CompletionCallback* callback,
RequestHandle* request,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
virtual void CancelRequest(RequestHandle request) {
NOTREACHED();
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;
}
diff --git a/net/proxy/proxy_resolver_v8.h b/net/proxy/proxy_resolver_v8.h
index 236beab..4424a30 100644
--- a/net/proxy/proxy_resolver_v8.h
+++ b/net/proxy/proxy_resolver_v8.h
@@ -49,7 +49,7 @@ class ProxyResolverV8 : public ProxyResolver {
ProxyInfo* results,
CompletionCallback* /*callback*/,
RequestHandle* /*request*/,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
virtual void CancelRequest(RequestHandle request);
virtual void PurgeMemory();
diff --git a/net/proxy/proxy_resolver_v8_unittest.cc b/net/proxy/proxy_resolver_v8_unittest.cc
index ee536b0..904bf7c 100644
--- a/net/proxy/proxy_resolver_v8_unittest.cc
+++ b/net/proxy/proxy_resolver_v8_unittest.cc
@@ -6,7 +6,7 @@
#include "base/string_util.h"
#include "base/path_service.h"
#include "googleurl/src/gurl.h"
-#include "net/base/load_log_unittest.h"
+#include "net/base/net_log_unittest.h"
#include "net/base/net_errors.h"
#include "net/proxy/proxy_info.h"
#include "net/proxy/proxy_resolver_js_bindings.h"
@@ -118,8 +118,9 @@ TEST(ProxyResolverV8Test, Direct) {
EXPECT_EQ(OK, result);
ProxyInfo proxy_info;
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
+ log.bound());
EXPECT_EQ(OK, result);
EXPECT_TRUE(proxy_info.is_direct());
@@ -128,7 +129,7 @@ TEST(ProxyResolverV8Test, Direct) {
EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
// No bindings were called, so no log entries.
- EXPECT_EQ(0u, log->entries().size());
+ EXPECT_EQ(0u, log.entries().size());
}
TEST(ProxyResolverV8Test, ReturnEmptyString) {
@@ -416,37 +417,38 @@ TEST(ProxyResolverV8Test, V8Bindings) {
}
// Test that calls to the myIpAddress() and dnsResolve() bindings get
-// logged to the LoadLog parameter.
-TEST(ProxyResolverV8Test, LoadLog) {
+// logged to the NetLog parameter.
+TEST(ProxyResolverV8Test, NetLog) {
ProxyResolverV8WithMockBindings resolver;
int result = resolver.SetPacScriptFromDisk("simple.js");
EXPECT_EQ(OK, result);
ProxyInfo proxy_info;
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
+ log.bound());
EXPECT_EQ(OK, result);
EXPECT_FALSE(proxy_info.is_direct());
EXPECT_EQ("c:100", proxy_info.proxy_server().ToURI());
// Note that dnsResolve() was never called directly, but it appears
- // in the LoadLog. This is because it gets called indirectly by
+ // in the NetLog. This is because it gets called indirectly by
// isInNet() and isResolvable().
- EXPECT_EQ(6u, log->entries().size());
+ EXPECT_EQ(6u, log.entries().size());
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 0, LoadLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS));
+ log.entries(), 0, NetLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 1, LoadLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS));
+ log.entries(), 1, NetLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS));
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 2, LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE));
+ log.entries(), 2, NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 3, LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE));
+ log.entries(), 3, NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE));
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 4, LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE));
+ log.entries(), 4, NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 5, LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE));
+ log.entries(), 5, NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE));
}
// Try loading a PAC script that ends with a comment and has no terminal
@@ -459,8 +461,9 @@ TEST(ProxyResolverV8Test, EndsWithCommentNoNewline) {
EXPECT_EQ(OK, result);
ProxyInfo proxy_info;
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
+ log.bound());
EXPECT_EQ(OK, result);
EXPECT_FALSE(proxy_info.is_direct());
@@ -478,8 +481,9 @@ TEST(ProxyResolverV8Test, EndsWithStatementNoNewline) {
EXPECT_EQ(OK, result);
ProxyInfo proxy_info;
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
+ log.bound());
EXPECT_EQ(OK, result);
EXPECT_FALSE(proxy_info.is_direct());
diff --git a/net/proxy/proxy_resolver_winhttp.cc b/net/proxy/proxy_resolver_winhttp.cc
index fd9efe3..e1faf95 100644
--- a/net/proxy/proxy_resolver_winhttp.cc
+++ b/net/proxy/proxy_resolver_winhttp.cc
@@ -56,7 +56,7 @@ int ProxyResolverWinHttp::GetProxyForURL(const GURL& query_url,
ProxyInfo* results,
CompletionCallback* /*callback*/,
RequestHandle* /*request*/,
- LoadLog* /*load_log*/) {
+ const BoundNetLog& /*net_log*/) {
// If we don't have a WinHTTP session, then create a new one.
if (!session_handle_ && !OpenWinHttpSession())
return ERR_FAILED;
diff --git a/net/proxy/proxy_resolver_winhttp.h b/net/proxy/proxy_resolver_winhttp.h
index ab1df0f1..6062fbe 100644
--- a/net/proxy/proxy_resolver_winhttp.h
+++ b/net/proxy/proxy_resolver_winhttp.h
@@ -26,7 +26,7 @@ class ProxyResolverWinHttp : public ProxyResolver {
ProxyInfo* results,
CompletionCallback* /*callback*/,
RequestHandle* /*request*/,
- LoadLog* /*load_log*/);
+ const BoundNetLog& /*net_log*/);
virtual void CancelRequest(RequestHandle request);
private:
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index 1ff2999..bc4a708 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -11,7 +11,7 @@
#include "base/message_loop.h"
#include "base/string_util.h"
#include "googleurl/src/gurl.h"
-#include "net/base/load_log.h"
+#include "net/base/net_log.h"
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
#include "net/proxy/init_proxy_resolver.h"
@@ -37,7 +37,7 @@ using base::TimeTicks;
namespace net {
-static const size_t kMaxNumLoadLogEntries = 100;
+static const size_t kMaxNumNetLogEntries = 100;
// Config getter that fails every time.
class ProxyConfigServiceNull : public ProxyConfigService {
@@ -58,7 +58,7 @@ class ProxyResolverNull : public ProxyResolver {
ProxyInfo* results,
CompletionCallback* callback,
RequestHandle* request,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
return ERR_NOT_IMPLEMENTED;
}
@@ -83,7 +83,7 @@ class ProxyService::PacRequest
const GURL& url,
ProxyInfo* results,
CompletionCallback* user_callback,
- LoadLog* load_log)
+ const BoundNetLog& net_log)
: service_(service),
user_callback_(user_callback),
ALLOW_THIS_IN_INITIALIZER_LIST(io_callback_(
@@ -92,7 +92,7 @@ class ProxyService::PacRequest
url_(url),
resolve_job_(NULL),
config_id_(ProxyConfig::INVALID_ID),
- load_log_(load_log) {
+ net_log_(net_log) {
DCHECK(user_callback);
}
@@ -104,7 +104,7 @@ class ProxyService::PacRequest
config_id_ = service_->config_.id();
return resolver()->GetProxyForURL(
- url_, results_, &io_callback_, &resolve_job_, load_log_);
+ url_, results_, &io_callback_, &resolve_job_, net_log_);
}
bool is_started() const {
@@ -129,7 +129,7 @@ class ProxyService::PacRequest
}
void Cancel() {
- LoadLog::AddEvent(load_log_, LoadLog::TYPE_CANCELLED);
+ net_log_.AddEvent(NetLog::TYPE_CANCELLED);
if (is_started())
CancelResolveJob();
@@ -139,7 +139,7 @@ class ProxyService::PacRequest
user_callback_ = NULL;
results_ = NULL;
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_PROXY_SERVICE);
+ net_log_.EndEvent(NetLog::TYPE_PROXY_SERVICE);
}
// Returns true if Cancel() has been called.
@@ -158,10 +158,10 @@ class ProxyService::PacRequest
resolve_job_ = NULL;
config_id_ = ProxyConfig::INVALID_ID;
- return service_->DidFinishResolvingProxy(results_, result_code, load_log_);
+ return service_->DidFinishResolvingProxy(results_, result_code, net_log_);
}
- LoadLog* load_log() const { return load_log_; }
+ BoundNetLog* net_log() { return &net_log_; }
private:
friend class base::RefCounted<ProxyService::PacRequest>;
@@ -192,7 +192,7 @@ class ProxyService::PacRequest
GURL url_;
ProxyResolver::RequestHandle resolve_job_;
ProxyConfig::ID config_id_; // The config id when the resolve was started.
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
};
// ProxyService ---------------------------------------------------------------
@@ -206,6 +206,7 @@ ProxyService::ProxyService(ProxyConfigService* config_service,
should_use_proxy_resolver_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(init_proxy_resolver_callback_(
this, &ProxyService::OnInitProxyResolverComplete)),
+ init_proxy_resolver_log_(kMaxNumNetLogEntries),
network_change_notifier_(network_change_notifier) {
// Register to receive network change notifications.
if (network_change_notifier_)
@@ -266,10 +267,10 @@ int ProxyService::ResolveProxy(const GURL& raw_url,
ProxyInfo* result,
CompletionCallback* callback,
PacRequest** pac_request,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
DCHECK(callback);
- LoadLog::BeginEvent(load_log, LoadLog::TYPE_PROXY_SERVICE);
+ net_log.BeginEvent(NetLog::TYPE_PROXY_SERVICE);
// Strip away any reference fragments and the username/password, as they
// are not relevant to proxy resolution.
@@ -277,13 +278,13 @@ int ProxyService::ResolveProxy(const GURL& raw_url,
// Check if the request can be completed right away. This is the case when
// using a direct connection, or when the config is bad.
- UpdateConfigIfOld(load_log);
+ UpdateConfigIfOld(net_log);
int rv = TryToCompleteSynchronously(url, result);
if (rv != ERR_IO_PENDING)
- return DidFinishResolvingProxy(result, rv, load_log);
+ return DidFinishResolvingProxy(result, rv, net_log);
scoped_refptr<PacRequest> req =
- new PacRequest(this, url, result, callback, load_log);
+ new PacRequest(this, url, result, callback, net_log);
bool resolver_is_ready = !IsInitializingProxyResolver();
@@ -293,8 +294,7 @@ int ProxyService::ResolveProxy(const GURL& raw_url,
if (rv != ERR_IO_PENDING)
return req->QueryDidComplete(rv);
} else {
- LoadLog::BeginEvent(req->load_log(),
- LoadLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC);
+ req->net_log()->BeginEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC);
}
DCHECK_EQ(ERR_IO_PENDING, rv);
@@ -335,6 +335,10 @@ ProxyService::~ProxyService() {
++it) {
(*it)->Cancel();
}
+
+ // Make sure that InitProxyResolver gets destroyed BEFORE the
+ // CapturingNetLog it is using is deleted.
+ init_proxy_resolver_.reset();
}
void ProxyService::SuspendAllPendingRequests() {
@@ -345,8 +349,8 @@ void ProxyService::SuspendAllPendingRequests() {
if (req->is_started()) {
req->CancelResolveJob();
- LoadLog::BeginEvent(req->load_log(),
- LoadLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC);
+ req->net_log()->BeginEvent(
+ NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC);
}
}
}
@@ -364,8 +368,7 @@ void ProxyService::ResumeAllPendingRequests() {
++it) {
PacRequest* req = it->get();
if (!req->is_started() && !req->was_cancelled()) {
- LoadLog::EndEvent(req->load_log(),
- LoadLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC);
+ req->net_log()->EndEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC);
// Note that we re-check for synchronous completion, in case we are
// no longer using a ProxyResolver (can happen if we fell-back to manual).
@@ -396,14 +399,14 @@ int ProxyService::ReconsiderProxyAfterError(const GURL& url,
ProxyInfo* result,
CompletionCallback* callback,
PacRequest** pac_request,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
// Check to see if we have a new config since ResolveProxy was called. We
// want to re-run ResolveProxy in two cases: 1) we have a new config, or 2) a
// direct connection failed and we never tried the current config.
bool re_resolve = result->config_id_ != config_.id();
if (!re_resolve) {
- UpdateConfig(load_log);
+ UpdateConfig(net_log);
if (result->config_id_ != config_.id()) {
// A new configuration!
re_resolve = true;
@@ -413,7 +416,7 @@ int ProxyService::ReconsiderProxyAfterError(const GURL& url,
// If we have a new config or the config was never tried, we delete the
// list of bad proxies and we try again.
proxy_retry_info_.clear();
- return ResolveProxy(url, result, callback, pac_request, load_log);
+ return ResolveProxy(url, result, callback, pac_request, net_log);
}
// We don't have new proxy settings to try, try to fallback to the next proxy
@@ -446,21 +449,19 @@ void ProxyService::RemovePendingRequest(PacRequest* req) {
int ProxyService::DidFinishResolvingProxy(ProxyInfo* result,
int result_code,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
// Log the result of the proxy resolution.
if (result_code == OK) {
// When full logging is enabled, dump the proxy list.
- if (LoadLog::IsUnbounded(load_log)) {
- LoadLog::AddString(
- load_log,
+ if (net_log.HasListener()) {
+ net_log.AddString(
std::string("Resolved proxy list: ") + result->ToPacString());
}
result->DeprioritizeBadProxies(proxy_retry_info_);
} else {
- LoadLog::AddStringLiteral(
- load_log,
+ net_log.AddStringLiteral(
"Got an error from proxy resolver, falling-back to DIRECT.");
- LoadLog::AddErrorCode(load_log, result_code);
+ net_log.AddErrorCode(result_code);
// Fall-back to direct when the proxy resolver fails. This corresponds
// with a javascript runtime error in the PAC script.
@@ -473,7 +474,7 @@ int ProxyService::DidFinishResolvingProxy(ProxyInfo* result,
result_code = OK;
}
- LoadLog::EndEvent(load_log, LoadLog::TYPE_PROXY_SERVICE);
+ net_log.EndEvent(NetLog::TYPE_PROXY_SERVICE);
return result_code;
}
@@ -564,18 +565,17 @@ ProxyResolver* ProxyService::CreateNonV8ProxyResolver() {
#endif
}
-void ProxyService::UpdateConfig(LoadLog* load_log) {
+void ProxyService::UpdateConfig(const BoundNetLog& net_log) {
bool is_first_update = !config_has_been_initialized();
ProxyConfig latest;
// Fetch the proxy settings.
TimeTicks start_time = TimeTicks::Now();
- LoadLog::BeginEvent(load_log,
- LoadLog::TYPE_PROXY_SERVICE_POLL_CONFIG_SERVICE_FOR_CHANGES);
+ net_log.BeginEvent(
+ NetLog::TYPE_PROXY_SERVICE_POLL_CONFIG_SERVICE_FOR_CHANGES);
int rv = config_service_->GetProxyConfig(&latest);
- LoadLog::EndEvent(load_log,
- LoadLog::TYPE_PROXY_SERVICE_POLL_CONFIG_SERVICE_FOR_CHANGES);
+ net_log.EndEvent(NetLog::TYPE_PROXY_SERVICE_POLL_CONFIG_SERVICE_FOR_CHANGES);
TimeTicks end_time = TimeTicks::Now();
// Record how long the call to config_service_->GetConfig() above took.
@@ -636,23 +636,24 @@ void ProxyService::StartInitProxyResolver() {
init_proxy_resolver_.reset(
new InitProxyResolver(resolver_.get(), proxy_script_fetcher_.get()));
- init_proxy_resolver_log_ = new LoadLog(kMaxNumLoadLogEntries);
+ init_proxy_resolver_log_.Clear();
int rv = init_proxy_resolver_->Init(
- config_, &init_proxy_resolver_callback_, init_proxy_resolver_log_);
+ config_, &init_proxy_resolver_callback_,
+ init_proxy_resolver_log_.bound());
if (rv != ERR_IO_PENDING)
OnInitProxyResolverComplete(rv);
}
-void ProxyService::UpdateConfigIfOld(LoadLog* load_log) {
+void ProxyService::UpdateConfigIfOld(const BoundNetLog& net_log) {
// The overhead of calling ProxyConfigService::GetProxyConfig is very low.
const TimeDelta kProxyConfigMaxAge = TimeDelta::FromSeconds(5);
// Periodically check for a new config.
if (!config_has_been_initialized() ||
(TimeTicks::Now() - config_last_update_time_) > kProxyConfigMaxAge)
- UpdateConfig(load_log);
+ UpdateConfig(net_log);
}
@@ -679,11 +680,11 @@ SyncProxyServiceHelper::SyncProxyServiceHelper(MessageLoop* io_message_loop,
int SyncProxyServiceHelper::ResolveProxy(const GURL& url,
ProxyInfo* proxy_info,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
DCHECK(io_message_loop_ != MessageLoop::current());
io_message_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &SyncProxyServiceHelper::StartAsyncResolve, url, load_log));
+ this, &SyncProxyServiceHelper::StartAsyncResolve, url, net_log));
event_.Wait();
@@ -694,11 +695,11 @@ int SyncProxyServiceHelper::ResolveProxy(const GURL& url,
}
int SyncProxyServiceHelper::ReconsiderProxyAfterError(
- const GURL& url, ProxyInfo* proxy_info, LoadLog* load_log) {
+ const GURL& url, ProxyInfo* proxy_info, const BoundNetLog& net_log) {
DCHECK(io_message_loop_ != MessageLoop::current());
io_message_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &SyncProxyServiceHelper::StartAsyncReconsider, url, load_log));
+ this, &SyncProxyServiceHelper::StartAsyncReconsider, url, net_log));
event_.Wait();
@@ -709,18 +710,18 @@ int SyncProxyServiceHelper::ReconsiderProxyAfterError(
}
void SyncProxyServiceHelper::StartAsyncResolve(const GURL& url,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
result_ = proxy_service_->ResolveProxy(
- url, &proxy_info_, &callback_, NULL, load_log);
+ url, &proxy_info_, &callback_, NULL, net_log);
if (result_ != net::ERR_IO_PENDING) {
OnCompletion(result_);
}
}
void SyncProxyServiceHelper::StartAsyncReconsider(const GURL& url,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
result_ = proxy_service_->ReconsiderProxyAfterError(
- url, &proxy_info_, &callback_, NULL, load_log);
+ url, &proxy_info_, &callback_, NULL, net_log);
if (result_ != net::ERR_IO_PENDING) {
OnCompletion(result_);
}
diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h
index 7ad83d5..2cf3f95 100644
--- a/net/proxy/proxy_service.h
+++ b/net/proxy/proxy_service.h
@@ -13,6 +13,7 @@
#include "base/waitable_event.h"
#include "net/base/completion_callback.h"
#include "net/base/network_change_notifier.h"
+#include "net/base/net_log.h"
#include "net/proxy/proxy_server.h"
#include "net/proxy/proxy_info.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
@@ -24,7 +25,6 @@ class URLRequestContext;
namespace net {
class InitProxyResolver;
-class LoadLog;
class ProxyConfigService;
class ProxyResolver;
class ProxyScriptFetcher;
@@ -64,12 +64,12 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>,
// 2. PAC URL
// 3. named proxy
//
- // Profiling information for the request is saved to |load_log| if non-NULL.
+ // Profiling information for the request is saved to |net_log| if non-NULL.
int ResolveProxy(const GURL& url,
ProxyInfo* results,
CompletionCallback* callback,
PacRequest** pac_request,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
// This method is called after a failure to connect or resolve a host name.
// It gives the proxy service an opportunity to reconsider the proxy to use.
@@ -82,12 +82,12 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>,
//
// Returns ERR_FAILED if there is not another proxy config to try.
//
- // Profiling information for the request is saved to |load_log| if non-NULL.
+ // Profiling information for the request is saved to |net_log| if non-NULL.
int ReconsiderProxyAfterError(const GURL& url,
ProxyInfo* results,
CompletionCallback* callback,
PacRequest** pac_request,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
// Call this method with a non-null |pac_request| to cancel the PAC request.
void CancelPacRequest(PacRequest* pac_request);
@@ -111,7 +111,7 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>,
// Returns the log for the most recent WPAD + PAC initialization.
// (This shows how much time was spent downloading and parsing the
// PAC scripts for the current configuration).
- LoadLog* init_proxy_resolver_log() const {
+ const CapturingBoundNetLog& init_proxy_resolver_log() const {
return init_proxy_resolver_log_;
}
@@ -199,7 +199,7 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>,
// Checks to see if the proxy configuration changed, and then updates config_
// to reference the new configuration.
- void UpdateConfig(LoadLog* load_log);
+ void UpdateConfig(const BoundNetLog& net_log);
// Assign |config| as the current configuration.
void SetConfig(const ProxyConfig& config);
@@ -209,7 +209,7 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>,
void StartInitProxyResolver();
// Tries to update the configuration if it hasn't been checked in a while.
- void UpdateConfigIfOld(LoadLog* load_log);
+ void UpdateConfigIfOld(const BoundNetLog& net_log);
// Returns true if the proxy resolver is being initialized for PAC
// (downloading PAC script(s) + testing).
@@ -245,7 +245,7 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>,
// bad entries from the results list.
int DidFinishResolvingProxy(ProxyInfo* result,
int result_code,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
// NetworkChangeNotifier::Observer methods:
virtual void OnIPAddressChanged();
@@ -287,7 +287,7 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>,
scoped_ptr<InitProxyResolver> init_proxy_resolver_;
// Log from the *last* time |init_proxy_resolver_.Init()| was called, or NULL.
- scoped_refptr<LoadLog> init_proxy_resolver_log_;
+ CapturingBoundNetLog init_proxy_resolver_log_;
// The (possibly NULL) network change notifier that we use to decide when
// to refetch PAC scripts or re-run WPAD.
@@ -303,17 +303,17 @@ class SyncProxyServiceHelper
SyncProxyServiceHelper(MessageLoop* io_message_loop,
ProxyService* proxy_service);
- int ResolveProxy(const GURL& url, ProxyInfo* proxy_info, LoadLog* load_log);
+ int ResolveProxy(const GURL& url, ProxyInfo* proxy_info, const BoundNetLog& net_log);
int ReconsiderProxyAfterError(const GURL& url,
- ProxyInfo* proxy_info, LoadLog* load_log);
+ ProxyInfo* proxy_info, const BoundNetLog& net_log);
private:
friend class base::RefCountedThreadSafe<SyncProxyServiceHelper>;
~SyncProxyServiceHelper() {}
- void StartAsyncResolve(const GURL& url, LoadLog* load_log);
- void StartAsyncReconsider(const GURL& url, LoadLog* load_log);
+ void StartAsyncResolve(const GURL& url, const BoundNetLog& net_log);
+ void StartAsyncReconsider(const GURL& url, const BoundNetLog& net_log);
void OnCompletion(int result);
diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc
index 309a4654..d4a6326 100644
--- a/net/proxy/proxy_service_unittest.cc
+++ b/net/proxy/proxy_service_unittest.cc
@@ -10,8 +10,8 @@
#include "base/logging.h"
#include "base/string_util.h"
#include "googleurl/src/gurl.h"
-#include "net/base/load_log.h"
-#include "net/base/load_log_unittest.h"
+#include "net/base/net_log.h"
+#include "net/base/net_log_unittest.h"
#include "net/base/mock_network_change_notifier.h"
#include "net/base/net_errors.h"
#include "net/base/test_completion_callback.h"
@@ -98,18 +98,19 @@ TEST(ProxyServiceTest, Direct) {
ProxyInfo info;
TestCompletionCallback callback;
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- int rv = service->ResolveProxy(url, &info, &callback, NULL, log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ int rv = service->ResolveProxy(url, &info, &callback, NULL, log.bound());
EXPECT_EQ(OK, rv);
EXPECT_TRUE(resolver->pending_requests().empty());
- EXPECT_TRUE(NULL == service->init_proxy_resolver_log());
EXPECT_TRUE(info.is_direct());
- // Check the LoadLog was filled correctly.
- EXPECT_EQ(5u, log->entries().size());
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_PROXY_SERVICE));
- EXPECT_TRUE(LogContainsEndEvent(*log, 4, LoadLog::TYPE_PROXY_SERVICE));
+ // Check the NetLog was filled correctly.
+ EXPECT_EQ(5u, log.entries().size());
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log.entries(), 0, NetLog::TYPE_PROXY_SERVICE));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), 4, NetLog::TYPE_PROXY_SERVICE));
}
TEST(ProxyServiceTest, PAC) {
@@ -125,13 +126,13 @@ TEST(ProxyServiceTest, PAC) {
ProxyInfo info;
TestCompletionCallback callback;
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- int rv = service->ResolveProxy(url, &info, &callback, NULL, log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+
+ int rv = service->ResolveProxy(url, &info, &callback, NULL, log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
resolver->pending_set_pac_script_request()->pac_url());
- EXPECT_FALSE(NULL == service->init_proxy_resolver_log());
resolver->pending_set_pac_script_request()->CompleteNow(OK);
ASSERT_EQ(1u, resolver->pending_requests().size());
@@ -145,14 +146,16 @@ TEST(ProxyServiceTest, PAC) {
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy:80", info.proxy_server().ToURI());
- // Check the LoadLog was filled correctly.
- EXPECT_EQ(7u, log->entries().size());
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_PROXY_SERVICE));
+ // Check the NetLog was filled correctly.
+ EXPECT_EQ(7u, log.entries().size());
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log.entries(), 0, NetLog::TYPE_PROXY_SERVICE));
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 3, LoadLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC));
+ log.entries(), 3, NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 4, LoadLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC));
- EXPECT_TRUE(LogContainsEndEvent(*log, 6, LoadLog::TYPE_PROXY_SERVICE));
+ log.entries(), 4, NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), 6, NetLog::TYPE_PROXY_SERVICE));
}
// Test that the proxy resolver does not see the URL's username/password
@@ -1036,9 +1039,9 @@ TEST(ProxyServiceTest, CancelWhilePACFetching) {
ProxyInfo info1;
TestCompletionCallback callback1;
ProxyService::PacRequest* request1;
- scoped_refptr<LoadLog> log1(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log1(CapturingNetLog::kUnbounded);
int rv = service->ResolveProxy(
- GURL("http://request1"), &info1, &callback1, &request1, log1);
+ GURL("http://request1"), &info1, &callback1, &request1, log1.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
// The first request should have triggered download of PAC script.
@@ -1090,16 +1093,18 @@ TEST(ProxyServiceTest, CancelWhilePACFetching) {
EXPECT_FALSE(callback1.have_result()); // Cancelled.
EXPECT_FALSE(callback2.have_result()); // Cancelled.
- // Check the LoadLog for request 1 (which was cancelled) got filled properly.
- EXPECT_EQ(6u, log1->entries().size());
- EXPECT_TRUE(LogContainsBeginEvent(*log1, 0, LoadLog::TYPE_PROXY_SERVICE));
+ // Check the NetLog for request 1 (which was cancelled) got filled properly.
+ EXPECT_EQ(6u, log1.entries().size());
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log1.entries(), 0, NetLog::TYPE_PROXY_SERVICE));
EXPECT_TRUE(LogContainsBeginEvent(
- *log1, 3, LoadLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC));
+ log1.entries(), 3, NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC));
// Note that TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC is never completed before
// the cancellation occured.
EXPECT_TRUE(LogContainsEvent(
- *log1, 4, LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE));
- EXPECT_TRUE(LogContainsEndEvent(*log1, 5, LoadLog::TYPE_PROXY_SERVICE));
+ log1.entries(), 4, NetLog::TYPE_CANCELLED, NetLog::PHASE_NONE));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log1.entries(), 5, NetLog::TYPE_PROXY_SERVICE));
}
// Test that if auto-detect fails, we fall-back to the custom pac.
diff --git a/net/proxy/single_threaded_proxy_resolver.cc b/net/proxy/single_threaded_proxy_resolver.cc
index 05c8af0..81e3f1b 100644
--- a/net/proxy/single_threaded_proxy_resolver.cc
+++ b/net/proxy/single_threaded_proxy_resolver.cc
@@ -5,7 +5,7 @@
#include "net/proxy/single_threaded_proxy_resolver.h"
#include "base/thread.h"
-#include "net/base/load_log.h"
+#include "net/base/net_log.h"
#include "net/base/net_errors.h"
#include "net/proxy/proxy_info.h"
@@ -110,11 +110,11 @@ class SingleThreadedProxyResolver::Job
const GURL& url,
ProxyInfo* results,
CompletionCallback* callback,
- LoadLog* load_log)
+ const BoundNetLog& net_log)
: coordinator_(coordinator),
callback_(callback),
results_(results),
- load_log_(load_log),
+ net_log_(net_log),
url_(url),
is_started_(false),
origin_loop_(MessageLoop::current()) {
@@ -125,7 +125,7 @@ class SingleThreadedProxyResolver::Job
void Start() {
is_started_ = true;
- size_t load_log_bound = load_log_ ? load_log_->max_num_entries() : 0;
+ size_t load_log_bound = 100;
coordinator_->thread()->message_loop()->PostTask(
FROM_HERE, NewRunnableMethod(this, &Job::DoQuery,
@@ -146,7 +146,7 @@ class SingleThreadedProxyResolver::Job
// Returns true if Cancel() has been called.
bool was_cancelled() const { return callback_ == NULL; }
- LoadLog* load_log() { return load_log_; }
+ BoundNetLog* net_log() { return &net_log_; }
private:
friend class base::RefCountedThreadSafe<SingleThreadedProxyResolver::Job>;
@@ -155,29 +155,23 @@ class SingleThreadedProxyResolver::Job
// Runs on the worker thread.
void DoQuery(ProxyResolver* resolver, size_t load_log_bound) {
- LoadLog* worker_log = NULL;
- if (load_log_bound > 0) {
- worker_log = new LoadLog(load_log_bound);
- worker_log->AddRef(); // Balanced in QueryComplete.
- }
+ scoped_ptr<CapturingNetLog> worker_log(new CapturingNetLog(load_log_bound));
+ BoundNetLog bound_worker_log(NetLog::Source(), worker_log.get());
int rv = resolver->GetProxyForURL(url_, &results_buf_, NULL, NULL,
- worker_log);
+ bound_worker_log);
DCHECK_NE(rv, ERR_IO_PENDING);
origin_loop_->PostTask(FROM_HERE,
- NewRunnableMethod(this, &Job::QueryComplete, rv, worker_log));
+ NewRunnableMethod(this, &Job::QueryComplete, rv, worker_log.release()));
}
// Runs the completion callback on the origin thread.
- void QueryComplete(int result_code, LoadLog* worker_log) {
+ void QueryComplete(int result_code, CapturingNetLog* worker_log) {
// Merge the load log that was generated on the worker thread, into the
// main log.
- if (worker_log) {
- if (load_log_)
- load_log_->Append(worker_log);
- worker_log->Release();
- }
+ CapturingBoundNetLog bound_worker_log(NetLog::Source(), worker_log);
+ bound_worker_log.AppendTo(net_log_);
// The Job may have been cancelled after it was started.
if (!was_cancelled()) {
@@ -197,7 +191,7 @@ class SingleThreadedProxyResolver::Job
SingleThreadedProxyResolver* coordinator_;
CompletionCallback* callback_;
ProxyInfo* results_;
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
GURL url_;
bool is_started_;
@@ -233,10 +227,10 @@ int SingleThreadedProxyResolver::GetProxyForURL(const GURL& url,
ProxyInfo* results,
CompletionCallback* callback,
RequestHandle* request,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
DCHECK(callback);
- scoped_refptr<Job> job = new Job(this, url, results, callback, load_log);
+ scoped_refptr<Job> job = new Job(this, url, results, callback, net_log);
bool is_first_job = pending_jobs_.empty();
pending_jobs_.push_back(job); // Jobs can never finish synchronously.
@@ -246,9 +240,7 @@ int SingleThreadedProxyResolver::GetProxyForURL(const GURL& url,
job->Start();
} else {
// Otherwise the job will get started eventually by ProcessPendingJobs().
- LoadLog::BeginEvent(
- job->load_log(),
- LoadLog::TYPE_WAITING_FOR_SINGLE_PROXY_RESOLVER_THREAD);
+ job->net_log()->BeginEvent(NetLog::TYPE_WAITING_FOR_SINGLE_PROXY_RESOLVER_THREAD);
}
// Completion will be notified through |callback|, unless the caller cancels
@@ -329,9 +321,8 @@ void SingleThreadedProxyResolver::ProcessPendingJobs() {
if (job->is_started())
return;
- LoadLog::EndEvent(
- job->load_log(),
- LoadLog::TYPE_WAITING_FOR_SINGLE_PROXY_RESOLVER_THREAD);
+ job->net_log()->EndEvent(
+ NetLog::TYPE_WAITING_FOR_SINGLE_PROXY_RESOLVER_THREAD);
EnsureThreadStarted();
job->Start();
diff --git a/net/proxy/single_threaded_proxy_resolver.h b/net/proxy/single_threaded_proxy_resolver.h
index 3d43309..2da6085 100644
--- a/net/proxy/single_threaded_proxy_resolver.h
+++ b/net/proxy/single_threaded_proxy_resolver.h
@@ -35,7 +35,7 @@ class SingleThreadedProxyResolver : public ProxyResolver {
ProxyInfo* results,
CompletionCallback* callback,
RequestHandle* request,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
virtual void CancelRequest(RequestHandle request);
virtual void CancelSetPacScript();
virtual void PurgeMemory();
diff --git a/net/proxy/single_threaded_proxy_resolver_unittest.cc b/net/proxy/single_threaded_proxy_resolver_unittest.cc
index 3f90c7a..ee52a77 100644
--- a/net/proxy/single_threaded_proxy_resolver_unittest.cc
+++ b/net/proxy/single_threaded_proxy_resolver_unittest.cc
@@ -4,8 +4,8 @@
#include "base/waitable_event.h"
#include "googleurl/src/gurl.h"
-#include "net/base/load_log.h"
-#include "net/base/load_log_unittest.h"
+#include "net/base/net_log.h"
+#include "net/base/net_log_unittest.h"
#include "net/base/net_errors.h"
#include "net/base/test_completion_callback.h"
#include "net/proxy/proxy_info.h"
@@ -32,7 +32,7 @@ class MockProxyResolver : public ProxyResolver {
ProxyInfo* results,
CompletionCallback* callback,
RequestHandle* request,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
if (resolve_latency_ms_)
PlatformThread::Sleep(resolve_latency_ms_);
@@ -41,8 +41,8 @@ class MockProxyResolver : public ProxyResolver {
EXPECT_TRUE(callback == NULL);
EXPECT_TRUE(request == NULL);
- // Write something into |load_log| (doesn't really have any meaning.)
- LoadLog::BeginEvent(load_log, LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE);
+ // Write something into |net_log| (doesn't really have any meaning.)
+ net_log.BeginEvent(NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE);
results->UseNamedProxy(query_url.host());
@@ -124,14 +124,14 @@ class BlockableProxyResolver : public MockProxyResolver {
ProxyInfo* results,
CompletionCallback* callback,
RequestHandle* request,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
if (should_block_) {
blocked_.Signal();
unblocked_.Wait();
}
return MockProxyResolver::GetProxyForURL(
- query_url, results, callback, request, load_log);
+ query_url, results, callback, request, net_log);
}
private:
@@ -158,10 +158,10 @@ TEST(SingleThreadedProxyResolverTest, Basic) {
// Start request 0.
TestCompletionCallback callback0;
- scoped_refptr<LoadLog> log0(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log0(CapturingNetLog::kUnbounded);
ProxyInfo results0;
rv = resolver.GetProxyForURL(
- GURL("http://request0"), &results0, &callback0, NULL, log0);
+ GURL("http://request0"), &results0, &callback0, NULL, log0.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Wait for request 0 to finish.
@@ -171,7 +171,7 @@ TEST(SingleThreadedProxyResolverTest, Basic) {
// The mock proxy resolver should have written 1 log entry. And
// on completion, this should have been copied into |log0|.
- EXPECT_EQ(1u, log0->entries().size());
+ EXPECT_EQ(1u, log0.entries().size());
// Start 3 more requests (request1 to request3).
@@ -221,9 +221,9 @@ TEST(SingleThreadedProxyResolverTest, Basic) {
EXPECT_EQ(1, mock->purge_count());
}
-// Tests that the LoadLog is updated to include the time the request was waiting
+// Tests that the NetLog is updated to include the time the request was waiting
// to be scheduled to a thread.
-TEST(SingleThreadedProxyResolverTest, UpdatesLoadLogWithThreadWait) {
+TEST(SingleThreadedProxyResolverTest, UpdatesNetLogWithThreadWait) {
BlockableProxyResolver* mock = new BlockableProxyResolver;
SingleThreadedProxyResolver resolver(mock);
@@ -236,26 +236,26 @@ TEST(SingleThreadedProxyResolverTest, UpdatesLoadLogWithThreadWait) {
ProxyResolver::RequestHandle request0;
TestCompletionCallback callback0;
ProxyInfo results0;
- scoped_refptr<LoadLog> log0(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log0(CapturingNetLog::kUnbounded);
rv = resolver.GetProxyForURL(
- GURL("http://request0"), &results0, &callback0, &request0, log0);
+ GURL("http://request0"), &results0, &callback0, &request0, log0.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Start 2 more requests (request1 and request2).
TestCompletionCallback callback1;
ProxyInfo results1;
- scoped_refptr<LoadLog> log1(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log1(CapturingNetLog::kUnbounded);
rv = resolver.GetProxyForURL(
- GURL("http://request1"), &results1, &callback1, NULL, log1);
+ GURL("http://request1"), &results1, &callback1, NULL, log1.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
ProxyResolver::RequestHandle request2;
TestCompletionCallback callback2;
ProxyInfo results2;
- scoped_refptr<LoadLog> log2(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log2(CapturingNetLog::kUnbounded);
rv = resolver.GetProxyForURL(
- GURL("http://request2"), &results2, &callback2, &request2, log2);
+ GURL("http://request2"), &results2, &callback2, &request2, log2.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
// Unblock the worker thread so the requests can continue running.
@@ -263,28 +263,32 @@ TEST(SingleThreadedProxyResolverTest, UpdatesLoadLogWithThreadWait) {
mock->Unblock();
// Check that request 0 completed as expected.
- // The LoadLog only has 1 entry (that came from the mock proxy resolver.)
+ // The NetLog only has 1 entry (that came from the mock proxy resolver.)
EXPECT_EQ(0, callback0.WaitForResult());
EXPECT_EQ("PROXY request0:80", results0.ToPacString());
- ASSERT_EQ(1u, log0->entries().size());
+ ASSERT_EQ(1u, log0.entries().size());
// Check that request 1 completed as expected.
EXPECT_EQ(1, callback1.WaitForResult());
EXPECT_EQ("PROXY request1:80", results1.ToPacString());
- ASSERT_EQ(3u, log1->entries().size());
+ ASSERT_EQ(3u, log1.entries().size());
EXPECT_TRUE(LogContainsBeginEvent(
- *log1, 0, LoadLog::TYPE_WAITING_FOR_SINGLE_PROXY_RESOLVER_THREAD));
+ log1.entries(), 0,
+ NetLog::TYPE_WAITING_FOR_SINGLE_PROXY_RESOLVER_THREAD));
EXPECT_TRUE(LogContainsEndEvent(
- *log1, 1, LoadLog::TYPE_WAITING_FOR_SINGLE_PROXY_RESOLVER_THREAD));
+ log1.entries(), 1,
+ NetLog::TYPE_WAITING_FOR_SINGLE_PROXY_RESOLVER_THREAD));
// Check that request 2 completed as expected.
EXPECT_EQ(2, callback2.WaitForResult());
EXPECT_EQ("PROXY request2:80", results2.ToPacString());
- ASSERT_EQ(3u, log2->entries().size());
+ ASSERT_EQ(3u, log2.entries().size());
EXPECT_TRUE(LogContainsBeginEvent(
- *log2, 0, LoadLog::TYPE_WAITING_FOR_SINGLE_PROXY_RESOLVER_THREAD));
+ log2.entries(), 0,
+ NetLog::TYPE_WAITING_FOR_SINGLE_PROXY_RESOLVER_THREAD));
EXPECT_TRUE(LogContainsEndEvent(
- *log2, 1, LoadLog::TYPE_WAITING_FOR_SINGLE_PROXY_RESOLVER_THREAD));
+ log2.entries(), 1,
+ NetLog::TYPE_WAITING_FOR_SINGLE_PROXY_RESOLVER_THREAD));
}
// Cancel a request which is in progress, and then cancel a request which
diff --git a/net/socket/client_socket.h b/net/socket/client_socket.h
index e696554..3005708 100644
--- a/net/socket/client_socket.h
+++ b/net/socket/client_socket.h
@@ -10,7 +10,7 @@
namespace net {
class AddressList;
-class LoadLog;
+class BoundNetLog;
class ClientSocket : public Socket {
public:
@@ -28,7 +28,8 @@ class ClientSocket : public Socket {
//
// Connect may also be called again after a call to the Disconnect method.
//
- virtual int Connect(CompletionCallback* callback, LoadLog* load_log) = 0;
+ virtual int Connect(CompletionCallback* callback,
+ const BoundNetLog& net_log) = 0;
// Called to disconnect a socket. Does nothing if the socket is already
// disconnected. After calling Disconnect it is possible to call Connect
diff --git a/net/socket/client_socket_handle.h b/net/socket/client_socket_handle.h
index bf7bf8a..782ad48 100644
--- a/net/socket/client_socket_handle.h
+++ b/net/socket/client_socket_handle.h
@@ -55,7 +55,7 @@ class ClientSocketHandle {
//
// Init may be called multiple times.
//
- // Profiling information for the request is saved to |load_log| if non-NULL.
+ // Profiling information for the request is saved to |net_log| if non-NULL.
//
template <typename SocketParams, typename PoolType>
int Init(const std::string& group_name,
@@ -63,7 +63,7 @@ class ClientSocketHandle {
RequestPriority priority,
CompletionCallback* callback,
PoolType* pool,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
// An initialized handle can be reset, which causes it to return to the
// un-initialized state. This releases the underlying socket, which in the
@@ -150,7 +150,7 @@ int ClientSocketHandle::Init(const std::string& group_name,
RequestPriority priority,
CompletionCallback* callback,
PoolType* pool,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
CHECK(!group_name.empty());
// Note that this will result in a link error if the SocketParams has not been
// registered for the PoolType via REGISTER_SOCKET_PARAMS_FOR_POOL (defined in
@@ -161,7 +161,7 @@ int ClientSocketHandle::Init(const std::string& group_name,
group_name_ = group_name;
init_time_ = base::TimeTicks::Now();
int rv = pool_->RequestSocket(
- group_name, &socket_params, priority, this, &callback_, load_log);
+ group_name, &socket_params, priority, this, &callback_, net_log);
if (rv == ERR_IO_PENDING) {
user_callback_ = callback;
} else {
diff --git a/net/socket/client_socket_pool.h b/net/socket/client_socket_pool.h
index 718b1f8..16f408b 100644
--- a/net/socket/client_socket_pool.h
+++ b/net/socket/client_socket_pool.h
@@ -47,13 +47,13 @@ class ClientSocketPool : public base::RefCounted<ClientSocketPool> {
// If ERR_IO_PENDING is returned, then the callback will be used to notify the
// client of completion.
//
- // Profiling information for the request is saved to |load_log| if non-NULL.
+ // Profiling information for the request is saved to |net_log| if non-NULL.
virtual int RequestSocket(const std::string& group_name,
const void* params,
RequestPriority priority,
ClientSocketHandle* handle,
CompletionCallback* callback,
- LoadLog* load_log) = 0;
+ const BoundNetLog& net_log) = 0;
// Called to cancel a RequestSocket call that returned ERR_IO_PENDING. The
// same handle parameter must be passed to this method as was passed to the
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc
index 65823a5..3e32cc1 100644
--- a/net/socket/client_socket_pool_base.cc
+++ b/net/socket/client_socket_pool_base.cc
@@ -11,7 +11,7 @@
#include "base/stl_util-inl.h"
#include "base/string_util.h"
#include "base/time.h"
-#include "net/base/load_log.h"
+#include "net/base/net_log.h"
#include "net/base/net_errors.h"
#include "net/socket/client_socket_handle.h"
@@ -27,9 +27,6 @@ namespace {
// some conditions. See http://crbug.com/4606.
const int kCleanupInterval = 10; // DO NOT INCREASE THIS TIMEOUT.
-// The maximum size of the ConnectJob's LoadLog.
-const int kMaxNumLoadLogEntries = 50;
-
} // namespace
namespace net {
@@ -37,11 +34,11 @@ namespace net {
ConnectJob::ConnectJob(const std::string& group_name,
base::TimeDelta timeout_duration,
Delegate* delegate,
- LoadLog* load_log)
+ const BoundNetLog& net_log)
: group_name_(group_name),
timeout_duration_(timeout_duration),
delegate_(delegate),
- load_log_(load_log) {
+ net_log_(net_log) {
DCHECK(!group_name.empty());
DCHECK(delegate);
}
@@ -50,8 +47,8 @@ ConnectJob::~ConnectJob() {
if (delegate_) {
// If the delegate was not NULLed, then NotifyDelegateOfCompletion has
// not been called yet (hence we are cancelling).
- LoadLog::AddEvent(load_log_, LoadLog::TYPE_CANCELLED);
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB);
+ net_log_.AddEvent(NetLog::TYPE_CANCELLED);
+ net_log_.EndEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB);
}
}
@@ -59,13 +56,13 @@ int ConnectJob::Connect() {
if (timeout_duration_ != base::TimeDelta())
timer_.Start(timeout_duration_, this, &ConnectJob::OnTimeout);
- LoadLog::BeginEvent(load_log_, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB);
+ net_log_.BeginEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB);
int rv = ConnectInternal();
if (rv != ERR_IO_PENDING) {
delegate_ = NULL;
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB);
+ net_log_.EndEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB);
}
return rv;
@@ -76,7 +73,7 @@ void ConnectJob::NotifyDelegateOfCompletion(int rv) {
Delegate *delegate = delegate_;
delegate_ = NULL;
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB);
+ net_log_.EndEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB);
delegate->OnConnectJobComplete(rv, this);
}
@@ -85,8 +82,7 @@ void ConnectJob::OnTimeout() {
// Make sure the socket is NULL before calling into |delegate|.
set_socket(NULL);
- LoadLog::AddEvent(load_log_,
- LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB_TIMED_OUT);
+ net_log_.AddEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_TIMED_OUT);
NotifyDelegateOfCompletion(ERR_TIMED_OUT);
}
@@ -97,9 +93,9 @@ ClientSocketPoolBaseHelper::Request::Request(
ClientSocketHandle* handle,
CompletionCallback* callback,
RequestPriority priority,
- LoadLog* load_log)
+ const BoundNetLog& net_log)
: handle_(handle), callback_(callback), priority_(priority),
- load_log_(load_log) {}
+ net_log_(net_log) {}
ClientSocketPoolBaseHelper::Request::~Request() {}
@@ -167,11 +163,11 @@ ClientSocketPoolBaseHelper::RemoveRequestFromQueue(
int ClientSocketPoolBaseHelper::RequestSocket(
const std::string& group_name,
const Request* request) {
- LoadLog::BeginEvent(request->load_log(), LoadLog::TYPE_SOCKET_POOL);
+ request->net_log().BeginEvent(NetLog::TYPE_SOCKET_POOL);
Group& group = group_map_[group_name];
int rv = RequestSocketInternal(group_name, request);
if (rv != ERR_IO_PENDING)
- LoadLog::EndEvent(request->load_log(), LoadLog::TYPE_SOCKET_POOL);
+ request->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL);
else
InsertRequestIntoQueue(request, &group.pending_requests);
return rv;
@@ -195,13 +191,9 @@ int ClientSocketPoolBaseHelper::RequestSocketInternal(
// a scan of all groups, so just flip a flag here, and do the check later.
may_have_stalled_group_ = true;
- LoadLog::AddEvent(
- request->load_log(),
- LoadLog::TYPE_SOCKET_POOL_STALLED_MAX_SOCKETS);
+ request->net_log().AddEvent(NetLog::TYPE_SOCKET_POOL_STALLED_MAX_SOCKETS);
} else {
- LoadLog::AddEvent(
- request->load_log(),
- LoadLog::TYPE_SOCKET_POOL_STALLED_MAX_SOCKETS_PER_GROUP);
+ request->net_log().AddEvent(NetLog::TYPE_SOCKET_POOL_STALLED_MAX_SOCKETS_PER_GROUP);
}
return ERR_IO_PENDING;
}
@@ -217,7 +209,7 @@ int ClientSocketPoolBaseHelper::RequestSocketInternal(
base::TimeTicks::Now() - idle_socket.start_time;
HandOutSocket(
idle_socket.socket, idle_socket.used, handle, idle_time, &group,
- request->load_log());
+ request->net_log());
return OK;
}
delete idle_socket.socket;
@@ -230,20 +222,23 @@ int ClientSocketPoolBaseHelper::RequestSocketInternal(
}
// We couldn't find a socket to reuse, so allocate and connect a new one.
- scoped_refptr<LoadLog> job_load_log = new LoadLog(kMaxNumLoadLogEntries);
+ BoundNetLog job_net_log = BoundNetLog::Make(
+ request->net_log().net_log(), NetLog::SOURCE_CONNECT_JOB);
scoped_ptr<ConnectJob> connect_job(
connect_job_factory_->NewConnectJob(group_name, *request, this,
- job_load_log));
+ job_net_log));
int rv = connect_job->Connect();
- if (rv != ERR_IO_PENDING && request->load_log())
- request->load_log()->Append(job_load_log);
+ if (rv != ERR_IO_PENDING) {
+ request->net_log().AddEventWithInteger(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID,
+ job_net_log.source().id);
+ }
if (rv == OK) {
HandOutSocket(connect_job->ReleaseSocket(), false /* not reused */,
- handle, base::TimeDelta(), &group, request->load_log());
+ handle, base::TimeDelta(), &group, request->net_log());
} else if (rv == ERR_IO_PENDING) {
// If we don't have any sockets in this group, set a timer for potentially
// creating a new one. If the SYN is lost, this backup socket may complete
@@ -252,7 +247,7 @@ int ClientSocketPoolBaseHelper::RequestSocketInternal(
group.backup_job = connect_job_factory_->NewConnectJob(group_name,
*request,
this,
- job_load_log);
+ job_net_log);
StartBackupSocketTimer(group_name);
}
@@ -296,14 +291,13 @@ void ClientSocketPoolBaseHelper::OnBackupSocketTimerFired(
// If our backup job is waiting on DNS, just reset the timer.
CHECK(group.jobs.size());
if ((*group.jobs.begin())->GetLoadState() == LOAD_STATE_RESOLVING_HOST) {
- LoadLog::AddEvent(group.backup_job->load_log(),
- LoadLog::TYPE_SOCKET_BACKUP_TIMER_EXTENDED);
+ group.backup_job->net_log().EndEvent(
+ NetLog::TYPE_SOCKET_BACKUP_TIMER_EXTENDED);
StartBackupSocketTimer(group_name);
return;
}
- LoadLog::AddEvent(group.backup_job->load_log(),
- LoadLog::TYPE_SOCKET_BACKUP_CREATED);
+ group.backup_job->net_log().AddEvent(NetLog::TYPE_SOCKET_BACKUP_CREATED);
SIMPLE_STATS_COUNTER("socket.backup_created");
int rv = group.backup_job->Connect();
if (rv == ERR_IO_PENDING) {
@@ -326,8 +320,8 @@ void ClientSocketPoolBaseHelper::CancelRequest(
for (; it != group.pending_requests.end(); ++it) {
if ((*it)->handle() == handle) {
const Request* req = RemoveRequestFromQueue(it, &group.pending_requests);
- LoadLog::AddEvent(req->load_log(), LoadLog::TYPE_CANCELLED);
- LoadLog::EndEvent(req->load_log(), LoadLog::TYPE_SOCKET_POOL);
+ req->net_log().AddEvent(NetLog::TYPE_CANCELLED);
+ req->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL);
delete req;
if (group.jobs.size() > group.pending_requests.size() + 1) {
// TODO(willchan): Cancel the job in the earliest LoadState.
@@ -553,21 +547,20 @@ void ClientSocketPoolBaseHelper::OnConnectJobComplete(
scoped_ptr<ClientSocket> socket(job->ReleaseSocket());
- scoped_refptr<LoadLog> job_load_log(job->load_log());
+ BoundNetLog job_log = job->net_log();
RemoveConnectJob(job, &group);
- LoadLog::EndEvent(job_load_log, LoadLog::TYPE_SOCKET_POOL);
-
if (result == OK) {
DCHECK(socket.get());
if (!group.pending_requests.empty()) {
scoped_ptr<const Request> r(RemoveRequestFromQueue(
group.pending_requests.begin(), &group.pending_requests));
- if (r->load_log())
- r->load_log()->Append(job_load_log);
+ r->net_log().AddEventWithInteger(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID,
+ job_log.source().id);
+ r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL);
HandOutSocket(
socket.release(), false /* unused socket */, r->handle(),
- base::TimeDelta(), &group, r->load_log());
+ base::TimeDelta(), &group, r->net_log());
r->callback()->Run(result);
} else {
AddIdleSocket(socket.release(), false /* unused socket */, &group);
@@ -578,8 +571,9 @@ void ClientSocketPoolBaseHelper::OnConnectJobComplete(
if (!group.pending_requests.empty()) {
scoped_ptr<const Request> r(RemoveRequestFromQueue(
group.pending_requests.begin(), &group.pending_requests));
- if (r->load_log())
- r->load_log()->Append(job_load_log);
+ r->net_log().AddEventWithInteger(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID,
+ job_log.source().id);
+ r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL);
r->callback()->Run(result);
}
MaybeOnAvailableSocketSlot(group_name);
@@ -640,7 +634,7 @@ void ClientSocketPoolBaseHelper::ProcessPendingRequest(
int rv = RequestSocketInternal(group_name, r.get());
if (rv != ERR_IO_PENDING) {
- LoadLog::EndEvent(r->load_log(), LoadLog::TYPE_SOCKET_POOL);
+ r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL);
RemoveRequestFromQueue(group->pending_requests.begin(),
&group->pending_requests);
r->callback()->Run(rv);
@@ -660,17 +654,16 @@ void ClientSocketPoolBaseHelper::HandOutSocket(
ClientSocketHandle* handle,
base::TimeDelta idle_time,
Group* group,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
DCHECK(socket);
handle->set_socket(socket);
handle->set_is_reused(reused);
handle->set_idle_time(idle_time);
if (reused)
- LoadLog::AddStringLiteral(load_log, "Reusing socket.");
+ net_log.AddStringLiteral("Reusing socket.");
if (idle_time != base::TimeDelta()) {
- LoadLog::AddString(
- load_log,
+ net_log.AddString(
StringPrintf("Socket sat idle for %" PRId64 " milliseconds",
idle_time.InMilliseconds()));
}
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h
index 82068c4..f6041a1 100644
--- a/net/socket/client_socket_pool_base.h
+++ b/net/socket/client_socket_pool_base.h
@@ -38,6 +38,7 @@
#include "net/base/completion_callback.h"
#include "net/base/load_states.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log.h"
#include "net/base/network_change_notifier.h"
#include "net/base/request_priority.h"
#include "net/socket/client_socket.h"
@@ -46,7 +47,6 @@
namespace net {
class ClientSocketHandle;
-class LoadLog;
// ConnectJob provides an abstract interface for "connecting" a socket.
// The connection may involve host resolution, tcp connection, ssl connection,
@@ -69,12 +69,12 @@ class ConnectJob {
ConnectJob(const std::string& group_name,
base::TimeDelta timeout_duration,
Delegate* delegate,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
virtual ~ConnectJob();
// Accessors
const std::string& group_name() const { return group_name_; }
- LoadLog* load_log() { return load_log_; }
+ const BoundNetLog& net_log() { return net_log_; }
// Releases |socket_| to the client. On connection error, this should return
// NULL.
@@ -107,7 +107,7 @@ class ConnectJob {
base::OneShotTimer<ConnectJob> timer_;
Delegate* delegate_;
scoped_ptr<ClientSocket> socket_;
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
DISALLOW_COPY_AND_ASSIGN(ConnectJob);
};
@@ -129,20 +129,20 @@ class ClientSocketPoolBaseHelper
Request(ClientSocketHandle* handle,
CompletionCallback* callback,
RequestPriority priority,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
virtual ~Request();
ClientSocketHandle* handle() const { return handle_; }
CompletionCallback* callback() const { return callback_; }
RequestPriority priority() const { return priority_; }
- LoadLog* load_log() const { return load_log_.get(); }
+ const BoundNetLog& net_log() const { return net_log_; }
private:
ClientSocketHandle* const handle_;
CompletionCallback* const callback_;
const RequestPriority priority_;
- const scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
DISALLOW_COPY_AND_ASSIGN(Request);
};
@@ -156,7 +156,7 @@ class ClientSocketPoolBaseHelper
const std::string& group_name,
const Request& request,
ConnectJob::Delegate* delegate,
- LoadLog* load_log) const = 0;
+ const BoundNetLog& net_log) const = 0;
private:
DISALLOW_COPY_AND_ASSIGN(ConnectJobFactory);
@@ -355,7 +355,7 @@ class ClientSocketPoolBaseHelper
ClientSocketHandle* handle,
base::TimeDelta time_idle,
Group* group,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
// Adds |socket| to the list of idle sockets for |group|. |used| indicates
// whether or not the socket has previously been used.
@@ -371,7 +371,7 @@ class ClientSocketPoolBaseHelper
bool ReachedMaxSocketsLimit() const;
// This is the internal implementation of RequestSocket(). It differs in that
- // it does not handle logging into LoadLog of the queueing status of
+ // it does not handle logging into NetLog of the queueing status of
// |request|.
int RequestSocketInternal(const std::string& group_name,
const Request* request);
@@ -450,9 +450,9 @@ class ClientSocketPoolBase {
CompletionCallback* callback,
RequestPriority priority,
const SocketParams& params,
- LoadLog* load_log)
+ const BoundNetLog& net_log)
: internal::ClientSocketPoolBaseHelper::Request(
- handle, callback, priority, load_log),
+ handle, callback, priority, net_log),
params_(params) {}
const SocketParams& params() const { return params_; }
@@ -470,7 +470,7 @@ class ClientSocketPoolBase {
const std::string& group_name,
const Request& request,
ConnectJob::Delegate* delegate,
- LoadLog* load_log) const = 0;
+ const BoundNetLog& net_log) const = 0;
private:
DISALLOW_COPY_AND_ASSIGN(ConnectJobFactory);
@@ -507,9 +507,9 @@ class ClientSocketPoolBase {
RequestPriority priority,
ClientSocketHandle* handle,
CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
scoped_ptr<Request> request(
- new Request(handle, callback, priority, params, load_log));
+ new Request(handle, callback, priority, params, net_log));
int rv = helper_->RequestSocket(group_name, request.get());
if (rv == ERR_IO_PENDING)
request.release();
@@ -576,10 +576,10 @@ class ClientSocketPoolBase {
const std::string& group_name,
const internal::ClientSocketPoolBaseHelper::Request& request,
ConnectJob::Delegate* delegate,
- LoadLog* load_log) const {
+ const BoundNetLog& net_log) const {
const Request* casted_request = static_cast<const Request*>(&request);
return connect_job_factory_->NewConnectJob(
- group_name, *casted_request, delegate, load_log);
+ group_name, *casted_request, delegate, net_log);
}
const scoped_ptr<ConnectJobFactory> connect_job_factory_;
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index 8ad24cf..f29ad40 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -9,9 +9,8 @@
#include "base/message_loop.h"
#include "base/platform_thread.h"
#include "base/scoped_vector.h"
-#include "net/base/load_log.h"
-#include "net/base/load_log_unittest.h"
-#include "net/base/load_log_util.h"
+#include "net/base/net_log.h"
+#include "net/base/net_log_unittest.h"
#include "net/base/net_errors.h"
#include "net/base/request_priority.h"
#include "net/base/test_completion_callback.h"
@@ -51,7 +50,7 @@ class MockClientSocket : public ClientSocket {
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, LoadLog* load_log) {
+ virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log) {
connected_ = true;
return OK;
}
@@ -116,8 +115,8 @@ class TestConnectJob : public ConnectJob {
base::TimeDelta timeout_duration,
ConnectJob::Delegate* delegate,
MockClientSocketFactory* client_socket_factory,
- LoadLog* load_log)
- : ConnectJob(group_name, timeout_duration, delegate, load_log),
+ const BoundNetLog& net_log)
+ : ConnectJob(group_name, timeout_duration, delegate, net_log),
job_type_(job_type),
client_socket_factory_(client_socket_factory),
method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
@@ -250,14 +249,14 @@ class TestConnectJobFactory
const std::string& group_name,
const TestClientSocketPoolBase::Request& request,
ConnectJob::Delegate* delegate,
- LoadLog* load_log) const {
+ const BoundNetLog& net_log) const {
return new TestConnectJob(job_type_,
group_name,
request,
timeout_duration_,
delegate,
client_socket_factory_,
- load_log);
+ net_log);
}
private:
@@ -286,9 +285,9 @@ class TestClientSocketPool : public ClientSocketPool {
net::RequestPriority priority,
ClientSocketHandle* handle,
CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
return base_.RequestSocket(
- group_name, params, priority, handle, callback, load_log);
+ group_name, params, priority, handle, callback, net_log);
}
virtual void CancelRequest(
@@ -443,9 +442,9 @@ int InitHandle(ClientSocketHandle* handle,
net::RequestPriority priority,
CompletionCallback* callback,
TestClientSocketPool* pool,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
return handle->Init<TestSocketParams, TestClientSocketPool>(
- group_name, NULL, priority, callback, pool, load_log);
+ group_name, NULL, priority, callback, pool, net_log);
}
// Even though a timeout is specified, it doesn't time out on a synchronous
@@ -469,7 +468,8 @@ TEST_F(ClientSocketPoolBaseTest, ConnectJob_NoTimeoutOnSynchronousCompletion) {
TEST_F(ClientSocketPoolBaseTest, ConnectJob_TimedOut) {
TestConnectJobDelegate delegate;
ClientSocketHandle ignored;
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+
TestClientSocketPoolBase::Request request(
&ignored, NULL, kDefaultPriority, NULL, NULL);
// Deleted by TestConnectJobDelegate.
@@ -480,19 +480,19 @@ TEST_F(ClientSocketPoolBaseTest, ConnectJob_TimedOut) {
base::TimeDelta::FromMicroseconds(1),
&delegate,
&client_socket_factory_,
- log);
+ log.bound());
ASSERT_EQ(ERR_IO_PENDING, job->Connect());
PlatformThread::Sleep(1);
EXPECT_EQ(ERR_TIMED_OUT, delegate.WaitForResult());
- EXPECT_EQ(3u, log->entries().size());
+ EXPECT_EQ(3u, log.entries().size());
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 0, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ log.entries(), 0, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
EXPECT_TRUE(LogContainsEvent(
- *log, 1, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB_TIMED_OUT,
- LoadLog::PHASE_NONE));
+ log.entries(), 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_TIMED_OUT,
+ NetLog::PHASE_NONE));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 2, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ log.entries(), 2, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
}
TEST_F(ClientSocketPoolBaseTest, BasicSynchronous) {
@@ -500,45 +500,52 @@ TEST_F(ClientSocketPoolBaseTest, BasicSynchronous) {
TestCompletionCallback callback;
ClientSocketHandle handle;
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+
EXPECT_EQ(OK, InitHandle(&handle, "a", kDefaultPriority,
- &callback, pool_.get(), log));
+ &callback, pool_.get(), log.bound()));
EXPECT_TRUE(handle.is_initialized());
EXPECT_TRUE(handle.socket());
handle.Reset();
- EXPECT_EQ(4u, log->entries().size());
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKET_POOL));
+ EXPECT_EQ(5u, log.entries().size());
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 1, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ log.entries(), 0, NetLog::TYPE_SOCKET_POOL));
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log.entries(), 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), 2, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ EXPECT_TRUE(LogContainsEvent(
+ log.entries(), 3, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID,
+ NetLog::PHASE_NONE));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 2, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB));
- EXPECT_TRUE(LogContainsEndEvent(*log, 3, LoadLog::TYPE_SOCKET_POOL));
+ log.entries(), 4, NetLog::TYPE_SOCKET_POOL));
}
TEST_F(ClientSocketPoolBaseTest, InitConnectionFailure) {
CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup);
connect_job_factory_->set_job_type(TestConnectJob::kMockFailingJob);
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+
TestSocketRequest req(&request_order_, &completion_count_);
EXPECT_EQ(ERR_CONNECTION_FAILED,
InitHandle(req.handle(), "a", kDefaultPriority, &req,
- pool_.get(), log));
+ pool_.get(), log.bound()));
- EXPECT_EQ(4u, log->entries().size());
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKET_POOL));
+ EXPECT_EQ(5u, log.entries().size());
+ EXPECT_TRUE(LogContainsBeginEvent(log.entries(), 0, NetLog::TYPE_SOCKET_POOL));
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 1, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ log.entries(), 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 2, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB));
- EXPECT_TRUE(LogContainsEndEvent(*log, 3, LoadLog::TYPE_SOCKET_POOL));
+ log.entries(), 2, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ EXPECT_TRUE(LogContainsEndEvent(log.entries(), 4, NetLog::TYPE_SOCKET_POOL));
}
TEST_F(ClientSocketPoolBaseTest, TotalLimit) {
CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup);
- // TODO(eroman): Check that the LoadLog contains this event.
+ // TODO(eroman): Check that the NetLog contains this event.
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
EXPECT_EQ(OK, StartRequest("b", kDefaultPriority));
@@ -574,7 +581,7 @@ TEST_F(ClientSocketPoolBaseTest, TotalLimit) {
TEST_F(ClientSocketPoolBaseTest, TotalLimitReachedNewGroup) {
CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup);
- // TODO(eroman): Check that the LoadLog contains this event.
+ // TODO(eroman): Check that the NetLog contains this event.
// Reach all limits: max total sockets, and max sockets per group.
EXPECT_EQ(OK, StartRequest("a", kDefaultPriority));
@@ -1111,8 +1118,8 @@ TEST_F(ClientSocketPoolBaseTest, BasicAsynchronous) {
connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob);
TestSocketRequest req(&request_order_, &completion_count_);
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- int rv = InitHandle(req.handle(), "a", LOWEST, &req, pool_.get(), log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ int rv = InitHandle(req.handle(), "a", LOWEST, &req, pool_.get(), log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", req.handle()));
EXPECT_EQ(OK, req.WaitForResult());
@@ -1120,18 +1127,19 @@ TEST_F(ClientSocketPoolBaseTest, BasicAsynchronous) {
EXPECT_TRUE(req.handle()->socket());
req.handle()->Reset();
- EXPECT_EQ(6u, log->entries().size());
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKET_POOL));
+ EXPECT_EQ(7u, log.entries().size());
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 1, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ log.entries(), 0, NetLog::TYPE_SOCKET_POOL));
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log.entries(), 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 2, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ log.entries(), 2, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
EXPECT_TRUE(LogContainsEvent(
- *log, 3, LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE));
+ log.entries(), 3, NetLog::TYPE_CANCELLED, NetLog::PHASE_NONE));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 4, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ log.entries(), 4, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 5, LoadLog::TYPE_SOCKET_POOL));
+ log.entries(), 6, NetLog::TYPE_SOCKET_POOL));
}
TEST_F(ClientSocketPoolBaseTest,
@@ -1140,25 +1148,26 @@ TEST_F(ClientSocketPoolBaseTest,
connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob);
TestSocketRequest req(&request_order_, &completion_count_);
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
EXPECT_EQ(ERR_IO_PENDING,
InitHandle(req.handle(), "a", kDefaultPriority, &req,
- pool_.get(), log));
+ pool_.get(), log.bound()));
EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", req.handle()));
EXPECT_EQ(ERR_CONNECTION_FAILED, req.WaitForResult());
- EXPECT_EQ(6u, log->entries().size());
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKET_POOL));
+ EXPECT_EQ(7u, log.entries().size());
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log.entries(), 0, NetLog::TYPE_SOCKET_POOL));
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 1, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ log.entries(), 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 2, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ log.entries(), 2, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
EXPECT_TRUE(LogContainsEvent(
- *log, 3, LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE));
+ log.entries(), 3, NetLog::TYPE_CANCELLED, NetLog::PHASE_NONE));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 4, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB));
+ log.entries(), 4, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
EXPECT_TRUE(LogContainsEndEvent(
- *log, 5, LoadLog::TYPE_SOCKET_POOL));
+ log.entries(), 6, NetLog::TYPE_SOCKET_POOL));
}
TEST_F(ClientSocketPoolBaseTest, TwoRequestsCancelOne) {
@@ -1168,44 +1177,33 @@ TEST_F(ClientSocketPoolBaseTest, TwoRequestsCancelOne) {
TestSocketRequest req(&request_order_, &completion_count_);
TestSocketRequest req2(&request_order_, &completion_count_);
- scoped_refptr<LoadLog> log1(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log1(CapturingNetLog::kUnbounded);
EXPECT_EQ(ERR_IO_PENDING,
InitHandle(req.handle(), "a", kDefaultPriority, &req,
- pool_.get(), log1));
- scoped_refptr<LoadLog> log2(new LoadLog(LoadLog::kUnbounded));
+ pool_.get(), log1.bound()));
+ CapturingBoundNetLog log2(CapturingNetLog::kUnbounded);
EXPECT_EQ(ERR_IO_PENDING,
InitHandle(req2.handle(), "a", kDefaultPriority, &req2,
- pool_.get(), log2));
+ pool_.get(), log2.bound()));
req.handle()->Reset();
- EXPECT_EQ(3u, log1->entries().size());
- EXPECT_TRUE(LogContainsBeginEvent(*log1, 0, LoadLog::TYPE_SOCKET_POOL));
+ EXPECT_EQ(4u, log1.entries().size());
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log1.entries(), 0, NetLog::TYPE_SOCKET_POOL));
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log1.entries(), 1, NetLog::TYPE_SOCKET_POOL_CONNECT_JOB));
EXPECT_TRUE(LogContainsEvent(
- *log1, 1, LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE));
- EXPECT_TRUE(LogContainsEndEvent(*log1, 2, LoadLog::TYPE_SOCKET_POOL));
+ log1.entries(), 2, NetLog::TYPE_CANCELLED, NetLog::PHASE_NONE));
+ EXPECT_TRUE(LogContainsEndEvent(log1.entries(), 3, NetLog::TYPE_SOCKET_POOL));
// At this point, request 2 is just waiting for the connect job to finish.
- EXPECT_EQ(1u, log2->entries().size());
- EXPECT_TRUE(LogContainsBeginEvent(*log2, 0, LoadLog::TYPE_SOCKET_POOL));
EXPECT_EQ(OK, req2.WaitForResult());
req2.handle()->Reset();
// Now request 2 has actually finished.
- EXPECT_EQ(6u, log2->entries().size());
- EXPECT_TRUE(LogContainsBeginEvent(*log2, 0, LoadLog::TYPE_SOCKET_POOL));
- EXPECT_TRUE(LogContainsBeginEvent(
- *log2, 1, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB));
- EXPECT_TRUE(LogContainsEndEvent(
- *log2, 2, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB));
- EXPECT_TRUE(LogContainsEvent(
- *log2, 3, LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE));
- EXPECT_TRUE(LogContainsEndEvent(
- *log2, 4, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB));
- EXPECT_TRUE(LogContainsEndEvent(
- *log2, 5, LoadLog::TYPE_SOCKET_POOL));
-
+ // TODO(eroman): Add back log expectations.
}
TEST_F(ClientSocketPoolBaseTest, CancelRequestLimitsJobs) {
@@ -1375,13 +1373,12 @@ TEST_F(ClientSocketPoolBaseTest, CleanupTimedOutIdleSockets) {
// used socket. Request it to make sure that it's used.
pool_->CleanupTimedOutIdleSockets();
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- rv = InitHandle(req.handle(), "a", LOWEST, &req, pool_.get(), log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ rv = InitHandle(req.handle(), "a", LOWEST, &req, pool_.get(), log.bound());
EXPECT_EQ(OK, rv);
EXPECT_TRUE(req.handle()->is_reused());
EXPECT_TRUE(LogContainsEntryWithType(
- *log, 1, LoadLog::Entry::TYPE_STRING_LITERAL))
- << LoadLogUtil::PrettyPrintAsEventTree(log);
+ log.entries(), 1, NetLog::Entry::TYPE_STRING_LITERAL));
}
// Make sure that we process all pending requests even when we're stalling
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index 1634106..ba0c8dc 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -83,7 +83,7 @@ MockTCPClientSocket::MockTCPClientSocket(const net::AddressList& addresses,
}
int MockTCPClientSocket::Connect(net::CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
if (connected_)
return net::OK;
connected_ = true;
@@ -252,10 +252,10 @@ void MockSSLClientSocket::GetSSLInfo(net::SSLInfo* ssl_info) {
}
int MockSSLClientSocket::Connect(net::CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
ConnectCallback* connect_callback = new ConnectCallback(
this, callback, data_->connect.result);
- int rv = transport_->Connect(connect_callback, load_log);
+ int rv = transport_->Connect(connect_callback, net_log);
if (rv == net::OK) {
delete connect_callback;
if (data_->connect.async) {
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h
index e2f3504..69b78da 100644
--- a/net/socket/socket_test_util.h
+++ b/net/socket/socket_test_util.h
@@ -35,8 +35,8 @@ enum {
ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ = -10000,
};
+class BoundNetLog;
class ClientSocket;
-class LoadLog;
class MockClientSocket;
class SSLClientSocket;
@@ -272,7 +272,8 @@ class MockClientSocket : public net::SSLClientSocket {
MockClientSocket();
// ClientSocket methods:
- virtual int Connect(net::CompletionCallback* callback, LoadLog* load_log) = 0;
+ virtual int Connect(net::CompletionCallback* callback,
+ const BoundNetLog& net_log) = 0;
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
@@ -316,7 +317,7 @@ class MockTCPClientSocket : public MockClientSocket {
// ClientSocket methods:
virtual int Connect(net::CompletionCallback* callback,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const { return IsConnected(); }
@@ -362,7 +363,8 @@ class MockSSLClientSocket : public MockClientSocket {
virtual void GetSSLInfo(net::SSLInfo* ssl_info);
- virtual int Connect(net::CompletionCallback* callback, LoadLog* load_log);
+ virtual int Connect(net::CompletionCallback* callback,
+ const BoundNetLog& net_log);
virtual void Disconnect();
// Socket methods:
diff --git a/net/socket/socks5_client_socket.cc b/net/socket/socks5_client_socket.cc
index fbaf77c..0e29e2c 100644
--- a/net/socket/socks5_client_socket.cc
+++ b/net/socket/socks5_client_socket.cc
@@ -10,7 +10,7 @@
#include "base/string_util.h"
#include "base/trace_event.h"
#include "net/base/io_buffer.h"
-#include "net/base/load_log.h"
+#include "net/base/net_log.h"
#include "net/base/net_util.h"
#include "net/base/sys_addrinfo.h"
@@ -65,7 +65,7 @@ SOCKS5ClientSocket::~SOCKS5ClientSocket() {
}
int SOCKS5ClientSocket::Connect(CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
DCHECK(transport_.get());
DCHECK(transport_->IsConnected());
DCHECK_EQ(STATE_NONE, next_state_);
@@ -75,8 +75,8 @@ int SOCKS5ClientSocket::Connect(CompletionCallback* callback,
if (completed_handshake_)
return OK;
- load_log_ = load_log;
- LoadLog::BeginEvent(load_log, LoadLog::TYPE_SOCKS5_CONNECT);
+ net_log_ = net_log;
+ net_log.BeginEvent(NetLog::TYPE_SOCKS5_CONNECT);
next_state_ = STATE_GREET_WRITE;
buffer_.clear();
@@ -85,8 +85,8 @@ int SOCKS5ClientSocket::Connect(CompletionCallback* callback,
if (rv == ERR_IO_PENDING) {
user_callback_ = callback;
} else {
- LoadLog::EndEvent(load_log, LoadLog::TYPE_SOCKS5_CONNECT);
- load_log_ = NULL;
+ net_log.EndEvent(NetLog::TYPE_SOCKS5_CONNECT);
+ net_log_ = BoundNetLog();
}
return rv;
}
@@ -99,7 +99,7 @@ void SOCKS5ClientSocket::Disconnect() {
// These are the states initialized by Connect().
next_state_ = STATE_NONE;
user_callback_ = NULL;
- load_log_ = NULL;
+ net_log_ = BoundNetLog();
}
bool SOCKS5ClientSocket::IsConnected() const {
@@ -155,8 +155,8 @@ void SOCKS5ClientSocket::OnIOComplete(int result) {
DCHECK_NE(STATE_NONE, next_state_);
int rv = DoLoop(result);
if (rv != ERR_IO_PENDING) {
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_SOCKS5_CONNECT);
- load_log_ = NULL;
+ net_log_.EndEvent(NetLog::TYPE_SOCKS5_CONNECT);
+ net_log_ = BoundNetLog();
DoCallback(rv);
}
}
@@ -170,39 +170,39 @@ int SOCKS5ClientSocket::DoLoop(int last_io_result) {
switch (state) {
case STATE_GREET_WRITE:
DCHECK_EQ(OK, rv);
- LoadLog::BeginEvent(load_log_, LoadLog::TYPE_SOCKS5_GREET_WRITE);
+ net_log_.BeginEvent(NetLog::TYPE_SOCKS5_GREET_WRITE);
rv = DoGreetWrite();
break;
case STATE_GREET_WRITE_COMPLETE:
rv = DoGreetWriteComplete(rv);
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_SOCKS5_GREET_WRITE);
+ net_log_.EndEvent(NetLog::TYPE_SOCKS5_GREET_WRITE);
break;
case STATE_GREET_READ:
DCHECK_EQ(OK, rv);
- LoadLog::BeginEvent(load_log_, LoadLog::TYPE_SOCKS5_GREET_READ);
+ net_log_.BeginEvent(NetLog::TYPE_SOCKS5_GREET_READ);
rv = DoGreetRead();
break;
case STATE_GREET_READ_COMPLETE:
rv = DoGreetReadComplete(rv);
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_SOCKS5_GREET_READ);
+ net_log_.EndEvent(NetLog::TYPE_SOCKS5_GREET_READ);
break;
case STATE_HANDSHAKE_WRITE:
DCHECK_EQ(OK, rv);
- LoadLog::BeginEvent(load_log_, LoadLog::TYPE_SOCKS5_HANDSHAKE_WRITE);
+ net_log_.BeginEvent(NetLog::TYPE_SOCKS5_HANDSHAKE_WRITE);
rv = DoHandshakeWrite();
break;
case STATE_HANDSHAKE_WRITE_COMPLETE:
rv = DoHandshakeWriteComplete(rv);
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_SOCKS5_HANDSHAKE_WRITE);
+ net_log_.EndEvent(NetLog::TYPE_SOCKS5_HANDSHAKE_WRITE);
break;
case STATE_HANDSHAKE_READ:
DCHECK_EQ(OK, rv);
- LoadLog::BeginEvent(load_log_, LoadLog::TYPE_SOCKS5_HANDSHAKE_READ);
+ net_log_.BeginEvent(NetLog::TYPE_SOCKS5_HANDSHAKE_READ);
rv = DoHandshakeRead();
break;
case STATE_HANDSHAKE_READ_COMPLETE:
rv = DoHandshakeReadComplete(rv);
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_SOCKS5_HANDSHAKE_READ);
+ net_log_.EndEvent(NetLog::TYPE_SOCKS5_HANDSHAKE_READ);
break;
default:
NOTREACHED() << "bad state";
@@ -220,8 +220,7 @@ int SOCKS5ClientSocket::DoGreetWrite() {
// Since we only have 1 byte to send the hostname length in, if the
// URL has a hostname longer than 255 characters we can't send it.
if (0xFF < host_request_info_.hostname().size()) {
- LoadLog::AddStringLiteral(load_log_,
- "Failed sending request because hostname is "
+ net_log_.AddStringLiteral("Failed sending request because hostname is "
"longer than 255 characters");
return ERR_SOCKS_CONNECTION_FAILED;
}
@@ -267,8 +266,8 @@ int SOCKS5ClientSocket::DoGreetReadComplete(int result) {
return result;
if (result == 0) {
- LoadLog::AddStringLiteral(
- load_log_, "Connection unexpected closed while reading greeting.");
+ net_log_.AddStringLiteral(
+ "Connection unexpected closed while reading greeting.");
return ERR_SOCKS_CONNECTION_FAILED;
}
@@ -281,14 +280,14 @@ int SOCKS5ClientSocket::DoGreetReadComplete(int result) {
// Got the greet data.
if (buffer_[0] != kSOCKS5Version) {
- LoadLog::AddStringLiteral(load_log_, "Unexpected SOCKS version");
- LoadLog::AddString(load_log_, StringPrintf(
+ net_log_.AddStringLiteral("Unexpected SOCKS version");
+ net_log_.AddString(StringPrintf(
"buffer_[0] = 0x%x", static_cast<int>(buffer_[0])));
return ERR_SOCKS_CONNECTION_FAILED;
}
if (buffer_[1] != 0x00) {
- LoadLog::AddStringLiteral(load_log_, "Unexpected authentication method");
- LoadLog::AddString(load_log_, StringPrintf(
+ net_log_.AddStringLiteral("Unexpected authentication method");
+ net_log_.AddString(StringPrintf(
"buffer_[1] = 0x%x", static_cast<int>(buffer_[1])));
return ERR_SOCKS_CONNECTION_FAILED;
}
@@ -378,8 +377,8 @@ int SOCKS5ClientSocket::DoHandshakeReadComplete(int result) {
// The underlying socket closed unexpectedly.
if (result == 0) {
- LoadLog::AddStringLiteral(
- load_log_, "Connection unexpected closed while reading handshake.");
+ net_log_.AddStringLiteral(
+ "Connection unexpected closed while reading handshake.");
return ERR_SOCKS_CONNECTION_FAILED;
}
@@ -390,21 +389,20 @@ int SOCKS5ClientSocket::DoHandshakeReadComplete(int result) {
// and accordingly increase them
if (bytes_received_ == kReadHeaderSize) {
if (buffer_[0] != kSOCKS5Version || buffer_[2] != kNullByte) {
- LoadLog::AddStringLiteral(load_log_, "Unexpected SOCKS version.");
- LoadLog::AddString(load_log_, StringPrintf(
+ net_log_.AddStringLiteral("Unexpected SOCKS version.");
+ net_log_.AddString(StringPrintf(
"buffer_[0] = 0x%x; buffer_[2] = 0x%x",
static_cast<int>(buffer_[0]),
static_cast<int>(buffer_[2])));
return ERR_SOCKS_CONNECTION_FAILED;
}
if (buffer_[1] != 0x00) {
- LoadLog::AddStringLiteral(load_log_,
- "SOCKS server returned a failure code:");
+ net_log_.AddStringLiteral("SOCKS server returned a failure code:");
const char* error_string = MapSOCKSReplyToErrorString(buffer_[1]);
if (error_string) {
- LoadLog::AddStringLiteral(load_log_, error_string);
+ net_log_.AddStringLiteral(error_string);
} else {
- LoadLog::AddString(load_log_, StringPrintf(
+ net_log_.AddString(StringPrintf(
"buffer_[1] = 0x%x", static_cast<int>(buffer_[1])));
}
return ERR_SOCKS_CONNECTION_FAILED;
@@ -424,8 +422,8 @@ int SOCKS5ClientSocket::DoHandshakeReadComplete(int result) {
else if (address_type == kEndPointResolvedIPv6)
read_header_size += sizeof(struct in6_addr) - 1;
else {
- LoadLog::AddStringLiteral(load_log_, "Unknown address type in response");
- LoadLog::AddString(load_log_, StringPrintf(
+ net_log_.AddStringLiteral("Unknown address type in response");
+ net_log_.AddString(StringPrintf(
"buffer_[3] = 0x%x", static_cast<int>(buffer_[3])));
return ERR_SOCKS_CONNECTION_FAILED;
}
diff --git a/net/socket/socks5_client_socket.h b/net/socket/socks5_client_socket.h
index 629180a..ae3ef76 100644
--- a/net/socket/socks5_client_socket.h
+++ b/net/socket/socks5_client_socket.h
@@ -15,12 +15,13 @@
#include "net/base/completion_callback.h"
#include "net/base/host_resolver.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log.h"
#include "net/socket/client_socket.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
namespace net {
-class LoadLog;
+class BoundNetLog;
// This ClientSocket is used to setup a SOCKSv5 handshake with a socks proxy.
// Currently no SOCKSv5 authentication is supported.
@@ -44,7 +45,7 @@ class SOCKS5ClientSocket : public ClientSocket {
// ClientSocket methods:
// Does the SOCKS handshake and completes the protocol.
- virtual int Connect(CompletionCallback* callback, LoadLog* load_log);
+ virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
@@ -133,7 +134,7 @@ class SOCKS5ClientSocket : public ClientSocket {
HostResolver::RequestInfo host_request_info_;
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
DISALLOW_COPY_AND_ASSIGN(SOCKS5ClientSocket);
};
diff --git a/net/socket/socks5_client_socket_unittest.cc b/net/socket/socks5_client_socket_unittest.cc
index 75d0619..d15676c 100644
--- a/net/socket/socks5_client_socket_unittest.cc
+++ b/net/socket/socks5_client_socket_unittest.cc
@@ -8,8 +8,8 @@
#include <map>
#include "net/base/address_list.h"
-#include "net/base/load_log.h"
-#include "net/base/load_log_unittest.h"
+#include "net/base/net_log.h"
+#include "net/base/net_log_unittest.h"
#include "net/base/mock_host_resolver.h"
#include "net/base/sys_addrinfo.h"
#include "net/base/test_completion_callback.h"
@@ -128,17 +128,17 @@ TEST_F(SOCKS5ClientSocketTest, CompleteHandshake) {
EXPECT_TRUE(tcp_sock_->IsConnected());
EXPECT_FALSE(user_sock_->IsConnected());
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- int rv = user_sock_->Connect(&callback_, log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ int rv = user_sock_->Connect(&callback_, log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(user_sock_->IsConnected());
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsBeginEvent(log.entries(), 0, NetLog::TYPE_SOCKS5_CONNECT));
rv = callback_.WaitForResult();
EXPECT_EQ(OK, rv);
EXPECT_TRUE(user_sock_->IsConnected());
- EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(log.entries(), -1, NetLog::TYPE_SOCKS5_CONNECT));
scoped_refptr<IOBuffer> buffer = new IOBuffer(payload_write.size());
memcpy(buffer->data(), payload_write.data(), payload_write.size());
@@ -245,14 +245,14 @@ TEST_F(SOCKS5ClientSocketTest, PartialReadWrites) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
hostname, 80));
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- int rv = user_sock_->Connect(&callback_, log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ int rv = user_sock_->Connect(&callback_, log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsBeginEvent(log.entries(), 0, NetLog::TYPE_SOCKS5_CONNECT));
rv = callback_.WaitForResult();
EXPECT_EQ(OK, rv);
EXPECT_TRUE(user_sock_->IsConnected());
- EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(log.entries(), -1, NetLog::TYPE_SOCKS5_CONNECT));
}
// Test for partial greet response read
@@ -269,14 +269,14 @@ TEST_F(SOCKS5ClientSocketTest, PartialReadWrites) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
hostname, 80));
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- int rv = user_sock_->Connect(&callback_, log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ int rv = user_sock_->Connect(&callback_, log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsBeginEvent(log.entries(), 0, NetLog::TYPE_SOCKS5_CONNECT));
rv = callback_.WaitForResult();
EXPECT_EQ(OK, rv);
EXPECT_TRUE(user_sock_->IsConnected());
- EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(log.entries(), -1, NetLog::TYPE_SOCKS5_CONNECT));
}
// Test for partial handshake request write.
@@ -294,14 +294,14 @@ TEST_F(SOCKS5ClientSocketTest, PartialReadWrites) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
hostname, 80));
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- int rv = user_sock_->Connect(&callback_, log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ int rv = user_sock_->Connect(&callback_, log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsBeginEvent(log.entries(), 0, NetLog::TYPE_SOCKS5_CONNECT));
rv = callback_.WaitForResult();
EXPECT_EQ(OK, rv);
EXPECT_TRUE(user_sock_->IsConnected());
- EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(log.entries(), -1, NetLog::TYPE_SOCKS5_CONNECT));
}
// Test for partial handshake response read
@@ -321,14 +321,14 @@ TEST_F(SOCKS5ClientSocketTest, PartialReadWrites) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
hostname, 80));
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- int rv = user_sock_->Connect(&callback_, log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ int rv = user_sock_->Connect(&callback_, log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsBeginEvent(log.entries(), 0, NetLog::TYPE_SOCKS5_CONNECT));
rv = callback_.WaitForResult();
EXPECT_EQ(OK, rv);
EXPECT_TRUE(user_sock_->IsConnected());
- EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS5_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(log.entries(), -1, NetLog::TYPE_SOCKS5_CONNECT));
}
}
diff --git a/net/socket/socks_client_socket.cc b/net/socket/socks_client_socket.cc
index a9135d2..c92189c 100644
--- a/net/socket/socks_client_socket.cc
+++ b/net/socket/socks_client_socket.cc
@@ -8,7 +8,7 @@
#include "base/compiler_specific.h"
#include "base/trace_event.h"
#include "net/base/io_buffer.h"
-#include "net/base/load_log.h"
+#include "net/base/net_log.h"
#include "net/base/net_util.h"
#include "net/base/sys_addrinfo.h"
@@ -80,7 +80,7 @@ SOCKSClientSocket::~SOCKSClientSocket() {
}
int SOCKSClientSocket::Connect(CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
DCHECK(transport_.get());
DCHECK(transport_->IsConnected());
DCHECK_EQ(STATE_NONE, next_state_);
@@ -91,16 +91,16 @@ int SOCKSClientSocket::Connect(CompletionCallback* callback,
return OK;
next_state_ = STATE_RESOLVE_HOST;
- load_log_ = load_log;
+ net_log_ = net_log;
- LoadLog::BeginEvent(load_log, LoadLog::TYPE_SOCKS_CONNECT);
+ net_log.BeginEvent(NetLog::TYPE_SOCKS_CONNECT);
int rv = DoLoop(OK);
if (rv == ERR_IO_PENDING) {
user_callback_ = callback;
} else {
- LoadLog::EndEvent(load_log, LoadLog::TYPE_SOCKS_CONNECT);
- load_log_ = NULL;
+ net_log.EndEvent(NetLog::TYPE_SOCKS_CONNECT);
+ net_log_ = BoundNetLog();
}
return rv;
}
@@ -114,7 +114,7 @@ void SOCKSClientSocket::Disconnect() {
// These are the states initialized by Connect().
next_state_ = STATE_NONE;
user_callback_ = NULL;
- load_log_ = NULL;
+ net_log_ = BoundNetLog();
}
bool SOCKSClientSocket::IsConnected() const {
@@ -171,8 +171,8 @@ void SOCKSClientSocket::OnIOComplete(int result) {
DCHECK_NE(STATE_NONE, next_state_);
int rv = DoLoop(result);
if (rv != ERR_IO_PENDING) {
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_SOCKS_CONNECT);
- load_log_ = NULL;
+ net_log_.EndEvent(NetLog::TYPE_SOCKS_CONNECT);
+ net_log_ = BoundNetLog();
DoCallback(rv);
}
}
@@ -219,7 +219,7 @@ int SOCKSClientSocket::DoResolveHost() {
next_state_ = STATE_RESOLVE_HOST_COMPLETE;
return host_resolver_.Resolve(
- host_request_info_, &addresses_, &io_callback_, load_log_);
+ host_request_info_, &addresses_, &io_callback_, net_log_);
}
int SOCKSClientSocket::DoResolveHostComplete(int result) {
@@ -356,7 +356,7 @@ int SOCKSClientSocket::DoHandshakeReadComplete(int result) {
return ERR_CONNECTION_CLOSED;
if (bytes_received_ + result > kReadHeaderSize) {
- // TODO(eroman): Describe failure in LoadLog.
+ // TODO(eroman): Describe failure in NetLog.
return ERR_SOCKS_CONNECTION_FAILED;
}
diff --git a/net/socket/socks_client_socket.h b/net/socket/socks_client_socket.h
index 7dc998a..943c6c0 100644
--- a/net/socket/socks_client_socket.h
+++ b/net/socket/socks_client_socket.h
@@ -15,12 +15,13 @@
#include "net/base/completion_callback.h"
#include "net/base/host_resolver.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log.h"
#include "net/socket/client_socket.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
namespace net {
-class LoadLog;
+class BoundNetLog;
// The SOCKS client socket implementation
class SOCKSClientSocket : public ClientSocket {
@@ -40,7 +41,7 @@ class SOCKSClientSocket : public ClientSocket {
// ClientSocket methods:
// Does the SOCKS handshake and completes the protocol.
- virtual int Connect(CompletionCallback* callback, LoadLog* load_log);
+ virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
@@ -125,7 +126,7 @@ class SOCKSClientSocket : public ClientSocket {
AddressList addresses_;
HostResolver::RequestInfo host_request_info_;
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocket);
};
diff --git a/net/socket/socks_client_socket_unittest.cc b/net/socket/socks_client_socket_unittest.cc
index fb1ad82..ef11107 100644
--- a/net/socket/socks_client_socket_unittest.cc
+++ b/net/socket/socks_client_socket_unittest.cc
@@ -5,8 +5,8 @@
#include "net/socket/socks_client_socket.h"
#include "net/base/address_list.h"
-#include "net/base/load_log.h"
-#include "net/base/load_log_unittest.h"
+#include "net/base/net_log.h"
+#include "net/base/net_log_unittest.h"
#include "net/base/mock_host_resolver.h"
#include "net/base/test_completion_callback.h"
#include "net/base/winsock_init.h"
@@ -92,7 +92,7 @@ class HangingHostResolver : public HostResolver {
AddressList* addresses,
CompletionCallback* callback,
RequestHandle* out_req,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
EXPECT_FALSE(HasOutstandingRequest());
outstanding_request_ = reinterpret_cast<RequestHandle>(1);
*out_req = outstanding_request_;
@@ -138,18 +138,19 @@ TEST_F(SOCKSClientSocketTest, CompleteHandshake) {
EXPECT_TRUE(tcp_sock_->IsConnected());
EXPECT_FALSE(user_sock_->IsConnected());
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- int rv = user_sock_->Connect(&callback_, log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ int rv = user_sock_->Connect(&callback_, log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_TRUE(
- LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS_CONNECT));
+ LogContainsBeginEvent(log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT));
EXPECT_FALSE(user_sock_->IsConnected());
rv = callback_.WaitForResult();
EXPECT_EQ(OK, rv);
EXPECT_TRUE(user_sock_->IsConnected());
EXPECT_EQ(SOCKSClientSocket::kSOCKS4, user_sock_->socks_version_);
- EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), -1, NetLog::TYPE_SOCKS_CONNECT));
scoped_refptr<IOBuffer> buffer = new IOBuffer(payload_write.size());
memcpy(buffer->data(), payload_write.data(), payload_write.size());
@@ -200,16 +201,18 @@ TEST_F(SOCKSClientSocketTest, HandshakeFailures) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
host_resolver_, "localhost", 80));
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- int rv = user_sock_->Connect(&callback_, log);
+ int rv = user_sock_->Connect(&callback_, log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS_CONNECT));
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT));
rv = callback_.WaitForResult();
EXPECT_EQ(tests[i].fail_code, rv);
EXPECT_FALSE(user_sock_->IsConnected());
EXPECT_TRUE(tcp_sock_->IsConnected());
- EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), -1, NetLog::TYPE_SOCKS_CONNECT));
}
}
@@ -228,16 +231,18 @@ TEST_F(SOCKSClientSocketTest, PartialServerReads) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
host_resolver_, "localhost", 80));
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- int rv = user_sock_->Connect(&callback_, log);
+
+ int rv = user_sock_->Connect(&callback_, log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_TRUE(LogContainsBeginEvent(
- *log, 0, LoadLog::TYPE_SOCKS_CONNECT));
+ log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT));
rv = callback_.WaitForResult();
EXPECT_EQ(OK, rv);
EXPECT_TRUE(user_sock_->IsConnected());
- EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), -1, NetLog::TYPE_SOCKS_CONNECT));
}
// Tests scenario when the client sends the handshake request in
@@ -259,15 +264,17 @@ TEST_F(SOCKSClientSocketTest, PartialClientWrites) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
host_resolver_, "localhost", 80));
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- int rv = user_sock_->Connect(&callback_, log);
+ int rv = user_sock_->Connect(&callback_, log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS_CONNECT));
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT));
rv = callback_.WaitForResult();
EXPECT_EQ(OK, rv);
EXPECT_TRUE(user_sock_->IsConnected());
- EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), -1, NetLog::TYPE_SOCKS_CONNECT));
}
// Tests the case when the server sends a smaller sized handshake data
@@ -283,15 +290,18 @@ TEST_F(SOCKSClientSocketTest, FailedSocketRead) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
host_resolver_, "localhost", 80));
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+
- int rv = user_sock_->Connect(&callback_, log);
+ int rv = user_sock_->Connect(&callback_, log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS_CONNECT));
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT));
rv = callback_.WaitForResult();
EXPECT_EQ(ERR_CONNECTION_CLOSED, rv);
EXPECT_FALSE(user_sock_->IsConnected());
- EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), -1, NetLog::TYPE_SOCKS_CONNECT));
}
// Tries to connect to an unknown DNS and on failure should revert to SOCKS4A.
@@ -312,16 +322,18 @@ TEST_F(SOCKSClientSocketTest, SOCKS4AFailedDNS) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
host_resolver_, hostname, 80));
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- int rv = user_sock_->Connect(&callback_, log);
+ int rv = user_sock_->Connect(&callback_, log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS_CONNECT));
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT));
rv = callback_.WaitForResult();
EXPECT_EQ(OK, rv);
EXPECT_TRUE(user_sock_->IsConnected());
EXPECT_EQ(SOCKSClientSocket::kSOCKS4a, user_sock_->socks_version_);
- EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), -1, NetLog::TYPE_SOCKS_CONNECT));
}
// Tries to connect to a domain that resolves to IPv6.
@@ -343,16 +355,18 @@ TEST_F(SOCKSClientSocketTest, SOCKS4AIfDomainInIPv6) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
host_resolver_, hostname, 80));
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- int rv = user_sock_->Connect(&callback_, log);
+ int rv = user_sock_->Connect(&callback_, log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS_CONNECT));
+ EXPECT_TRUE(LogContainsBeginEvent(
+ log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT));
rv = callback_.WaitForResult();
EXPECT_EQ(OK, rv);
EXPECT_TRUE(user_sock_->IsConnected());
EXPECT_EQ(SOCKSClientSocket::kSOCKS4a, user_sock_->socks_version_);
- EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS_CONNECT));
+ EXPECT_TRUE(LogContainsEndEvent(
+ log.entries(), -1, NetLog::TYPE_SOCKS_CONNECT));
}
// Calls Disconnect() while a host resolve is in progress. The outstanding host
diff --git a/net/socket/ssl_client_socket_mac.cc b/net/socket/ssl_client_socket_mac.cc
index ebb31f2..0cc34c2 100644
--- a/net/socket/ssl_client_socket_mac.cc
+++ b/net/socket/ssl_client_socket_mac.cc
@@ -15,8 +15,8 @@
#include "net/base/address_list.h"
#include "net/base/cert_verifier.h"
#include "net/base/io_buffer.h"
-#include "net/base/load_log.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log.h"
#include "net/base/ssl_cert_request_info.h"
#include "net/base/ssl_info.h"
@@ -518,26 +518,26 @@ SSLClientSocketMac::~SSLClientSocketMac() {
}
int SSLClientSocketMac::Connect(CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
DCHECK(transport_.get());
DCHECK(next_handshake_state_ == STATE_NONE);
DCHECK(!user_connect_callback_);
- LoadLog::BeginEvent(load_log, LoadLog::TYPE_SSL_CONNECT);
+ net_log.BeginEvent(NetLog::TYPE_SSL_CONNECT);
int rv = InitializeSSLContext();
if (rv != OK) {
- LoadLog::EndEvent(load_log, LoadLog::TYPE_SSL_CONNECT);
+ net_log.EndEvent(NetLog::TYPE_SSL_CONNECT);
return rv;
}
next_handshake_state_ = STATE_HANDSHAKE_START;
rv = DoHandshakeLoop(OK);
if (rv == ERR_IO_PENDING) {
- load_log_ = load_log;
+ net_log_ = net_log;
user_connect_callback_ = callback;
} else {
- LoadLog::EndEvent(load_log, LoadLog::TYPE_SSL_CONNECT);
+ net_log.EndEvent(NetLog::TYPE_SSL_CONNECT);
}
return rv;
}
@@ -816,8 +816,8 @@ void SSLClientSocketMac::OnHandshakeIOComplete(int result) {
DCHECK(next_handshake_state_ != STATE_NONE);
int rv = DoHandshakeLoop(result);
if (rv != ERR_IO_PENDING) {
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_SSL_CONNECT);
- load_log_ = NULL;
+ net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
+ net_log_ = BoundNetLog();
DoConnectCallback(rv);
}
}
@@ -833,8 +833,8 @@ void SSLClientSocketMac::OnTransportReadComplete(int result) {
if (next_handshake_state_ != STATE_NONE) {
int rv = DoHandshakeLoop(result);
if (rv != ERR_IO_PENDING) {
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_SSL_CONNECT);
- load_log_ = NULL;
+ net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
+ net_log_ = BoundNetLog();
DoConnectCallback(rv);
}
return;
diff --git a/net/socket/ssl_client_socket_mac.h b/net/socket/ssl_client_socket_mac.h
index 3e6f97e..3e649ff 100644
--- a/net/socket/ssl_client_socket_mac.h
+++ b/net/socket/ssl_client_socket_mac.h
@@ -13,13 +13,13 @@
#include "base/scoped_ptr.h"
#include "net/base/cert_verify_result.h"
#include "net/base/completion_callback.h"
+#include "net/base/net_log.h"
#include "net/base/ssl_config_service.h"
#include "net/socket/ssl_client_socket.h"
namespace net {
class CertVerifier;
-class LoadLog;
// An SSL client socket implemented with Secure Transport.
class SSLClientSocketMac : public SSLClientSocket {
@@ -39,7 +39,7 @@ class SSLClientSocketMac : public SSLClientSocket {
virtual NextProtoStatus GetNextProto(std::string* proto);
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, LoadLog* load_log);
+ virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
@@ -127,7 +127,7 @@ class SSLClientSocketMac : public SSLClientSocket {
scoped_refptr<IOBuffer> read_io_buf_;
scoped_refptr<IOBuffer> write_io_buf_;
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
};
} // namespace net
diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc
index cfd88c0..a9c405d 100644
--- a/net/socket/ssl_client_socket_nss.cc
+++ b/net/socket/ssl_client_socket_nss.cc
@@ -67,7 +67,7 @@
#include "net/base/address_list.h"
#include "net/base/cert_verifier.h"
#include "net/base/io_buffer.h"
-#include "net/base/load_log.h"
+#include "net/base/net_log.h"
#include "net/base/net_errors.h"
#include "net/base/ssl_cert_request_info.h"
#include "net/base/ssl_info.h"
@@ -271,7 +271,7 @@ int SSLClientSocketNSS::Init() {
}
int SSLClientSocketNSS::Connect(CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
EnterFunction("");
DCHECK(transport_.get());
DCHECK(next_handshake_state_ == STATE_NONE);
@@ -281,7 +281,7 @@ int SSLClientSocketNSS::Connect(CompletionCallback* callback,
DCHECK(!user_read_buf_);
DCHECK(!user_write_buf_);
- LoadLog::BeginEvent(load_log, LoadLog::TYPE_SSL_CONNECT);
+ net_log.BeginEvent(NetLog::TYPE_SSL_CONNECT);
if (Init() != OK) {
NOTREACHED() << "Couldn't initialize nss";
@@ -289,7 +289,7 @@ int SSLClientSocketNSS::Connect(CompletionCallback* callback,
int rv = InitializeSSLOptions();
if (rv != OK) {
- LoadLog::EndEvent(load_log, LoadLog::TYPE_SSL_CONNECT);
+ net_log.EndEvent(NetLog::TYPE_SSL_CONNECT);
return rv;
}
@@ -297,9 +297,9 @@ int SSLClientSocketNSS::Connect(CompletionCallback* callback,
rv = DoHandshakeLoop(OK);
if (rv == ERR_IO_PENDING) {
user_connect_callback_ = callback;
- load_log_ = load_log;
+ net_log_ = net_log;
} else {
- LoadLog::EndEvent(load_log, LoadLog::TYPE_SSL_CONNECT);
+ net_log.EndEvent(NetLog::TYPE_SSL_CONNECT);
}
LeaveFunction("");
@@ -791,8 +791,8 @@ void SSLClientSocketNSS::OnHandshakeIOComplete(int result) {
EnterFunction(result);
int rv = DoHandshakeLoop(result);
if (rv != ERR_IO_PENDING) {
- LoadLog::EndEvent(load_log_, net::LoadLog::TYPE_SSL_CONNECT);
- load_log_ = NULL;
+ net_log_.EndEvent(net::NetLog::TYPE_SSL_CONNECT);
+ net_log_ = BoundNetLog();
DoConnectCallback(rv);
}
LeaveFunction("");
diff --git a/net/socket/ssl_client_socket_nss.h b/net/socket/ssl_client_socket_nss.h
index a315586..7cac7fb 100644
--- a/net/socket/ssl_client_socket_nss.h
+++ b/net/socket/ssl_client_socket_nss.h
@@ -16,14 +16,15 @@
#include "base/scoped_ptr.h"
#include "net/base/cert_verify_result.h"
#include "net/base/completion_callback.h"
+#include "net/base/net_log.h"
#include "net/base/nss_memio.h"
#include "net/base/ssl_config_service.h"
#include "net/socket/ssl_client_socket.h"
namespace net {
+class BoundNetLog;
class CertVerifier;
-class LoadLog;
class X509Certificate;
// An SSL client socket implemented with Mozilla NSS.
@@ -44,7 +45,7 @@ class SSLClientSocketNSS : public SSLClientSocket {
virtual NextProtoStatus GetNextProto(std::string* proto);
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, LoadLog* load_log);
+ virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
@@ -154,7 +155,7 @@ class SSLClientSocketNSS : public SSLClientSocket {
// Buffers for the network end of the SSL state machine
memio_Private* nss_bufs_;
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
#if defined(OS_WIN)
// A CryptoAPI in-memory certificate store. We use it for two purposes:
diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc
index f44f1ab..4984fc7 100644
--- a/net/socket/ssl_client_socket_unittest.cc
+++ b/net/socket/ssl_client_socket_unittest.cc
@@ -7,8 +7,8 @@
#include "net/base/address_list.h"
#include "net/base/host_resolver.h"
#include "net/base/io_buffer.h"
-#include "net/base/load_log.h"
-#include "net/base/load_log_unittest.h"
+#include "net/base/net_log.h"
+#include "net/base/net_log_unittest.h"
#include "net/base/net_errors.h"
#include "net/base/ssl_config_service.h"
#include "net/base/test_completion_callback.h"
@@ -80,15 +80,15 @@ TEST_F(SSLClientSocketTest, Connect) {
EXPECT_FALSE(sock->IsConnected());
- scoped_refptr<net::LoadLog> log(new net::LoadLog(net::LoadLog::kUnbounded));
- rv = sock->Connect(&callback, log);
+ net::CapturingBoundNetLog log(net::CapturingNetLog::kUnbounded);
+ rv = sock->Connect(&callback, log.bound());
EXPECT_TRUE(net::LogContainsBeginEvent(
- *log, 0, net::LoadLog::TYPE_SSL_CONNECT));
+ log.entries(), 0, net::NetLog::TYPE_SSL_CONNECT));
if (rv != net::OK) {
ASSERT_EQ(net::ERR_IO_PENDING, rv);
EXPECT_FALSE(sock->IsConnected());
EXPECT_FALSE(net::LogContainsEndEvent(
- *log, -1, net::LoadLog::TYPE_SSL_CONNECT));
+ log.entries(), -1, net::NetLog::TYPE_SSL_CONNECT));
rv = callback.WaitForResult();
EXPECT_EQ(net::OK, rv);
@@ -96,7 +96,7 @@ TEST_F(SSLClientSocketTest, Connect) {
EXPECT_TRUE(sock->IsConnected());
EXPECT_TRUE(net::LogContainsEndEvent(
- *log, -1, net::LoadLog::TYPE_SSL_CONNECT));
+ log.entries(), -1, net::NetLog::TYPE_SSL_CONNECT));
sock->Disconnect();
EXPECT_FALSE(sock->IsConnected());
@@ -124,15 +124,15 @@ TEST_F(SSLClientSocketTest, ConnectExpired) {
EXPECT_FALSE(sock->IsConnected());
- scoped_refptr<net::LoadLog> log(new net::LoadLog(net::LoadLog::kUnbounded));
- rv = sock->Connect(&callback, log);
+ net::CapturingBoundNetLog log(net::CapturingNetLog::kUnbounded);
+ rv = sock->Connect(&callback, log.bound());
EXPECT_TRUE(net::LogContainsBeginEvent(
- *log, 0, net::LoadLog::TYPE_SSL_CONNECT));
+ log.entries(), 0, net::NetLog::TYPE_SSL_CONNECT));
if (rv != net::OK) {
ASSERT_EQ(net::ERR_IO_PENDING, rv);
EXPECT_FALSE(sock->IsConnected());
EXPECT_FALSE(net::LogContainsEndEvent(
- *log, -1, net::LoadLog::TYPE_SSL_CONNECT));
+ log.entries(), -1, net::NetLog::TYPE_SSL_CONNECT));
rv = callback.WaitForResult();
EXPECT_EQ(net::ERR_CERT_DATE_INVALID, rv);
@@ -143,7 +143,7 @@ TEST_F(SSLClientSocketTest, ConnectExpired) {
// leave it connected.
EXPECT_TRUE(net::LogContainsEndEvent(
- *log, -1, net::LoadLog::TYPE_SSL_CONNECT));
+ log.entries(), -1, net::NetLog::TYPE_SSL_CONNECT));
}
TEST_F(SSLClientSocketTest, ConnectMismatched) {
@@ -169,15 +169,15 @@ TEST_F(SSLClientSocketTest, ConnectMismatched) {
EXPECT_FALSE(sock->IsConnected());
- scoped_refptr<net::LoadLog> log(new net::LoadLog(net::LoadLog::kUnbounded));
- rv = sock->Connect(&callback, log);
+ net::CapturingBoundNetLog log(net::CapturingNetLog::kUnbounded);
+ rv = sock->Connect(&callback, log.bound());
EXPECT_TRUE(net::LogContainsBeginEvent(
- *log, 0, net::LoadLog::TYPE_SSL_CONNECT));
+ log.entries(), 0, net::NetLog::TYPE_SSL_CONNECT));
if (rv != net::ERR_CERT_COMMON_NAME_INVALID) {
ASSERT_EQ(net::ERR_IO_PENDING, rv);
EXPECT_FALSE(sock->IsConnected());
EXPECT_FALSE(net::LogContainsEndEvent(
- *log, -1, net::LoadLog::TYPE_SSL_CONNECT));
+ log.entries(), -1, net::NetLog::TYPE_SSL_CONNECT));
rv = callback.WaitForResult();
EXPECT_EQ(net::ERR_CERT_COMMON_NAME_INVALID, rv);
@@ -188,7 +188,7 @@ TEST_F(SSLClientSocketTest, ConnectMismatched) {
// leave it connected.
EXPECT_TRUE(net::LogContainsEndEvent(
- *log, -1, net::LoadLog::TYPE_SSL_CONNECT));
+ log.entries(), -1, net::NetLog::TYPE_SSL_CONNECT));
}
// TODO(wtc): Add unit tests for IsConnectedAndIdle:
diff --git a/net/socket/ssl_client_socket_win.cc b/net/socket/ssl_client_socket_win.cc
index bcd2aac..6a4ed8f 100644
--- a/net/socket/ssl_client_socket_win.cc
+++ b/net/socket/ssl_client_socket_win.cc
@@ -14,7 +14,7 @@
#include "net/base/cert_verifier.h"
#include "net/base/connection_type_histograms.h"
#include "net/base/io_buffer.h"
-#include "net/base/load_log.h"
+#include "net/base/net_log.h"
#include "net/base/net_errors.h"
#include "net/base/ssl_cert_request_info.h"
#include "net/base/ssl_info.h"
@@ -431,16 +431,16 @@ SSLClientSocketWin::GetNextProto(std::string* proto) {
}
int SSLClientSocketWin::Connect(CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
DCHECK(transport_.get());
DCHECK(next_state_ == STATE_NONE);
DCHECK(!user_connect_callback_);
- LoadLog::BeginEvent(load_log, LoadLog::TYPE_SSL_CONNECT);
+ net_log.BeginEvent(NetLog::TYPE_SSL_CONNECT);
int rv = InitializeSSLContext();
if (rv != OK) {
- LoadLog::EndEvent(load_log, LoadLog::TYPE_SSL_CONNECT);
+ net_log.EndEvent(NetLog::TYPE_SSL_CONNECT);
return rv;
}
@@ -449,9 +449,9 @@ int SSLClientSocketWin::Connect(CompletionCallback* callback,
rv = DoLoop(OK);
if (rv == ERR_IO_PENDING) {
user_connect_callback_ = callback;
- load_log_ = load_log;
+ net_log_ = net_log;
} else {
- LoadLog::EndEvent(load_log, LoadLog::TYPE_SSL_CONNECT);
+ net_log.EndEvent(NetLog::TYPE_SSL_CONNECT);
}
return rv;
}
@@ -655,8 +655,8 @@ void SSLClientSocketWin::OnHandshakeIOComplete(int result) {
c->Run(rv);
return;
}
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_SSL_CONNECT);
- load_log_ = NULL;
+ net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT);
+ net_log_ = BoundNetLog();
CompletionCallback* c = user_connect_callback_;
user_connect_callback_ = NULL;
c->Run(rv);
diff --git a/net/socket/ssl_client_socket_win.h b/net/socket/ssl_client_socket_win.h
index 3a7d21c..40bc3c1 100644
--- a/net/socket/ssl_client_socket_win.h
+++ b/net/socket/ssl_client_socket_win.h
@@ -16,13 +16,14 @@
#include "base/scoped_ptr.h"
#include "net/base/cert_verify_result.h"
#include "net/base/completion_callback.h"
+#include "net/base/net_log.h"
#include "net/base/ssl_config_service.h"
#include "net/socket/ssl_client_socket.h"
namespace net {
class CertVerifier;
-class LoadLog;
+class BoundNetLog;
// An SSL client socket implemented with the Windows Schannel.
class SSLClientSocketWin : public SSLClientSocket {
@@ -42,7 +43,7 @@ class SSLClientSocketWin : public SSLClientSocket {
virtual NextProtoStatus GetNextProto(std::string* proto);
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, LoadLog* load_log);
+ virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
@@ -181,7 +182,7 @@ class SSLClientSocketWin : public SSLClientSocket {
// True when the decrypter needs more data in order to decrypt.
bool need_more_data_;
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
};
} // namespace net
diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc
index 3743495..db00c55 100644
--- a/net/socket/tcp_client_socket_libevent.cc
+++ b/net/socket/tcp_client_socket_libevent.cc
@@ -15,8 +15,8 @@
#include "base/string_util.h"
#include "base/trace_event.h"
#include "net/base/io_buffer.h"
-#include "net/base/load_log.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log.h"
#if defined(USE_SYSTEM_LIBEVENT)
#include <event.h>
#else
@@ -138,17 +138,17 @@ TCPClientSocketLibevent::~TCPClientSocketLibevent() {
}
int TCPClientSocketLibevent::Connect(CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
// If already connected, then just return OK.
if (socket_ != kInvalidSocket)
return OK;
DCHECK(!waiting_connect_);
- DCHECK(!load_log_);
+ DCHECK(!net_log_.net_log());
TRACE_EVENT_BEGIN("socket.connect", this, "");
- LoadLog::BeginEvent(load_log, LoadLog::TYPE_TCP_CONNECT);
+ net_log.BeginEvent(NetLog::TYPE_TCP_CONNECT);
int rv = DoConnect();
@@ -156,12 +156,12 @@ int TCPClientSocketLibevent::Connect(CompletionCallback* callback,
// Synchronous operation not supported.
DCHECK(callback);
- load_log_ = load_log;
+ net_log_ = net_log;
waiting_connect_ = true;
write_callback_ = callback;
} else {
TRACE_EVENT_END("socket.connect", this, "");
- LoadLog::EndEvent(load_log, LoadLog::TYPE_TCP_CONNECT);
+ net_log.EndEvent(NetLog::TYPE_TCP_CONNECT);
}
return rv;
@@ -403,19 +403,19 @@ void TCPClientSocketLibevent::DidCompleteConnect() {
const addrinfo* next = current_ai_->ai_next;
Disconnect();
current_ai_ = next;
- scoped_refptr<LoadLog> load_log;
- load_log.swap(load_log_);
+ BoundNetLog net_log = net_log_;
+ net_log_ = BoundNetLog();
TRACE_EVENT_END("socket.connect", this, "");
- LoadLog::EndEvent(load_log, LoadLog::TYPE_TCP_CONNECT);
- result = Connect(write_callback_, load_log);
+ net_log.EndEvent(NetLog::TYPE_TCP_CONNECT);
+ result = Connect(write_callback_, net_log);
} else {
result = MapConnectError(os_error);
bool ok = write_socket_watcher_.StopWatchingFileDescriptor();
DCHECK(ok);
waiting_connect_ = false;
TRACE_EVENT_END("socket.connect", this, "");
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_TCP_CONNECT);
- load_log_ = NULL;
+ net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT);
+ net_log_ = BoundNetLog();
}
if (result != ERR_IO_PENDING) {
diff --git a/net/socket/tcp_client_socket_libevent.h b/net/socket/tcp_client_socket_libevent.h
index 55c2fc4..211149a 100644
--- a/net/socket/tcp_client_socket_libevent.h
+++ b/net/socket/tcp_client_socket_libevent.h
@@ -10,13 +10,14 @@
#include "base/scoped_ptr.h"
#include "net/base/address_list.h"
#include "net/base/completion_callback.h"
+#include "net/base/net_log.h"
#include "net/socket/client_socket.h"
struct event; // From libevent
namespace net {
-class LoadLog;
+class BoundNetLog;
// A client socket that uses TCP as the transport layer.
class TCPClientSocketLibevent : public ClientSocket {
@@ -29,7 +30,7 @@ class TCPClientSocketLibevent : public ClientSocket {
virtual ~TCPClientSocketLibevent();
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, LoadLog* load_log);
+ virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
@@ -129,7 +130,7 @@ class TCPClientSocketLibevent : public ClientSocket {
// External callback; called when write is complete.
CompletionCallback* write_callback_;
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
DISALLOW_COPY_AND_ASSIGN(TCPClientSocketLibevent);
};
diff --git a/net/socket/tcp_client_socket_pool.cc b/net/socket/tcp_client_socket_pool.cc
index c7a524e..8e2b4f0c 100644
--- a/net/socket/tcp_client_socket_pool.cc
+++ b/net/socket/tcp_client_socket_pool.cc
@@ -9,7 +9,7 @@
#include "base/message_loop.h"
#include "base/string_util.h"
#include "base/time.h"
-#include "net/base/load_log.h"
+#include "net/base/net_log.h"
#include "net/base/net_errors.h"
#include "net/socket/client_socket_factory.h"
#include "net/socket/client_socket_handle.h"
@@ -38,8 +38,8 @@ TCPConnectJob::TCPConnectJob(
ClientSocketFactory* client_socket_factory,
HostResolver* host_resolver,
Delegate* delegate,
- LoadLog* load_log)
- : ConnectJob(group_name, timeout_duration, delegate, load_log),
+ const BoundNetLog& net_log)
+ : ConnectJob(group_name, timeout_duration, delegate, net_log),
params_(params),
client_socket_factory_(client_socket_factory),
ALLOW_THIS_IN_INITIALIZER_LIST(
@@ -113,7 +113,7 @@ int TCPConnectJob::DoLoop(int result) {
int TCPConnectJob::DoResolveHost() {
next_state_ = kStateResolveHostComplete;
return resolver_.Resolve(params_.destination(), &addresses_, &callback_,
- load_log());
+ net_log());
}
int TCPConnectJob::DoResolveHostComplete(int result) {
@@ -126,7 +126,7 @@ int TCPConnectJob::DoTCPConnect() {
next_state_ = kStateTCPConnectComplete;
set_socket(client_socket_factory_->CreateTCPClientSocket(addresses_));
connect_start_time_ = base::TimeTicks::Now();
- return socket()->Connect(&callback_, load_log());
+ return socket()->Connect(&callback_, net_log());
}
int TCPConnectJob::DoTCPConnectComplete(int result) {
@@ -160,11 +160,11 @@ ConnectJob* TCPClientSocketPool::TCPConnectJobFactory::NewConnectJob(
const std::string& group_name,
const PoolBase::Request& request,
ConnectJob::Delegate* delegate,
- LoadLog* load_log) const {
+ const BoundNetLog& net_log) const {
return new TCPConnectJob(
group_name, request.params(),
base::TimeDelta::FromSeconds(kTCPConnectJobTimeoutInSeconds),
- client_socket_factory_, host_resolver_, delegate, load_log);
+ client_socket_factory_, host_resolver_, delegate, net_log);
}
TCPClientSocketPool::TCPClientSocketPool(
@@ -187,20 +187,18 @@ int TCPClientSocketPool::RequestSocket(
RequestPriority priority,
ClientSocketHandle* handle,
CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
const TCPSocketParams* casted_params =
static_cast<const TCPSocketParams*>(params);
- if (LoadLog::IsUnbounded(load_log)) {
- LoadLog::AddString(
- load_log,
- StringPrintf("Requested TCP socket to: %s [port %d]",
- casted_params->destination().hostname().c_str(),
- casted_params->destination().port()));
+ if (net_log.HasListener()) {
+ net_log.AddString(StringPrintf("Requested TCP socket to: %s [port %d]",
+ casted_params->destination().hostname().c_str(),
+ casted_params->destination().port()));
}
return base_.RequestSocket(group_name, *casted_params, priority, handle,
- callback, load_log);
+ callback, net_log);
}
void TCPClientSocketPool::CancelRequest(
diff --git a/net/socket/tcp_client_socket_pool.h b/net/socket/tcp_client_socket_pool.h
index 7896ea9..50b1237 100644
--- a/net/socket/tcp_client_socket_pool.h
+++ b/net/socket/tcp_client_socket_pool.h
@@ -50,7 +50,7 @@ class TCPConnectJob : public ConnectJob {
ClientSocketFactory* client_socket_factory,
HostResolver* host_resolver,
Delegate* delegate,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
virtual ~TCPConnectJob();
// ConnectJob methods.
@@ -112,7 +112,7 @@ class TCPClientSocketPool : public ClientSocketPool {
RequestPriority priority,
ClientSocketHandle* handle,
CompletionCallback* callback,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
virtual void CancelRequest(const std::string& group_name,
const ClientSocketHandle* handle);
@@ -153,7 +153,7 @@ class TCPClientSocketPool : public ClientSocketPool {
const std::string& group_name,
const PoolBase::Request& request,
ConnectJob::Delegate* delegate,
- LoadLog* load_log) const;
+ const BoundNetLog& net_log) const;
private:
ClientSocketFactory* const client_socket_factory_;
diff --git a/net/socket/tcp_client_socket_pool_unittest.cc b/net/socket/tcp_client_socket_pool_unittest.cc
index d5576f0..a275a63 100644
--- a/net/socket/tcp_client_socket_pool_unittest.cc
+++ b/net/socket/tcp_client_socket_pool_unittest.cc
@@ -30,7 +30,7 @@ class MockClientSocket : public ClientSocket {
MockClientSocket() : connected_(false) {}
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, LoadLog* /* load_log */) {
+ virtual int Connect(CompletionCallback* callback, const BoundNetLog& /* net_log */) {
connected_ = true;
return OK;
}
@@ -68,7 +68,7 @@ class MockFailingClientSocket : public ClientSocket {
MockFailingClientSocket() {}
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, LoadLog* /* load_log */) {
+ virtual int Connect(CompletionCallback* callback, const BoundNetLog& /* net_log */) {
return ERR_CONNECTION_FAILED;
}
@@ -112,7 +112,7 @@ class MockPendingClientSocket : public ClientSocket {
is_connected_(false) {}
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, LoadLog* /* load_log */) {
+ virtual int Connect(CompletionCallback* callback, const BoundNetLog& /* net_log */) {
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
method_factory_.NewRunnableMethod(
diff --git a/net/socket/tcp_client_socket_unittest.cc b/net/socket/tcp_client_socket_unittest.cc
index ffbde90..01a0783 100644
--- a/net/socket/tcp_client_socket_unittest.cc
+++ b/net/socket/tcp_client_socket_unittest.cc
@@ -9,8 +9,8 @@
#include "net/base/host_resolver.h"
#include "net/base/io_buffer.h"
#include "net/base/listen_socket.h"
-#include "net/base/load_log.h"
-#include "net/base/load_log_unittest.h"
+#include "net/base/net_log.h"
+#include "net/base/net_log_unittest.h"
#include "net/base/net_errors.h"
#include "net/base/test_completion_callback.h"
#include "net/base/winsock_init.h"
@@ -99,14 +99,14 @@ TEST_F(TCPClientSocketTest, Connect) {
TestCompletionCallback callback;
EXPECT_FALSE(sock_->IsConnected());
- scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded));
- int rv = sock_->Connect(&callback, log);
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ int rv = sock_->Connect(&callback, log.bound());
EXPECT_TRUE(net::LogContainsBeginEvent(
- *log, 0, net::LoadLog::TYPE_TCP_CONNECT));
+ log.entries(), 0, net::NetLog::TYPE_TCP_CONNECT));
if (rv != OK) {
ASSERT_EQ(rv, ERR_IO_PENDING);
EXPECT_FALSE(net::LogContainsEndEvent(
- *log, -1, net::LoadLog::TYPE_TCP_CONNECT));
+ log.entries(), -1, net::NetLog::TYPE_TCP_CONNECT));
rv = callback.WaitForResult();
EXPECT_EQ(rv, OK);
@@ -114,7 +114,7 @@ TEST_F(TCPClientSocketTest, Connect) {
EXPECT_TRUE(sock_->IsConnected());
EXPECT_TRUE(net::LogContainsEndEvent(
- *log, -1, net::LoadLog::TYPE_TCP_CONNECT));
+ log.entries(), -1, net::NetLog::TYPE_TCP_CONNECT));
sock_->Disconnect();
EXPECT_FALSE(sock_->IsConnected());
diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc
index b1270bb..fae2755 100644
--- a/net/socket/tcp_client_socket_win.cc
+++ b/net/socket/tcp_client_socket_win.cc
@@ -13,7 +13,7 @@
#include "base/trace_event.h"
#include "net/base/connection_type_histograms.h"
#include "net/base/io_buffer.h"
-#include "net/base/load_log.h"
+#include "net/base/net_log.h"
#include "net/base/net_errors.h"
#include "net/base/sys_addrinfo.h"
#include "net/base/winsock_init.h"
@@ -288,19 +288,19 @@ TCPClientSocketWin::~TCPClientSocketWin() {
}
int TCPClientSocketWin::Connect(CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
// If already connected, then just return OK.
if (socket_ != INVALID_SOCKET)
return OK;
- DCHECK(!load_log_);
+ DCHECK(!net_log_.net_log());
static StatsCounter connects("tcp.connect");
connects.Increment();
TRACE_EVENT_BEGIN("socket.connect", this, "");
- LoadLog::BeginEvent(load_log, LoadLog::TYPE_TCP_CONNECT);
+ net_log.BeginEvent(NetLog::TYPE_TCP_CONNECT);
int rv = DoConnect();
@@ -308,12 +308,12 @@ int TCPClientSocketWin::Connect(CompletionCallback* callback,
// Synchronous operation not supported.
DCHECK(callback);
- load_log_ = load_log;
+ net_log_ = net_log;
waiting_connect_ = true;
read_callback_ = callback;
} else {
TRACE_EVENT_END("socket.connect", this, "");
- LoadLog::EndEvent(load_log, LoadLog::TYPE_TCP_CONNECT);
+ net_log.EndEvent(NetLog::TYPE_TCP_CONNECT);
if (rv == OK)
UpdateConnectionTypeHistograms(CONNECTION_ANY);
}
@@ -658,23 +658,23 @@ void TCPClientSocketWin::DidCompleteConnect() {
const struct addrinfo* next = current_ai_->ai_next;
Disconnect();
current_ai_ = next;
- scoped_refptr<LoadLog> load_log;
- load_log.swap(load_log_);
+ BoundNetLog net_log(net_log_);
+ net_log_ = BoundNetLog();
TRACE_EVENT_END("socket.connect", this, "");
- LoadLog::EndEvent(load_log, LoadLog::TYPE_TCP_CONNECT);
- result = Connect(read_callback_, load_log);
+ net_log.EndEvent(NetLog::TYPE_TCP_CONNECT);
+ result = Connect(read_callback_, net_log);
} else {
result = MapConnectError(os_error);
TRACE_EVENT_END("socket.connect", this, "");
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_TCP_CONNECT);
- load_log_ = NULL;
+ net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT);
+ net_log_ = BoundNetLog();
}
} else {
NOTREACHED();
result = ERR_UNEXPECTED;
TRACE_EVENT_END("socket.connect", this, "");
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_TCP_CONNECT);
- load_log_ = NULL;
+ net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT);
+ net_log_ = BoundNetLog();
}
if (result != ERR_IO_PENDING) {
diff --git a/net/socket/tcp_client_socket_win.h b/net/socket/tcp_client_socket_win.h
index 6acfa8e..128b72e 100644
--- a/net/socket/tcp_client_socket_win.h
+++ b/net/socket/tcp_client_socket_win.h
@@ -10,11 +10,12 @@
#include "base/object_watcher.h"
#include "net/base/address_list.h"
#include "net/base/completion_callback.h"
+#include "net/base/net_log.h"
#include "net/socket/client_socket.h"
namespace net {
-class LoadLog;
+class BoundNetLog;
class TCPClientSocketWin : public ClientSocket {
public:
@@ -26,7 +27,7 @@ class TCPClientSocketWin : public ClientSocket {
~TCPClientSocketWin();
// ClientSocket methods:
- virtual int Connect(CompletionCallback* callback, LoadLog* load_log);
+ virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const;
@@ -78,7 +79,7 @@ class TCPClientSocketWin : public ClientSocket {
// External callback; called when write is complete.
CompletionCallback* write_callback_;
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
DISALLOW_COPY_AND_ASSIGN(TCPClientSocketWin);
};
diff --git a/net/socket_stream/socket_stream.cc b/net/socket_stream/socket_stream.cc
index 04c68b0..03d7a9f 100644
--- a/net/socket_stream/socket_stream.cc
+++ b/net/socket_stream/socket_stream.cc
@@ -62,9 +62,7 @@ SocketStream::SocketStream(const GURL& url, Delegate* delegate)
throttle_(
SocketStreamThrottle::GetSocketStreamThrottleForScheme(
url.scheme())),
- metrics_(new SocketStreamMetrics(url)),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- request_tracker_node_(this)) {
+ metrics_(new SocketStreamMetrics(url)) {
DCHECK(MessageLoop::current()) <<
"The current MessageLoop must exist";
DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) <<
@@ -96,15 +94,16 @@ void SocketStream::set_context(URLRequestContext* context) {
context_ = context;
if (prev_context != context) {
- if (prev_context)
- prev_context->socket_stream_tracker()->Remove(this);
+ net_log_.AddEvent(NetLog::TYPE_REQUEST_ALIVE);
+ net_log_ = BoundNetLog();
+
if (context) {
- if (!load_log_) {
- // Create the LoadLog -- we waited until now to create it so we know
- // what constraints the URLRequestContext is enforcing on log levels.
- load_log_ = context->socket_stream_tracker()->CreateLoadLog();
- }
- context->socket_stream_tracker()->Add(this);
+ net_log_ = BoundNetLog::Make(
+ context->net_log(),
+ NetLog::SOURCE_SOCKET_STREAM);
+
+ net_log_.BeginEventWithString(NetLog::TYPE_REQUEST_ALIVE,
+ url_.possibly_invalid_spec());
}
}
@@ -127,7 +126,7 @@ void SocketStream::Connect() {
// Open a connection asynchronously, so that delegate won't be called
// back before returning Connect().
next_state_ = STATE_RESOLVE_PROXY;
- LoadLog::BeginEvent(load_log_, LoadLog::TYPE_SOCKET_STREAM_CONNECT);
+ net_log_.BeginEvent(NetLog::TYPE_SOCKET_STREAM_CONNECT);
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &SocketStream::DoLoop, OK));
@@ -213,7 +212,7 @@ void SocketStream::DetachDelegate() {
if (!delegate_)
return;
delegate_ = NULL;
- LoadLog::AddEvent(load_log_, LoadLog::TYPE_CANCELLED);
+ net_log_.AddEvent(NetLog::TYPE_CANCELLED);
Close();
}
@@ -263,7 +262,7 @@ int SocketStream::DidEstablishConnection() {
next_state_ = STATE_READ_WRITE;
metrics_->OnConnected();
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_SOCKET_STREAM_CONNECT);
+ net_log_.EndEvent(NetLog::TYPE_SOCKET_STREAM_CONNECT);
if (delegate_)
delegate_->OnConnected(this, max_pending_send_allowed_);
@@ -273,7 +272,7 @@ int SocketStream::DidEstablishConnection() {
int SocketStream::DidReceiveData(int result) {
DCHECK(read_buf_);
DCHECK_GT(result, 0);
- LoadLog::AddEvent(load_log_, LoadLog::TYPE_SOCKET_STREAM_RECEIVED);
+ net_log_.AddEvent(NetLog::TYPE_SOCKET_STREAM_RECEIVED);
int len = result;
metrics_->OnRead(len);
result = throttle_->OnRead(this, read_buf_->data(), len, &io_callback_);
@@ -287,7 +286,7 @@ int SocketStream::DidReceiveData(int result) {
int SocketStream::DidSendData(int result) {
DCHECK_GT(result, 0);
- LoadLog::AddEvent(load_log_, LoadLog::TYPE_SOCKET_STREAM_SENT);
+ net_log_.AddEvent(NetLog::TYPE_SOCKET_STREAM_SENT);
int len = result;
metrics_->OnWrite(len);
result = throttle_->OnWrite(this, current_write_buf_->data(), len,
@@ -411,7 +410,7 @@ void SocketStream::DoLoop(int result) {
// close the connection.
if (state != STATE_READ_WRITE && result < ERR_IO_PENDING) {
DCHECK_EQ(next_state_, STATE_CLOSE);
- LoadLog::EndEvent(load_log_, LoadLog::TYPE_SOCKET_STREAM_CONNECT);
+ net_log_.EndEvent(NetLog::TYPE_SOCKET_STREAM_CONNECT);
}
} while (result != ERR_IO_PENDING);
}
@@ -426,7 +425,7 @@ int SocketStream::DoResolveProxy() {
}
return proxy_service()->ResolveProxy(
- proxy_url_, &proxy_info_, &io_callback_, &pac_request_, load_log_);
+ proxy_url_, &proxy_info_, &io_callback_, &pac_request_, net_log_);
}
int SocketStream::DoResolveProxyComplete(int result) {
@@ -485,7 +484,7 @@ int SocketStream::DoResolveHost() {
DCHECK(host_resolver_.get());
resolver_.reset(new SingleRequestHostResolver(host_resolver_.get()));
return resolver_->Resolve(resolve_info, &addresses_, &io_callback_,
- load_log_);
+ net_log_);
}
int SocketStream::DoResolveHostComplete(int result) {
@@ -506,7 +505,7 @@ int SocketStream::DoTcpConnect() {
DCHECK(factory_);
socket_.reset(factory_->CreateTCPClientSocket(addresses_));
metrics_->OnStartConnection();
- return socket_->Connect(&io_callback_, load_log_);
+ return socket_->Connect(&io_callback_, net_log_);
}
int SocketStream::DoTcpConnectComplete(int result) {
@@ -722,7 +721,7 @@ int SocketStream::DoSOCKSConnect() {
s = new SOCKSClientSocket(s, req_info, host_resolver_.get());
socket_.reset(s);
metrics_->OnSOCKSProxy();
- return socket_->Connect(&io_callback_, load_log_);
+ return socket_->Connect(&io_callback_, net_log_);
}
int SocketStream::DoSOCKSConnectComplete(int result) {
@@ -745,7 +744,7 @@ int SocketStream::DoSSLConnect() {
socket_.release(), url_.HostNoBrackets(), ssl_config_));
next_state_ = STATE_SSL_CONNECT_COMPLETE;
metrics_->OnSSLConnection();
- return socket_->Connect(&io_callback_, load_log_);
+ return socket_->Connect(&io_callback_, net_log_);
}
int SocketStream::DoSSLConnectComplete(int result) {
@@ -949,10 +948,4 @@ ProxyService* SocketStream::proxy_service() const {
return context_->proxy_service();
}
-void SocketStream::GetInfoForTracker(
- RequestTracker<SocketStream>::RecentRequestInfo* info) const {
- info->original_url = url_;
- info->load_log = load_log_;
-}
-
} // namespace net
diff --git a/net/socket_stream/socket_stream.h b/net/socket_stream/socket_stream.h
index 038d7a5..e8b250e 100644
--- a/net/socket_stream/socket_stream.h
+++ b/net/socket_stream/socket_stream.h
@@ -17,12 +17,12 @@
#include "net/base/address_list.h"
#include "net/base/completion_callback.h"
#include "net/base/io_buffer.h"
+#include "net/base/net_log.h"
#include "net/http/http_auth.h"
#include "net/http/http_auth_cache.h"
#include "net/http/http_auth_handler.h"
#include "net/proxy/proxy_service.h"
#include "net/socket/tcp_client_socket.h"
-#include "net/url_request/request_tracker.h"
#include "net/url_request/url_request_context.h"
namespace net {
@@ -31,7 +31,6 @@ class AuthChallengeInfo;
class ClientSocketFactory;
class HostResolver;
class HttpAuthHandlerFactory;
-class LoadLog;
class SSLConfigService;
class SingleRequestHostResolver;
class SocketStreamMetrics;
@@ -109,7 +108,7 @@ class SocketStream : public base::RefCountedThreadSafe<SocketStream> {
URLRequestContext* context() const { return context_.get(); }
void set_context(URLRequestContext* context);
- LoadLog* load_log() const { return load_log_; }
+ BoundNetLog* net_log() { return &net_log_; }
// Opens the connection on the IO thread.
// Once the connection is established, calls delegate's OnConnected.
@@ -207,7 +206,6 @@ class SocketStream : public base::RefCountedThreadSafe<SocketStream> {
};
typedef std::deque< scoped_refptr<IOBufferWithSize> > PendingDataQueue;
- friend class RequestTracker<SocketStream>;
friend class WebSocketThrottleTest;
@@ -256,10 +254,7 @@ class SocketStream : public base::RefCountedThreadSafe<SocketStream> {
SSLConfigService* ssl_config_service() const;
ProxyService* proxy_service() const;
- void GetInfoForTracker(
- RequestTracker<SocketStream>::RecentRequestInfo* info) const;
-
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
GURL url_;
int max_pending_send_allowed_;
@@ -322,8 +317,6 @@ class SocketStream : public base::RefCountedThreadSafe<SocketStream> {
scoped_ptr<SocketStreamMetrics> metrics_;
- RequestTracker<SocketStream>::Node request_tracker_node_;
-
DISALLOW_COPY_AND_ASSIGN(SocketStream);
};
diff --git a/net/socket_stream/socket_stream_unittest.cc b/net/socket_stream/socket_stream_unittest.cc
index f1b5c6e..b3bdbbe 100644
--- a/net/socket_stream/socket_stream_unittest.cc
+++ b/net/socket_stream/socket_stream_unittest.cc
@@ -6,9 +6,9 @@
#include <vector>
#include "base/callback.h"
-#include "net/base/load_log.h"
-#include "net/base/load_log_unittest.h"
#include "net/base/mock_host_resolver.h"
+#include "net/base/net_log.h"
+#include "net/base/net_log_unittest.h"
#include "net/base/test_completion_callback.h"
#include "net/socket/socket_test_util.h"
#include "net/socket_stream/socket_stream.h"
@@ -211,12 +211,7 @@ TEST_F(SocketStreamTest, BasicAuthProxy) {
EXPECT_EQ(SocketStreamEvent::EVENT_CONNECTED, events[1].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[2].event_type);
- // The first and last entries of the LoadLog should be for
- // SOCKET_STREAM_CONNECT.
- EXPECT_TRUE(LogContainsBeginEvent(
- *socket_stream->load_log(), 0, LoadLog::TYPE_SOCKET_STREAM_CONNECT));
- EXPECT_TRUE(LogContainsEndEvent(
- *socket_stream->load_log(), -1, LoadLog::TYPE_SOCKET_STREAM_CONNECT));
+ // TODO(eroman): Add back NetLogTest here...
}
} // namespace net
diff --git a/net/spdy/spdy_network_transaction.cc b/net/spdy/spdy_network_transaction.cc
index 27e4521..d7de332 100644
--- a/net/spdy/spdy_network_transaction.cc
+++ b/net/spdy/spdy_network_transaction.cc
@@ -45,13 +45,13 @@ SpdyNetworkTransaction::~SpdyNetworkTransaction() {
int SpdyNetworkTransaction::Start(const HttpRequestInfo* request_info,
CompletionCallback* callback,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
CHECK(request_info);
CHECK(callback);
SIMPLE_STATS_COUNTER("SpdyNetworkTransaction.Count");
- load_log_ = load_log;
+ net_log_ = net_log;
request_ = request_info;
start_time_ = base::TimeTicks::Now();
@@ -159,46 +159,38 @@ int SpdyNetworkTransaction::DoLoop(int result) {
switch (state) {
case STATE_INIT_CONNECTION:
DCHECK_EQ(OK, rv);
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION);
+ net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION);
rv = DoInitConnection();
break;
case STATE_INIT_CONNECTION_COMPLETE:
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION);
+ net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION);
rv = DoInitConnectionComplete(rv);
break;
case STATE_SEND_REQUEST:
DCHECK_EQ(OK, rv);
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST);
+ net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST);
rv = DoSendRequest();
break;
case STATE_SEND_REQUEST_COMPLETE:
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST);
+ net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST);
rv = DoSendRequestComplete(rv);
break;
case STATE_READ_HEADERS:
DCHECK_EQ(OK, rv);
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_SPDY_TRANSACTION_READ_HEADERS);
+ net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_READ_HEADERS);
rv = DoReadHeaders();
break;
case STATE_READ_HEADERS_COMPLETE:
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_SPDY_TRANSACTION_READ_HEADERS);
+ net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_READ_HEADERS);
rv = DoReadHeadersComplete(rv);
break;
case STATE_READ_BODY:
DCHECK_EQ(OK, rv);
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_SPDY_TRANSACTION_READ_BODY);
+ net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_READ_BODY);
rv = DoReadBody();
break;
case STATE_READ_BODY_COMPLETE:
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_SPDY_TRANSACTION_READ_BODY);
+ net_log_.EndEvent(NetLog::TYPE_SPDY_TRANSACTION_READ_BODY);
rv = DoReadBodyComplete(rv);
break;
case STATE_NONE:
@@ -240,7 +232,7 @@ int SpdyNetworkTransaction::DoInitConnection() {
DCHECK(spdy_);
return spdy_->Connect(
- connection_group, tcp_params, request_->priority, load_log_);
+ connection_group, tcp_params, request_->priority, net_log_);
}
int SpdyNetworkTransaction::DoInitConnectionComplete(int result) {
@@ -256,7 +248,7 @@ int SpdyNetworkTransaction::DoSendRequest() {
CHECK(!stream_.get());
UploadDataStream* upload_data = request_->upload_data ?
new UploadDataStream(request_->upload_data) : NULL;
- stream_ = spdy_->GetOrCreateStream(*request_, upload_data, load_log_.get());
+ stream_ = spdy_->GetOrCreateStream(*request_, upload_data, net_log_);
// Release the reference to |spdy_| since we don't need it anymore.
spdy_ = NULL;
return stream_->SendRequest(upload_data, &response_, &io_callback_);
diff --git a/net/spdy/spdy_network_transaction.h b/net/spdy/spdy_network_transaction.h
index a9087e7..f2eb8d5 100644
--- a/net/spdy/spdy_network_transaction.h
+++ b/net/spdy/spdy_network_transaction.h
@@ -14,6 +14,7 @@
#include "base/time.h"
#include "net/base/completion_callback.h"
#include "net/base/load_states.h"
+#include "net/base/net_log.h"
#include "net/http/http_response_info.h"
#include "net/http/http_transaction.h"
#include "net/spdy/spdy_session.h"
@@ -37,7 +38,7 @@ class SpdyNetworkTransaction : public HttpTransaction {
// HttpTransaction methods:
virtual int Start(const HttpRequestInfo* request_info,
CompletionCallback* callback,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
virtual int RestartIgnoringLastError(CompletionCallback* callback);
virtual int RestartWithCertificate(X509Certificate* client_cert,
CompletionCallback* callback);
@@ -89,7 +90,7 @@ class SpdyNetworkTransaction : public HttpTransaction {
int DoReadBody();
int DoReadBodyComplete(int result);
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
scoped_refptr<SpdySession> spdy_;
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc
index 3d8ccd7..5b1aa84 100644
--- a/net/spdy/spdy_network_transaction_unittest.cc
+++ b/net/spdy/spdy_network_transaction_unittest.cc
@@ -7,8 +7,8 @@
#include "base/basictypes.h"
#include "base/ref_counted.h"
#include "net/base/completion_callback.h"
-#include "net/base/load_log_unittest.h"
#include "net/base/mock_host_resolver.h"
+#include "net/base/net_log_unittest.h"
#include "net/base/ssl_config_service_defaults.h"
#include "net/base/test_completion_callback.h"
#include "net/base/upload_data.h"
@@ -285,7 +285,7 @@ class SpdyNetworkTransactionTest : public PlatformTest {
TransactionHelperResult TransactionHelper(const HttpRequestInfo& request,
DelayedSocketData* data,
- LoadLog* log) {
+ const BoundNetLog& log) {
TransactionHelperResult out;
// We disable SSL for this test.
@@ -1024,8 +1024,8 @@ TEST_F(SpdyNetworkTransactionTest, DecompressFailureOnSynReply) {
EnableCompression(false);
}
-// Test that the LoadLog contains good data for a simple GET request.
-TEST_F(SpdyNetworkTransactionTest, LoadLog) {
+// Test that the NetLog contains good data for a simple GET request.
+TEST_F(SpdyNetworkTransactionTest, NetLog) {
MockWrite writes[] = {
MockWrite(true, reinterpret_cast<const char*>(kGetSyn),
arraysize(kGetSyn)),
@@ -1039,7 +1039,7 @@ TEST_F(SpdyNetworkTransactionTest, LoadLog) {
MockRead(true, 0, 0) // EOF
};
- scoped_refptr<net::LoadLog> log(new net::LoadLog(net::LoadLog::kUnbounded));
+ net::CapturingBoundNetLog log(net::CapturingNetLog::kUnbounded);
HttpRequestInfo request;
request.method = "GET";
@@ -1049,42 +1049,42 @@ TEST_F(SpdyNetworkTransactionTest, LoadLog) {
new DelayedSocketData(1, reads, arraysize(reads),
writes, arraysize(writes)));
TransactionHelperResult out = TransactionHelper(request, data.get(),
- log);
+ log.bound());
EXPECT_EQ(OK, out.rv);
EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
EXPECT_EQ("hello!", out.response_data);
- // Check that the LoadLog was filled reasonably.
+ // Check that the NetLog was filled reasonably.
// This test is intentionally non-specific about the exact ordering of
// the log; instead we just check to make sure that certain events exist.
- EXPECT_LT(0u, log->entries().size());
+ EXPECT_LT(0u, log.entries().size());
int pos = 0;
// We know the first event at position 0.
EXPECT_TRUE(net::LogContainsBeginEvent(
- *log, 0, net::LoadLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION));
+ log.entries(), 0, net::NetLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION));
// For the rest of the events, allow additional events in the middle,
// but expect these to be logged in order.
- pos = net::ExpectLogContainsSomewhere(log, 0,
- net::LoadLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION,
- net::LoadLog::PHASE_END);
- pos = net::ExpectLogContainsSomewhere(log, pos + 1,
- net::LoadLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST,
- net::LoadLog::PHASE_BEGIN);
- pos = net::ExpectLogContainsSomewhere(log, pos + 1,
- net::LoadLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST,
- net::LoadLog::PHASE_END);
- pos = net::ExpectLogContainsSomewhere(log, pos + 1,
- net::LoadLog::TYPE_SPDY_TRANSACTION_READ_HEADERS,
- net::LoadLog::PHASE_BEGIN);
- pos = net::ExpectLogContainsSomewhere(log, pos + 1,
- net::LoadLog::TYPE_SPDY_TRANSACTION_READ_HEADERS,
- net::LoadLog::PHASE_END);
- pos = net::ExpectLogContainsSomewhere(log, pos + 1,
- net::LoadLog::TYPE_SPDY_TRANSACTION_READ_BODY,
- net::LoadLog::PHASE_BEGIN);
- pos = net::ExpectLogContainsSomewhere(log, pos + 1,
- net::LoadLog::TYPE_SPDY_TRANSACTION_READ_BODY,
- net::LoadLog::PHASE_END);
+ pos = net::ExpectLogContainsSomewhere(log.entries(), 0,
+ net::NetLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION,
+ net::NetLog::PHASE_END);
+ pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1,
+ net::NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST,
+ net::NetLog::PHASE_BEGIN);
+ pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1,
+ net::NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST,
+ net::NetLog::PHASE_END);
+ pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1,
+ net::NetLog::TYPE_SPDY_TRANSACTION_READ_HEADERS,
+ net::NetLog::PHASE_BEGIN);
+ pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1,
+ net::NetLog::TYPE_SPDY_TRANSACTION_READ_HEADERS,
+ net::NetLog::PHASE_END);
+ pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1,
+ net::NetLog::TYPE_SPDY_TRANSACTION_READ_BODY,
+ net::NetLog::PHASE_BEGIN);
+ pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1,
+ net::NetLog::TYPE_SPDY_TRANSACTION_READ_BODY,
+ net::NetLog::PHASE_END);
}
// Since we buffer the IO from the stream to the renderer, this test verifies
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 33fa576..d527e4f 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -13,7 +13,7 @@
#include "base/string_util.h"
#include "net/base/connection_type_histograms.h"
#include "net/base/load_flags.h"
-#include "net/base/load_log.h"
+#include "net/base/net_log.h"
#include "net/base/net_util.h"
#include "net/http/http_network_session.h"
#include "net/http/http_request_info.h"
@@ -259,7 +259,7 @@ void SpdySession::InitializeWithSSLSocket(ClientSocketHandle* connection) {
net::Error SpdySession::Connect(const std::string& group_name,
const TCPSocketParams& destination,
RequestPriority priority,
- LoadLog* load_log) {
+ const BoundNetLog& net_log) {
DCHECK(priority >= SPDY_PRIORITY_HIGHEST && priority <= SPDY_PRIORITY_LOWEST);
// If the connect process is started, let the caller continue.
@@ -273,7 +273,7 @@ net::Error SpdySession::Connect(const std::string& group_name,
int rv = connection_->Init(group_name, destination, priority,
&connect_callback_, session_->tcp_socket_pool(),
- load_log);
+ net_log);
DCHECK(rv <= 0);
// If the connect is pending, we still return ok. The APIs enqueue
@@ -287,7 +287,7 @@ net::Error SpdySession::Connect(const std::string& group_name,
scoped_refptr<SpdyStream> SpdySession::GetOrCreateStream(
const HttpRequestInfo& request,
const UploadDataStream* upload_data,
- LoadLog* log) {
+ const BoundNetLog& log) {
const GURL& url = request.url;
const std::string& path = url.PathForRequest();
@@ -310,7 +310,7 @@ scoped_refptr<SpdyStream> SpdySession::GetOrCreateStream(
DCHECK(!it->second);
// Server will assign a stream id when the push stream arrives. Use 0 for
// now.
- LoadLog::AddEvent(log, LoadLog::TYPE_SPDY_STREAM_ADOPTED_PUSH_STREAM);
+ log.AddEvent(NetLog::TYPE_SPDY_STREAM_ADOPTED_PUSH_STREAM);
SpdyStream* stream = new SpdyStream(this, 0, true, log);
stream->set_path(path);
it->second = stream;
@@ -475,7 +475,7 @@ void SpdySession::OnTCPConnect(int result) {
socket, "" /* request_->url.HostNoBrackets() */ , ssl_config_);
connection_->set_socket(socket);
is_secure_ = true;
- // TODO(willchan): Plumb LoadLog into SPDY code.
+ // TODO(willchan): Plumb NetLog into SPDY code.
int status = connection_->socket()->Connect(&ssl_connect_callback_, NULL);
if (status != ERR_IO_PENDING)
OnSSLConnect(status);
@@ -896,7 +896,7 @@ void SpdySession::OnSyn(const spdy::SpdySynStreamControlFrame& frame,
CHECK_EQ(0u, stream->stream_id());
stream->set_stream_id(stream_id);
} else {
- // TODO(mbelshe): can we figure out how to use a LoadLog here?
+ // TODO(mbelshe): can we figure out how to use a NetLog here?
stream = new SpdyStream(this, stream_id, true, NULL);
// A new HttpResponseInfo object needs to be generated so the call to
diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h
index 961e07b..80124c6 100644
--- a/net/spdy/spdy_session.h
+++ b/net/spdy/spdy_session.h
@@ -32,7 +32,7 @@ class SpdyStream;
class HttpNetworkSession;
class HttpRequestInfo;
class HttpResponseInfo;
-class LoadLog;
+class BoundNetLog;
class SSLInfo;
class SpdySession : public base::RefCounted<SpdySession>,
@@ -47,7 +47,7 @@ class SpdySession : public base::RefCounted<SpdySession>,
net::Error Connect(const std::string& group_name,
const TCPSocketParams& destination,
RequestPriority priority,
- LoadLog* load_log);
+ const BoundNetLog& net_log);
// Get a stream for a given |request|. In the typical case, this will involve
// the creation of a new stream (and will send the SYN frame). If the server
@@ -56,7 +56,7 @@ class SpdySession : public base::RefCounted<SpdySession>,
// X-Associated-Content.
// Returns the new or existing stream. Never returns NULL.
scoped_refptr<SpdyStream> GetOrCreateStream(const HttpRequestInfo& request,
- const UploadDataStream* upload_data, LoadLog* log);
+ const UploadDataStream* upload_data, const BoundNetLog& log);
// Write a data frame to the stream.
// Used to create and queue a data frame for the given stream.
diff --git a/net/spdy/spdy_stream.cc b/net/spdy/spdy_stream.cc
index e279770..6b82fa1 100644
--- a/net/spdy/spdy_stream.cc
+++ b/net/spdy/spdy_stream.cc
@@ -13,7 +13,7 @@
namespace net {
SpdyStream::SpdyStream(SpdySession* session, spdy::SpdyStreamId stream_id,
- bool pushed, LoadLog* log)
+ bool pushed, const BoundNetLog& log)
: stream_id_(stream_id),
priority_(0),
pushed_(pushed),
@@ -29,7 +29,7 @@ SpdyStream::SpdyStream(SpdySession* session, spdy::SpdyStreamId stream_id,
user_buffer_(NULL),
user_buffer_len_(0),
cancelled_(false),
- load_log_(log),
+ net_log_(log),
send_bytes_(0),
recv_bytes_(0),
histograms_recorded_(false),
@@ -278,35 +278,29 @@ int SpdyStream::DoLoop(int result) {
// State machine 1: Send headers and wait for response headers.
case STATE_SEND_HEADERS:
CHECK_EQ(OK, result);
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_SPDY_STREAM_SEND_HEADERS);
+ net_log_.BeginEvent(NetLog::TYPE_SPDY_STREAM_SEND_HEADERS);
result = DoSendHeaders();
break;
case STATE_SEND_HEADERS_COMPLETE:
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_SPDY_STREAM_SEND_HEADERS);
+ net_log_.EndEvent(NetLog::TYPE_SPDY_STREAM_SEND_HEADERS);
result = DoSendHeadersComplete(result);
break;
case STATE_SEND_BODY:
CHECK_EQ(OK, result);
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_SPDY_STREAM_SEND_BODY);
+ net_log_.BeginEvent(NetLog::TYPE_SPDY_STREAM_SEND_BODY);
result = DoSendBody();
break;
case STATE_SEND_BODY_COMPLETE:
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_SPDY_STREAM_SEND_BODY);
+ net_log_.EndEvent(NetLog::TYPE_SPDY_STREAM_SEND_BODY);
result = DoSendBodyComplete(result);
break;
case STATE_READ_HEADERS:
CHECK_EQ(OK, result);
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_SPDY_STREAM_READ_HEADERS);
+ net_log_.BeginEvent(NetLog::TYPE_SPDY_STREAM_READ_HEADERS);
result = DoReadHeaders();
break;
case STATE_READ_HEADERS_COMPLETE:
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_SPDY_STREAM_READ_HEADERS);
+ net_log_.EndEvent(NetLog::TYPE_SPDY_STREAM_READ_HEADERS);
result = DoReadHeadersComplete(result);
break;
@@ -315,13 +309,11 @@ int SpdyStream::DoLoop(int result) {
// the OnDataReceived()/OnClose()/ReadResponseHeaders()/etc. Only reason
// to do this is for consistency with the Http code.
case STATE_READ_BODY:
- LoadLog::BeginEvent(load_log_,
- LoadLog::TYPE_SPDY_STREAM_READ_BODY);
+ net_log_.BeginEvent(NetLog::TYPE_SPDY_STREAM_READ_BODY);
result = DoReadBody();
break;
case STATE_READ_BODY_COMPLETE:
- LoadLog::EndEvent(load_log_,
- LoadLog::TYPE_SPDY_STREAM_READ_BODY);
+ net_log_.EndEvent(NetLog::TYPE_SPDY_STREAM_READ_BODY);
result = DoReadBodyComplete(result);
break;
case STATE_DONE:
diff --git a/net/spdy/spdy_stream.h b/net/spdy/spdy_stream.h
index 5445a5c..89cfb18 100644
--- a/net/spdy/spdy_stream.h
+++ b/net/spdy/spdy_stream.h
@@ -15,7 +15,7 @@
#include "net/base/bandwidth_metrics.h"
#include "net/base/completion_callback.h"
#include "net/base/io_buffer.h"
-#include "net/base/load_log.h"
+#include "net/base/net_log.h"
#include "net/spdy/spdy_framer.h"
#include "net/spdy/spdy_protocol.h"
@@ -38,7 +38,7 @@ class SpdyStream : public base::RefCounted<SpdyStream> {
public:
// SpdyStream constructor
SpdyStream(SpdySession* session, spdy::SpdyStreamId stream_id, bool pushed,
- LoadLog* log);
+ const BoundNetLog& log);
// Ideally I'd use two abstract classes as interfaces for these two sections,
// but since we're ref counted, I can't make both abstract classes inherit
@@ -198,7 +198,7 @@ class SpdyStream : public base::RefCounted<SpdyStream> {
bool cancelled_;
- scoped_refptr<LoadLog> load_log_;
+ BoundNetLog net_log_;
base::TimeTicks send_time_;
base::TimeTicks recv_first_byte_time_;
diff --git a/net/url_request/request_tracker.h b/net/url_request/request_tracker.h
deleted file mode 100644
index 3202e60..0000000
--- a/net/url_request/request_tracker.h
+++ /dev/null
@@ -1,192 +0,0 @@
-// Copyright (c) 2006-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_URL_REQUEST_REQUEST_TRACKER_H_
-#define NET_URL_REQUEST_REQUEST_TRACKER_H_
-
-#include <vector>
-
-#include "base/ref_counted.h"
-#include "base/linked_list.h"
-#include "base/logging.h"
-#include "googleurl/src/gurl.h"
-#include "net/base/load_log.h"
-
-// Class to track all of the live instances of Request associated with a
-// particular URLRequestContext. It keeps a circular queue of the LoadLogs
-// for recently deceased requests.
-template<typename Request>
-class RequestTracker {
- public:
- struct RecentRequestInfo {
- GURL original_url;
- scoped_refptr<net::LoadLog> load_log;
- };
-
- // Helper class to make Request insertable into a base::LinkedList,
- // without making the public interface expose base::LinkNode.
- class Node : public base::LinkNode<Node> {
- public:
- Node(Request* request) : request_(request) {}
- ~Node() {}
-
- Request* request() const { return request_; }
-
- private:
- Request* request_;
- };
-
- typedef std::vector<RecentRequestInfo> RecentRequestInfoList;
- typedef bool (*RecentRequestsFilterFunc)(const GURL&);
-
- // The maximum number of entries for |graveyard_|, when in bounded mode.
- static const size_t kMaxGraveyardSize;
-
- // The maximum size of URLs to stuff into RecentRequestInfo, when in bounded
- // mode.
- static const size_t kMaxGraveyardURLSize;
-
- // The maximum number of entries to use for LoadLogs when in bounded mode.
- static const size_t kBoundedLoadLogMaxEntries;
-
- RequestTracker()
- : next_graveyard_index_(0),
- graveyard_filter_func_(NULL),
- is_unbounded_(false) {
- }
-
- ~RequestTracker() {}
-
- // Returns a list of Requests that are alive.
- std::vector<Request*> GetLiveRequests() {
- std::vector<Request*> list;
- for (base::LinkNode<Node>* node = live_instances_.head();
- node != live_instances_.end();
- node = node->next()) {
- Request* request = node->value()->request();
- list.push_back(request);
- }
- return list;
- }
-
- // Clears the circular buffer of RecentRequestInfos.
- void ClearRecentlyDeceased() {
- next_graveyard_index_ = 0;
- graveyard_.clear();
- }
-
- // Returns a list of recently completed Requests.
- const RecentRequestInfoList GetRecentlyDeceased() {
- RecentRequestInfoList list;
-
- // Copy the items from |graveyard_| (our circular queue of recently
- // deceased request infos) into a vector, ordered from oldest to newest.
- for (size_t i = 0; i < graveyard_.size(); ++i) {
- size_t index = (next_graveyard_index_ + i) % graveyard_.size();
- list.push_back(graveyard_[index]);
- }
- return list;
- }
-
- void Add(Request* request) {
- live_instances_.Append(&request->request_tracker_node_);
- }
-
- void Remove(Request* request) {
- // Remove from |live_instances_|.
- request->request_tracker_node_.RemoveFromList();
-
- RecentRequestInfo info;
- request->GetInfoForTracker(&info);
-
- if (!is_unbounded_) {
- // Paranoia check: truncate |info.original_url| if it is really big.
- const std::string& spec = info.original_url.possibly_invalid_spec();
- if (spec.size() > kMaxGraveyardURLSize)
- info.original_url = GURL(spec.substr(0, kMaxGraveyardURLSize));
- }
-
- if (ShouldInsertIntoGraveyard(info)) {
- // Add into |graveyard_|.
- InsertIntoGraveyard(info);
- }
- }
-
- // This function lets you exclude requests from being saved to the graveyard.
- // The graveyard is a circular buffer of the most recently completed
- // requests. Pass NULL turn off filtering. Otherwise pass in a function
- // returns false to exclude requests, true otherwise.
- void SetGraveyardFilter(RecentRequestsFilterFunc filter_func) {
- graveyard_filter_func_ = filter_func;
- }
-
- bool IsUnbounded() const {
- return is_unbounded_;
- }
-
- void SetUnbounded(bool unbounded) {
- // No change.
- if (is_unbounded_ == unbounded)
- return;
-
- // If we are going from unbounded to bounded, we need to trim the
- // graveyard. For simplicity we will simply clear it.
- if (is_unbounded_ && !unbounded)
- ClearRecentlyDeceased();
-
- is_unbounded_ = unbounded;
- }
-
- // Creates a LoadLog using the unbounded/bounded constraints that
- // apply to this tracker.
- net::LoadLog* CreateLoadLog() {
- if (IsUnbounded())
- return new net::LoadLog(net::LoadLog::kUnbounded);
- return new net::LoadLog(kBoundedLoadLogMaxEntries);
- }
-
- private:
- bool ShouldInsertIntoGraveyard(const RecentRequestInfo& info) {
- if (!graveyard_filter_func_)
- return true;
- return graveyard_filter_func_(info.original_url);
- }
-
- void InsertIntoGraveyard(const RecentRequestInfo& info) {
- if (is_unbounded_) {
- graveyard_.push_back(info);
- return;
- }
-
- // Otherwise enforce a bound on the graveyard size, by treating it as a
- // circular buffer.
- if (graveyard_.size() < kMaxGraveyardSize) {
- // Still growing to maximum capacity.
- DCHECK_EQ(next_graveyard_index_, graveyard_.size());
- graveyard_.push_back(info);
- } else {
- // At maximum capacity, overwite the oldest entry.
- graveyard_[next_graveyard_index_] = info;
- }
- next_graveyard_index_ = (next_graveyard_index_ + 1) % kMaxGraveyardSize;
- }
-
- base::LinkedList<Node> live_instances_;
-
- size_t next_graveyard_index_;
- RecentRequestInfoList graveyard_;
- RecentRequestsFilterFunc graveyard_filter_func_;
- bool is_unbounded_;
-};
-
-template<typename Request>
-const size_t RequestTracker<Request>::kMaxGraveyardSize = 25;
-
-template<typename Request>
-const size_t RequestTracker<Request>::kMaxGraveyardURLSize = 1000;
-
-template<typename Request>
-const size_t RequestTracker<Request>::kBoundedLoadLogMaxEntries = 50;
-
-#endif // NET_URL_REQUEST_REQUEST_TRACKER_H_
diff --git a/net/url_request/request_tracker_unittest.cc b/net/url_request/request_tracker_unittest.cc
deleted file mode 100644
index 633c923..0000000
--- a/net/url_request/request_tracker_unittest.cc
+++ /dev/null
@@ -1,266 +0,0 @@
-// Copyright (c) 2006-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.
-
-#include "net/url_request/request_tracker.h"
-
-#include "base/compiler_specific.h"
-#include "base/format_macros.h"
-#include "base/string_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-static const int kMaxNumLoadLogEntries = 1;
-
-class TestRequest {
- public:
- explicit TestRequest(const GURL& url)
- : url_(url),
- load_log_(new net::LoadLog(kMaxNumLoadLogEntries)),
- ALLOW_THIS_IN_INITIALIZER_LIST(request_tracker_node_(this)) {}
- ~TestRequest() {}
-
- // This method is used in RequestTrackerTest::Basic test.
- const GURL& original_url() const { return url_; }
-
- private:
- // RequestTracker<T> will access GetRecentRequestInfo() and
- // |request_tracker_node_|.
- friend class RequestTracker<TestRequest>;
-
- void GetInfoForTracker(
- RequestTracker<TestRequest>::RecentRequestInfo* info) const {
- info->original_url = url_;
- info->load_log = load_log_;
- }
-
- const GURL url_;
- scoped_refptr<net::LoadLog> load_log_;
-
- RequestTracker<TestRequest>::Node request_tracker_node_;
-
- DISALLOW_COPY_AND_ASSIGN(TestRequest);
-};
-
-
-TEST(RequestTrackerTest, BasicBounded) {
- RequestTracker<TestRequest> tracker;
- EXPECT_FALSE(tracker.IsUnbounded());
- EXPECT_EQ(0u, tracker.GetLiveRequests().size());
- EXPECT_EQ(0u, tracker.GetRecentlyDeceased().size());
-
- TestRequest req1(GURL("http://req1"));
- TestRequest req2(GURL("http://req2"));
- TestRequest req3(GURL("http://req3"));
- TestRequest req4(GURL("http://req4"));
- TestRequest req5(GURL("http://req5"));
-
- tracker.Add(&req1);
- tracker.Add(&req2);
- tracker.Add(&req3);
- tracker.Add(&req4);
- tracker.Add(&req5);
-
- std::vector<TestRequest*> live_reqs = tracker.GetLiveRequests();
-
- ASSERT_EQ(5u, live_reqs.size());
- EXPECT_EQ(GURL("http://req1"), live_reqs[0]->original_url());
- EXPECT_EQ(GURL("http://req2"), live_reqs[1]->original_url());
- EXPECT_EQ(GURL("http://req3"), live_reqs[2]->original_url());
- EXPECT_EQ(GURL("http://req4"), live_reqs[3]->original_url());
- EXPECT_EQ(GURL("http://req5"), live_reqs[4]->original_url());
-
- tracker.Remove(&req1);
- tracker.Remove(&req5);
- tracker.Remove(&req3);
-
- ASSERT_EQ(3u, tracker.GetRecentlyDeceased().size());
-
- live_reqs = tracker.GetLiveRequests();
-
- ASSERT_EQ(2u, live_reqs.size());
- EXPECT_EQ(GURL("http://req2"), live_reqs[0]->original_url());
- EXPECT_EQ(GURL("http://req4"), live_reqs[1]->original_url());
-}
-
-TEST(RequestTrackerTest, GraveyardBounded) {
- RequestTracker<TestRequest> tracker;
- EXPECT_FALSE(tracker.IsUnbounded());
- EXPECT_EQ(0u, tracker.GetLiveRequests().size());
- EXPECT_EQ(0u, tracker.GetRecentlyDeceased().size());
-
- // Add twice as many requests as will fit in the graveyard.
- for (size_t i = 0;
- i < RequestTracker<TestRequest>::kMaxGraveyardSize * 2;
- ++i) {
- TestRequest req(GURL(StringPrintf("http://req%" PRIuS, i).c_str()));
- tracker.Add(&req);
- tracker.Remove(&req);
- }
-
- // Check that only the last |kMaxGraveyardSize| requests are in-memory.
-
- RequestTracker<TestRequest>::RecentRequestInfoList recent_reqs =
- tracker.GetRecentlyDeceased();
-
- ASSERT_EQ(RequestTracker<TestRequest>::kMaxGraveyardSize, recent_reqs.size());
-
- for (size_t i = 0; i < RequestTracker<TestRequest>::kMaxGraveyardSize; ++i) {
- size_t req_number = i + RequestTracker<TestRequest>::kMaxGraveyardSize;
- GURL url(StringPrintf("http://req%" PRIuS, req_number).c_str());
- EXPECT_EQ(url, recent_reqs[i].original_url);
- }
-}
-
-TEST(RequestTrackerTest, GraveyardUnbounded) {
- RequestTracker<TestRequest> tracker;
- EXPECT_FALSE(tracker.IsUnbounded());
- EXPECT_EQ(0u, tracker.GetLiveRequests().size());
- EXPECT_EQ(0u, tracker.GetRecentlyDeceased().size());
-
- tracker.SetUnbounded(true);
-
- EXPECT_TRUE(tracker.IsUnbounded());
-
- // Add twice as many requests as would fit in the bounded graveyard.
-
- size_t kMaxSize = RequestTracker<TestRequest>::kMaxGraveyardSize * 2;
- for (size_t i = 0; i < kMaxSize; ++i) {
- TestRequest req(GURL(StringPrintf("http://req%" PRIuS, i).c_str()));
- tracker.Add(&req);
- tracker.Remove(&req);
- }
-
- // Check that all of them got saved.
-
- RequestTracker<TestRequest>::RecentRequestInfoList recent_reqs =
- tracker.GetRecentlyDeceased();
-
- ASSERT_EQ(kMaxSize, recent_reqs.size());
-
- for (size_t i = 0; i < kMaxSize; ++i) {
- GURL url(StringPrintf("http://req%" PRIuS, i).c_str());
- EXPECT_EQ(url, recent_reqs[i].original_url);
- }
-}
-
-// Check that very long URLs are truncated.
-TEST(RequestTrackerTest, GraveyardURLBounded) {
- RequestTracker<TestRequest> tracker;
- EXPECT_FALSE(tracker.IsUnbounded());
-
- std::string big_url_spec("http://");
- big_url_spec.resize(2 * RequestTracker<TestRequest>::kMaxGraveyardURLSize,
- 'x');
- GURL big_url(big_url_spec);
- TestRequest req(big_url);
-
- tracker.Add(&req);
- tracker.Remove(&req);
-
- ASSERT_EQ(1u, tracker.GetRecentlyDeceased().size());
- // The +1 is because GURL canonicalizes with a trailing '/' ... maybe
- // we should just save the std::string rather than the GURL.
- EXPECT_EQ(RequestTracker<TestRequest>::kMaxGraveyardURLSize + 1,
- tracker.GetRecentlyDeceased()[0].original_url.spec().size());
-}
-
-// Test the doesn't fail if the URL was invalid. http://crbug.com/21423.
-TEST(URLRequestTrackerTest, TrackingInvalidURL) {
- RequestTracker<TestRequest> tracker;
- EXPECT_FALSE(tracker.IsUnbounded());
-
- EXPECT_EQ(0u, tracker.GetLiveRequests().size());
- EXPECT_EQ(0u, tracker.GetRecentlyDeceased().size());
-
- GURL invalid_url("xabc");
- EXPECT_FALSE(invalid_url.is_valid());
- TestRequest req(invalid_url);
-
- tracker.Add(&req);
- tracker.Remove(&req);
-
- // Check that the invalid URL made it into graveyard.
- ASSERT_EQ(1u, tracker.GetRecentlyDeceased().size());
- EXPECT_FALSE(tracker.GetRecentlyDeceased()[0].original_url.is_valid());
-}
-
-bool ShouldRequestBeAddedToGraveyard(const GURL& url) {
- return !url.SchemeIs("chrome") && !url.SchemeIs("data");
-}
-
-// Check that we can exclude "chrome://" URLs and "data:" URLs from being
-// saved into the recent requests list (graveyard), by using a filter.
-TEST(RequestTrackerTest, GraveyardCanBeFiltered) {
- RequestTracker<TestRequest> tracker;
- EXPECT_FALSE(tracker.IsUnbounded());
-
- tracker.SetGraveyardFilter(ShouldRequestBeAddedToGraveyard);
-
- // This will be excluded.
- GURL url1("chrome://dontcare/");
- TestRequest req1(url1);
- tracker.Add(&req1);
- tracker.Remove(&req1);
-
- // This will be be added to graveyard.
- GURL url2("chrome2://dontcare/");
- TestRequest req2(url2);
- tracker.Add(&req2);
- tracker.Remove(&req2);
-
- // This will be be added to graveyard.
- GURL url3("http://foo/");
- TestRequest req3(url3);
- tracker.Add(&req3);
- tracker.Remove(&req3);
-
- // This will be be excluded.
- GURL url4("data:sup");
- TestRequest req4(url4);
- tracker.Add(&req4);
- tracker.Remove(&req4);
-
- ASSERT_EQ(2u, tracker.GetRecentlyDeceased().size());
- EXPECT_EQ(url2, tracker.GetRecentlyDeceased()[0].original_url);
- EXPECT_EQ(url3, tracker.GetRecentlyDeceased()[1].original_url);
-}
-
-// Convert an unbounded tracker back to being bounded.
-TEST(RequestTrackerTest, ConvertUnboundedToBounded) {
- RequestTracker<TestRequest> tracker;
- EXPECT_FALSE(tracker.IsUnbounded());
- EXPECT_EQ(0u, tracker.GetLiveRequests().size());
- EXPECT_EQ(0u, tracker.GetRecentlyDeceased().size());
-
- tracker.SetUnbounded(true);
- EXPECT_TRUE(tracker.IsUnbounded());
-
- // Add twice as many requests as would fit in the bounded graveyard.
-
- size_t kMaxSize = RequestTracker<TestRequest>::kMaxGraveyardSize * 2;
- for (size_t i = 0; i < kMaxSize; ++i) {
- TestRequest req(GURL(StringPrintf("http://req%" PRIuS, i).c_str()));
- tracker.Add(&req);
- tracker.Remove(&req);
- }
-
- // Check that all of them got saved.
- ASSERT_EQ(kMaxSize, tracker.GetRecentlyDeceased().size());
-
- // Now make the tracker bounded, and add more entries to its graveyard.
- tracker.SetUnbounded(false);
-
- kMaxSize = RequestTracker<TestRequest>::kMaxGraveyardSize;
- for (size_t i = 0; i < kMaxSize; ++i) {
- TestRequest req(GURL(StringPrintf("http://req%" PRIuS, i).c_str()));
- tracker.Add(&req);
- tracker.Remove(&req);
- }
-
- // We should only have kMaxGraveyardSize entries now.
- ASSERT_EQ(kMaxSize, tracker.GetRecentlyDeceased().size());
-}
-
-} // namespace
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
index 5c4566e..a44792d 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -9,8 +9,8 @@
#include "base/singleton.h"
#include "base/stats_counters.h"
#include "net/base/load_flags.h"
-#include "net/base/load_log.h"
#include "net/base/net_errors.h"
+#include "net/base/net_log.h"
#include "net/base/ssl_cert_request_info.h"
#include "net/base/upload_data.h"
#include "net/http/http_response_headers.h"
@@ -44,8 +44,7 @@ URLRequest::URLRequest(const GURL& url, Delegate* delegate)
enable_profiling_(false),
redirect_limit_(kMaxRedirects),
final_upload_progress_(0),
- priority_(net::LOWEST),
- ALLOW_THIS_IN_INITIALIZER_LIST(request_tracker_node_(this)) {
+ priority_(net::LOWEST) {
SIMPLE_STATS_COUNTER("URLRequestCount");
// Sanity check out environment.
@@ -256,7 +255,7 @@ void URLRequest::StartJob(URLRequestJob* job) {
DCHECK(!is_pending_);
DCHECK(!job_);
- net::LoadLog::BeginEvent(load_log_, net::LoadLog::TYPE_URL_REQUEST_START);
+ net_log_.BeginEvent(net::NetLog::TYPE_URL_REQUEST_START);
job_ = job;
job_->SetExtraRequestHeaders(extra_request_headers_);
@@ -363,9 +362,9 @@ void URLRequest::ReceivedRedirect(const GURL& location, bool* defer_redirect) {
void URLRequest::ResponseStarted() {
if (!status_.is_success())
- net::LoadLog::AddErrorCode(load_log_, status_.os_error());
+ net_log_.AddErrorCode(status_.os_error());
- net::LoadLog::EndEvent(load_log_, net::LoadLog::TYPE_URL_REQUEST_START);
+ net_log_.EndEvent(net::NetLog::TYPE_URL_REQUEST_START);
URLRequestJob* job = GetJobManager()->MaybeInterceptResponse(this);
if (job) {
@@ -438,8 +437,8 @@ std::string URLRequest::StripPostSpecificHeaders(const std::string& headers) {
}
int URLRequest::Redirect(const GURL& location, int http_status_code) {
- if (net::LoadLog::IsUnbounded(load_log_)) {
- net::LoadLog::AddString(load_log_, StringPrintf("Redirected (%d) to %s",
+ if (net_log_.HasListener()) {
+ net_log_.AddString(StringPrintf("Redirected (%d) to %s",
http_status_code, location.spec().c_str()));
}
if (redirect_limit_ <= 0) {
@@ -504,18 +503,17 @@ void URLRequest::set_context(URLRequestContext* context) {
context_ = context;
- // If the context this request belongs to has changed, update the tracker(s).
+ // If the context this request belongs to has changed, update the tracker.
if (prev_context != context) {
- if (prev_context)
- prev_context->url_request_tracker()->Remove(this);
+ net_log_.EndEvent(net::NetLog::TYPE_REQUEST_ALIVE);
+ net_log_ = net::BoundNetLog();
+
if (context) {
- if (!load_log_) {
- // Create the LoadLog -- we waited until now to create it so we know
- // what constraints the URLRequestContext is enforcing on log levels.
- load_log_ = context->url_request_tracker()->CreateLoadLog();
- }
+ net_log_ = net::BoundNetLog::Make(context->net_log(),
+ net::NetLog::SOURCE_URL_REQUEST);
- context->url_request_tracker()->Add(this);
+ net_log_.BeginEventWithString(net::NetLog::TYPE_REQUEST_ALIVE,
+ original_url_.possibly_invalid_spec());
}
}
}
@@ -538,10 +536,3 @@ URLRequest::UserData* URLRequest::GetUserData(const void* key) const {
void URLRequest::SetUserData(const void* key, UserData* data) {
user_data_[key] = linked_ptr<UserData>(data);
}
-
-void URLRequest::GetInfoForTracker(
- RequestTracker<URLRequest>::RecentRequestInfo* info) const {
- DCHECK(info);
- info->original_url = original_url_;
- info->load_log = load_log_;
-}
diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h
index c8bc2bf..81d2436 100644
--- a/net/url_request/url_request.h
+++ b/net/url_request/url_request.h
@@ -16,11 +16,10 @@
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "googleurl/src/gurl.h"
-#include "net/base/load_log.h"
#include "net/base/load_states.h"
+#include "net/base/net_log.h"
#include "net/base/request_priority.h"
#include "net/http/http_response_info.h"
-#include "net/url_request/request_tracker.h"
#include "net/url_request/url_request_status.h"
namespace base {
@@ -510,7 +509,7 @@ class URLRequest {
URLRequestContext* context();
void set_context(URLRequestContext* context);
- net::LoadLog* load_log() { return load_log_; }
+ const net::BoundNetLog& net_log() const { return net_log_; }
// Returns the expected content size if available
int64 GetExpectedContentSize() const;
@@ -551,7 +550,6 @@ class URLRequest {
private:
friend class URLRequestJob;
- friend class RequestTracker<URLRequest>;
void StartJob(URLRequestJob* job);
@@ -573,18 +571,13 @@ class URLRequest {
// Origin).
static std::string StripPostSpecificHeaders(const std::string& headers);
- // Gets the goodies out of this that we want to show the user later on the
- // chrome://net-internals/ page.
- void GetInfoForTracker(
- RequestTracker<URLRequest>::RecentRequestInfo* info) const;
-
// Contextual information used for this request (can be NULL). This contains
// most of the dependencies which are shared between requests (disk cache,
// cookie store, socket poool, etc.)
scoped_refptr<URLRequestContext> context_;
// Tracks the time spent in various load states throughout this request.
- scoped_refptr<net::LoadLog> load_log_;
+ net::BoundNetLog net_log_;
scoped_refptr<URLRequestJob> job_;
scoped_refptr<net::UploadData> upload_;
@@ -631,7 +624,6 @@ class URLRequest {
// this to determine which URLRequest to allocate sockets to first.
net::RequestPriority priority_;
- RequestTracker<URLRequest>::Node request_tracker_node_;
base::LeakTracker<URLRequest> leak_tracker_;
DISALLOW_COPY_AND_ASSIGN(URLRequest);
diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h
index fb2608f..070942f 100644
--- a/net/url_request/url_request_context.h
+++ b/net/url_request/url_request_context.h
@@ -14,11 +14,11 @@
#include "base/string_util.h"
#include "net/base/cookie_store.h"
#include "net/base/host_resolver.h"
+#include "net/base/net_log.h"
#include "net/base/ssl_config_service.h"
#include "net/base/transport_security_state.h"
#include "net/ftp/ftp_auth_cache.h"
#include "net/proxy/proxy_service.h"
-#include "net/url_request/request_tracker.h"
namespace net {
class CookiePolicy;
@@ -34,12 +34,17 @@ class URLRequestContext :
public base::RefCountedThreadSafe<URLRequestContext> {
public:
URLRequestContext()
- : http_transaction_factory_(NULL),
+ : net_log_(NULL),
+ http_transaction_factory_(NULL),
ftp_transaction_factory_(NULL),
cookie_policy_(NULL),
transport_security_state_(NULL) {
}
+ net::NetLog* net_log() const {
+ return net_log_;
+ }
+
net::HostResolver* host_resolver() const {
return host_resolver_;
}
@@ -90,16 +95,6 @@ class URLRequestContext :
// Gets the value of 'Accept-Language' header field.
const std::string& accept_language() const { return accept_language_; }
- // Gets the tracker for URLRequests associated with this context.
- RequestTracker<URLRequest>* url_request_tracker() {
- return &url_request_tracker_;
- }
-
- // Gets the tracker for SocketStreams associated with this context.
- RequestTracker<net::SocketStream>* socket_stream_tracker() {
- return &socket_stream_tracker_;
- }
-
// Gets the UA string to use for the given URL. Pass an invalid URL (such as
// GURL()) to get the default UA string. Subclasses should override this
// method to provide a UA string.
@@ -135,6 +130,7 @@ class URLRequestContext :
// The following members are expected to be initialized and owned by
// subclasses.
+ net::NetLog* net_log_;
scoped_refptr<net::HostResolver> host_resolver_;
scoped_refptr<net::ProxyService> proxy_service_;
scoped_refptr<net::SSLConfigService> ssl_config_service_;
@@ -152,12 +148,6 @@ class URLRequestContext :
// filename for file download.
std::string referrer_charset_;
- // Tracks the requests associated with this context.
- RequestTracker<URLRequest> url_request_tracker_;
-
- // Trakcs the socket streams associated with this context.
- RequestTracker<net::SocketStream> socket_stream_tracker_;
-
private:
DISALLOW_COPY_AND_ASSIGN(URLRequestContext);
};
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 8f2412e..783ee42 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -617,7 +617,7 @@ void URLRequestHttpJob::StartTransaction() {
&transaction_);
if (rv == net::OK) {
rv = transaction_->Start(
- &request_info_, &start_callback_, request_->load_log());
+ &request_info_, &start_callback_, request_->net_log());
}
}
diff --git a/net/url_request/url_request_new_ftp_job.cc b/net/url_request/url_request_new_ftp_job.cc
index 171eed9..1af7eda 100644
--- a/net/url_request/url_request_new_ftp_job.cc
+++ b/net/url_request/url_request_new_ftp_job.cc
@@ -225,7 +225,7 @@ void URLRequestNewFtpJob::StartTransaction() {
int rv;
if (transaction_.get()) {
rv = transaction_->Start(
- &request_info_, &start_callback_, request_->load_log());
+ &request_info_, &start_callback_, request_->net_log());
if (rv == net::ERR_IO_PENDING)
return;
} else {
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index a1f0cf5e..dc39667 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -26,8 +26,8 @@
#include "net/base/cookie_monster.h"
#include "net/base/cookie_policy.h"
#include "net/base/load_flags.h"
-#include "net/base/load_log.h"
-#include "net/base/load_log_unittest.h"
+#include "net/base/net_log.h"
+#include "net/base/net_log_unittest.h"
#include "net/base/net_errors.h"
#include "net/base/net_module.h"
#include "net/base/net_util.h"
@@ -217,16 +217,7 @@ TEST_F(URLRequestTestHTTP, GetTest_NoCache) {
EXPECT_FALSE(d.received_data_before_response());
EXPECT_NE(0, d.bytes_received());
- // The first part of the log will be for URL_REQUEST_START.
- // After that, there should be an HTTP_TRANSACTION_READ_BODY
- EXPECT_TRUE(net::LogContainsBeginEvent(
- *r.load_log(), 0, net::LoadLog::TYPE_URL_REQUEST_START));
- EXPECT_TRUE(net::LogContainsEndEvent(
- *r.load_log(), -3, net::LoadLog::TYPE_URL_REQUEST_START));
- EXPECT_TRUE(net::LogContainsBeginEvent(
- *r.load_log(), -2, net::LoadLog::TYPE_HTTP_TRANSACTION_READ_BODY));
- EXPECT_TRUE(net::LogContainsEndEvent(
- *r.load_log(), -1, net::LoadLog::TYPE_HTTP_TRANSACTION_READ_BODY));
+ // TODO(eroman): Add back the NetLog tests...
}
}