Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(653)

Unified Diff: net/http/http_cache_transaction.cc

Issue 4067002: First pass at adding http/backend cache to NetLog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Lint fixes Created 9 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_cache_transaction.h ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_transaction.cc
===================================================================
--- net/http/http_cache_transaction.cc (revision 70512)
+++ net/http/http_cache_transaction.cc (working copy)
@@ -398,6 +398,10 @@
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::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 @@
// 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 @@
// 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::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 @@
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 @@
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 @@
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::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::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 @@
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::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 @@
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::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::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_)
« no previous file with comments | « net/http/http_cache_transaction.h ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698