diff options
Diffstat (limited to 'net/http')
-rw-r--r-- | net/http/http_basic_stream.cc | 5 | ||||
-rw-r--r-- | net/http/http_basic_stream.h | 4 | ||||
-rw-r--r-- | net/http/http_cache_transaction.cc | 36 | ||||
-rw-r--r-- | net/http/http_cache_transaction.h | 8 | ||||
-rw-r--r-- | net/http/http_cache_unittest.cc | 86 | ||||
-rw-r--r-- | net/http/http_network_layer_unittest.cc | 3 | ||||
-rw-r--r-- | net/http/http_network_transaction.cc | 66 | ||||
-rw-r--r-- | net/http/http_network_transaction.h | 7 | ||||
-rw-r--r-- | net/http/http_network_transaction_unittest.cc | 24 | ||||
-rw-r--r-- | net/http/http_stream_parser.cc | 10 | ||||
-rw-r--r-- | net/http/http_stream_parser.h | 6 | ||||
-rw-r--r-- | net/http/http_transaction.h | 6 | ||||
-rw-r--r-- | net/http/http_transaction_unittest.h | 7 |
13 files changed, 130 insertions, 138 deletions
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; |