diff options
author | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-06 19:01:03 +0000 |
---|---|---|
committer | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-06 19:01:03 +0000 |
commit | 5cc9eeb8555cce33bf9f098b207fc9b082a6f408 (patch) | |
tree | 96a259ffb2f7482ff739a28f3b90f68e91d5d383 /net/http/http_cache_transaction.cc | |
parent | 0b0c493346da0268d3e25ebafaa5a0eae6bc46ee (diff) | |
download | chromium_src-5cc9eeb8555cce33bf9f098b207fc9b082a6f408.zip chromium_src-5cc9eeb8555cce33bf9f098b207fc9b082a6f408.tar.gz chromium_src-5cc9eeb8555cce33bf9f098b207fc9b082a6f408.tar.bz2 |
First pass at adding http/backend cache events to the NetLog.
Adds sources and events for ActiveCacheEntry and EntryImpl
objects, as well as adding cache read/write events to
HttpCacheTransactions. Most new read/write events are
only logged when NetLog logging mode is set to log all events.
Also, net-internals now merges begin and end events that have
parameters, as long as only one of them has parameters.
I think this increases readability, at the cost of making
it a little more difficult to follow timings with just the "st"
values.
BUG=59382
TEST=none yet, other than updates to existing tests.
Originally applied: http://src.chromium.org/viewvc/chrome?view=rev&revision=70618
Reverted: http://src.chromium.org/viewvc/chrome?view=rev&revision=70619
Fixed and trying again...
Review URL: http://codereview.chromium.org/6125001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70628 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_cache_transaction.cc')
-rw-r--r-- | net/http/http_cache_transaction.cc | 60 |
1 files changed, 51 insertions, 9 deletions
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc index d795c83..b506edc 100644 --- a/net/http/http_cache_transaction.cc +++ b/net/http/http_cache_transaction.cc @@ -398,6 +398,10 @@ LoadState HttpCache::Transaction::GetWriterLoadState() const { return LOAD_STATE_WAITING_FOR_CACHE; } +const BoundNetLog& HttpCache::Transaction::net_log() const { + return net_log_; +} + //----------------------------------------------------------------------------- void HttpCache::Transaction::DoCallback(int rv) { @@ -579,13 +583,14 @@ int HttpCache::Transaction::DoLoop(int result) { int HttpCache::Transaction::DoGetBackend() { cache_pending_ = true; next_state_ = STATE_GET_BACKEND_COMPLETE; - net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WAITING, NULL); + net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_GET_BACKEND, NULL); return cache_->GetBackendForTransaction(this); } int HttpCache::Transaction::DoGetBackendComplete(int result) { DCHECK(result == OK || result == ERR_FAILED); - net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_WAITING, NULL); + net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_GET_BACKEND, + result); cache_pending_ = false; if (!ShouldPassThrough()) { @@ -757,7 +762,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. - net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY, NULL); + net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY, result); cache_pending_ = false; if (result == OK) { next_state_ = STATE_ADD_TO_ENTRY; @@ -800,7 +805,8 @@ 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. - net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY, NULL); + net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY, + result); cache_pending_ = false; next_state_ = STATE_ADD_TO_ENTRY; @@ -831,7 +837,7 @@ int HttpCache::Transaction::DoDoomEntry() { } int HttpCache::Transaction::DoDoomEntryComplete(int result) { - net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY, NULL); + net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY, result); next_state_ = STATE_CREATE_ENTRY; cache_pending_ = false; if (result == ERR_CACHE_RACE) @@ -844,14 +850,15 @@ int HttpCache::Transaction::DoAddToEntry() { DCHECK(new_entry_); cache_pending_ = true; next_state_ = STATE_ADD_TO_ENTRY_COMPLETE; - net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WAITING, NULL); + net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY, NULL); DCHECK(entry_lock_waiting_since_.is_null()); entry_lock_waiting_since_ = base::TimeTicks::Now(); return cache_->AddTransactionToEntry(new_entry_, this); } int HttpCache::Transaction::DoAddToEntryComplete(int result) { - net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_WAITING, NULL); + net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY, + result); const base::TimeDelta entry_lock_wait = base::TimeTicks::Now() - entry_lock_waiting_since_; @@ -1002,12 +1009,19 @@ int HttpCache::Transaction::DoTruncateCachedData() { cache_callback_->AddRef(); // Balanced in DoTruncateCachedDataComplete. if (!entry_) return OK; + if (net_log_.IsLoggingAllEvents()) + net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, NULL); // Truncate the stream. return WriteToEntry(kResponseContentIndex, 0, NULL, 0, cache_callback_); } int HttpCache::Transaction::DoTruncateCachedDataComplete(int result) { + if (net_log_.IsLoggingAllEvents() && entry_) { + net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, + result); + } + // Balance the AddRef from DoTruncateCachedData. cache_callback_->Release(); next_state_ = STATE_TRUNCATE_CACHED_METADATA; @@ -1020,10 +1034,17 @@ int HttpCache::Transaction::DoTruncateCachedMetadata() { if (!entry_) return OK; + if (net_log_.IsLoggingAllEvents()) + net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, NULL); return WriteToEntry(kMetadataIndex, 0, NULL, 0, cache_callback_); } int HttpCache::Transaction::DoTruncateCachedMetadataComplete(int result) { + if (net_log_.IsLoggingAllEvents() && entry_) { + net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, + result); + } + // Balance the AddRef from DoTruncateCachedMetadata. cache_callback_->Release(); @@ -1073,7 +1094,7 @@ int HttpCache::Transaction::DoCacheReadResponse() { int HttpCache::Transaction::DoCacheReadResponseComplete(int result) { cache_callback_->Release(); // Balance the AddRef from DoCacheReadResponse. - net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO, NULL); + net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_INFO, result); if (result != io_buf_len_ || !HttpCache::ParseResponseInfo(read_buf_->data(), io_buf_len_, &response_, &truncated_)) { @@ -1113,10 +1134,14 @@ int HttpCache::Transaction::DoCacheReadResponseComplete(int result) { } int HttpCache::Transaction::DoCacheWriteResponse() { + if (net_log_.IsLoggingAllEvents() && entry_) + net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, NULL); return WriteResponseInfoToEntry(false); } int HttpCache::Transaction::DoCacheWriteTruncatedResponse() { + if (net_log_.IsLoggingAllEvents() && entry_) + net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, NULL); return WriteResponseInfoToEntry(true); } @@ -1125,6 +1150,10 @@ int HttpCache::Transaction::DoCacheWriteResponseComplete(int result) { target_state_ = STATE_NONE; if (!entry_) return OK; + if (net_log_.IsLoggingAllEvents()) { + net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, + result); + } // Balance the AddRef from WriteResponseInfoToEntry. write_headers_callback_->Release(); @@ -1152,7 +1181,7 @@ int HttpCache::Transaction::DoCacheReadMetadata() { int HttpCache::Transaction::DoCacheReadMetadataComplete(int result) { cache_callback_->Release(); // Balance the AddRef from DoCacheReadMetadata. - net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO, NULL); + net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_INFO, result); if (result != response_.metadata->size()) { DLOG(ERROR) << "ReadData failed: " << result; return ERR_CACHE_READ_FAILURE; @@ -1183,6 +1212,9 @@ int HttpCache::Transaction::DoCacheReadData() { DCHECK(entry_); next_state_ = STATE_CACHE_READ_DATA_COMPLETE; cache_callback_->AddRef(); // Balanced in DoCacheReadDataComplete. + + if (net_log_.IsLoggingAllEvents()) + net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_DATA, NULL); if (partial_.get()) { return partial_->CacheRead(entry_->disk_entry, read_buf_, io_buf_len_, cache_callback_); @@ -1194,6 +1226,10 @@ int HttpCache::Transaction::DoCacheReadData() { int HttpCache::Transaction::DoCacheReadDataComplete(int result) { cache_callback_->Release(); // Balance the AddRef from DoCacheReadData. + if (net_log_.IsLoggingAllEvents()) { + net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_DATA, + result); + } if (!cache_) return ERR_UNEXPECTED; @@ -1213,12 +1249,18 @@ int HttpCache::Transaction::DoCacheReadDataComplete(int result) { int HttpCache::Transaction::DoCacheWriteData(int num_bytes) { next_state_ = STATE_CACHE_WRITE_DATA_COMPLETE; write_len_ = num_bytes; + if (net_log_.IsLoggingAllEvents() && entry_) + net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, NULL); cache_callback_->AddRef(); // Balanced in DoCacheWriteDataComplete. return AppendResponseDataToEntry(read_buf_, num_bytes, cache_callback_); } int HttpCache::Transaction::DoCacheWriteDataComplete(int result) { + if (net_log_.IsLoggingAllEvents() && entry_) { + net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, + result); + } // Balance the AddRef from DoCacheWriteData. cache_callback_->Release(); if (!cache_) |