Index: net/http/disk_cache_based_quic_server_info.cc |
diff --git a/net/http/disk_cache_based_quic_server_info.cc b/net/http/disk_cache_based_quic_server_info.cc |
index ab6b6c89ba39221ef2600b421dcde103b4a48b21..2e116daa027baa79ab9150ce91456b11d25ed87f 100644 |
--- a/net/http/disk_cache_based_quic_server_info.cc |
+++ b/net/http/disk_cache_based_quic_server_info.cc |
@@ -17,16 +17,42 @@ |
namespace net { |
-// Histogram for tracking down the state of disk_cache::Entry. |
-enum DiskCacheEntryState { |
- DISK_CACHE_ENTRY_OPENED = 0, |
- DISK_CACHE_ENTRY_CLOSED = 1, |
- DISK_CACHE_ENTRY_NUM_STATES = 2, |
+// Histogram that tracks number of times data read/parse/write API calls of |
+// QuicServerInfo to and from disk cache is called. |
+enum QuicServerInfoAPICall { |
+ QUIC_SERVER_INFO_START = 0, |
+ QUIC_SERVER_INFO_WAIT_FOR_DATA_READY = 1, |
+ QUIC_SERVER_INFO_PARSE = 2, |
+ QUIC_SERVER_INFO_WAIT_FOR_DATA_READY_CANCEL = 3, |
+ QUIC_SERVER_INFO_READY_TO_PERSIST = 4, |
+ QUIC_SERVER_INFO_PERSIST = 5, |
+ QUIC_SERVER_INFO_NUM_OF_API_CALLS = 6, |
}; |
-void RecordDiskCacheEntryState(DiskCacheEntryState entry_state) { |
- UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.EntryState", entry_state, |
- DISK_CACHE_ENTRY_NUM_STATES); |
+// Histogram that tracks failure reasons to read/load/write of QuicServerInfo to |
+// and from disk cache. |
+enum FailureReason { |
+ WAIT_FOR_DATA_READY_INVALID_ARGUMENT_FAILURE = 0, |
+ GET_BACKEND_FAILURE = 1, |
+ OPEN_FAILURE = 2, |
+ CREATE_OR_OPEN_FAILURE = 3, |
+ PARSE_NO_DATA_FAILURE = 4, |
+ PARSE_FAILURE = 5, |
+ READ_FAILURE = 6, |
+ READY_TO_PERSIST_FAILURE = 7, |
+ PERSIST_NO_BACKEND_FAILURE = 8, |
+ WRITE_FAILURE = 9, |
+ NUM_OF_FAILURES = 10, |
+}; |
+ |
+void RecordQuicServerInfoStatus(QuicServerInfoAPICall call) { |
+ UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.APICall", call, |
+ QUIC_SERVER_INFO_NUM_OF_API_CALLS); |
+} |
+ |
+void RecordQuicServerInfoFailure(FailureReason failure) { |
+ UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason", failure, |
+ NUM_OF_FAILURES); |
} |
// Some APIs inside disk_cache take a handle that the caller must keep alive |
@@ -78,6 +104,7 @@ DiskCacheBasedQuicServerInfo::DiskCacheBasedQuicServerInfo( |
void DiskCacheBasedQuicServerInfo::Start() { |
DCHECK(CalledOnValidThread()); |
DCHECK_EQ(GET_BACKEND, state_); |
+ RecordQuicServerInfoStatus(QUIC_SERVER_INFO_START); |
load_start_time_ = base::TimeTicks::Now(); |
DoLoop(OK); |
} |
@@ -87,14 +114,17 @@ int DiskCacheBasedQuicServerInfo::WaitForDataReady( |
DCHECK(CalledOnValidThread()); |
DCHECK_NE(GET_BACKEND, state_); |
+ RecordQuicServerInfoStatus(QUIC_SERVER_INFO_WAIT_FOR_DATA_READY); |
if (ready_) |
return OK; |
if (!callback.is_null()) { |
// Prevent a new callback for WaitForDataReady overwriting an existing |
// pending callback (|user_callback_|). |
- if (!user_callback_.is_null()) |
+ if (!user_callback_.is_null()) { |
+ RecordQuicServerInfoFailure(WAIT_FOR_DATA_READY_INVALID_ARGUMENT_FAILURE); |
return ERR_INVALID_ARGUMENT; |
+ } |
user_callback_ = callback; |
} |
@@ -104,6 +134,7 @@ int DiskCacheBasedQuicServerInfo::WaitForDataReady( |
void DiskCacheBasedQuicServerInfo::CancelWaitForDataReadyCallback() { |
DCHECK(CalledOnValidThread()); |
+ RecordQuicServerInfoStatus(QUIC_SERVER_INFO_WAIT_FOR_DATA_READY_CANCEL); |
if (!user_callback_.is_null()) |
user_callback_.Reset(); |
} |
@@ -119,7 +150,11 @@ bool DiskCacheBasedQuicServerInfo::IsReadyToPersist() { |
// |
// The data can be persisted if it has been loaded from the disk cache |
// and there are no pending writes. |
- return ready_ && new_data_.empty(); |
+ RecordQuicServerInfoStatus(QUIC_SERVER_INFO_READY_TO_PERSIST); |
+ if (ready_ && new_data_.empty()) |
+ return true; |
+ RecordQuicServerInfoFailure(READY_TO_PERSIST_FAILURE); |
+ return false; |
} |
void DiskCacheBasedQuicServerInfo::Persist() { |
@@ -131,8 +166,11 @@ void DiskCacheBasedQuicServerInfo::Persist() { |
DCHECK(user_callback_.is_null()); |
new_data_ = Serialize(); |
- if (!backend_) |
+ RecordQuicServerInfoStatus(QUIC_SERVER_INFO_PERSIST); |
+ if (!backend_) { |
+ RecordQuicServerInfoFailure(PERSIST_NO_BACKEND_FAILURE); |
return; |
+ } |
state_ = CREATE_OR_OPEN; |
DoLoop(OK); |
@@ -140,10 +178,8 @@ void DiskCacheBasedQuicServerInfo::Persist() { |
DiskCacheBasedQuicServerInfo::~DiskCacheBasedQuicServerInfo() { |
DCHECK(user_callback_.is_null()); |
- if (entry_) { |
+ if (entry_) |
entry_->Close(); |
- RecordDiskCacheEntryState(DISK_CACHE_ENTRY_CLOSED); |
- } |
} |
std::string DiskCacheBasedQuicServerInfo::key() const { |
@@ -214,6 +250,7 @@ int DiskCacheBasedQuicServerInfo::DoGetBackendComplete(int rv) { |
backend_ = data_shim_->backend; |
state_ = OPEN; |
} else { |
+ RecordQuicServerInfoFailure(GET_BACKEND_FAILURE); |
state_ = WAIT_FOR_DATA_READY_DONE; |
} |
return OK; |
@@ -224,8 +261,8 @@ int DiskCacheBasedQuicServerInfo::DoOpenComplete(int rv) { |
entry_ = data_shim_->entry; |
state_ = READ; |
found_entry_ = true; |
- RecordDiskCacheEntryState(DISK_CACHE_ENTRY_OPENED); |
} else { |
+ RecordQuicServerInfoFailure(OPEN_FAILURE); |
state_ = WAIT_FOR_DATA_READY_DONE; |
} |
@@ -235,24 +272,28 @@ int DiskCacheBasedQuicServerInfo::DoOpenComplete(int rv) { |
int DiskCacheBasedQuicServerInfo::DoReadComplete(int rv) { |
if (rv > 0) |
data_.assign(read_buffer_->data(), rv); |
+ else if (rv < 0) |
+ RecordQuicServerInfoFailure(READ_FAILURE); |
state_ = WAIT_FOR_DATA_READY_DONE; |
return OK; |
} |
int DiskCacheBasedQuicServerInfo::DoWriteComplete(int rv) { |
+ if (rv < 0) |
+ RecordQuicServerInfoFailure(WRITE_FAILURE); |
state_ = SET_DONE; |
return OK; |
} |
int DiskCacheBasedQuicServerInfo::DoCreateOrOpenComplete(int rv) { |
if (rv != OK) { |
+ RecordQuicServerInfoFailure(CREATE_OR_OPEN_FAILURE); |
state_ = SET_DONE; |
} else { |
if (!entry_) { |
entry_ = data_shim_->entry; |
found_entry_ = true; |
- RecordDiskCacheEntryState(DISK_CACHE_ENTRY_OPENED); |
} |
DCHECK(entry_); |
state_ = WRITE; |
@@ -314,22 +355,26 @@ int DiskCacheBasedQuicServerInfo::DoWaitForDataReadyDone() { |
ready_ = true; |
// We close the entry because, if we shutdown before ::Persist is called, |
// then we might leak a cache reference, which causes a DCHECK on shutdown. |
- if (entry_) { |
+ if (entry_) |
entry_->Close(); |
- RecordDiskCacheEntryState(DISK_CACHE_ENTRY_CLOSED); |
- } |
entry_ = NULL; |
- Parse(data_); |
+ |
+ RecordQuicServerInfoStatus(QUIC_SERVER_INFO_PARSE); |
+ if (!Parse(data_)) { |
+ if (data_.empty()) |
+ RecordQuicServerInfoFailure(PARSE_NO_DATA_FAILURE); |
+ else |
+ RecordQuicServerInfoFailure(PARSE_FAILURE); |
+ } |
+ |
UMA_HISTOGRAM_TIMES("Net.QuicServerInfo.DiskCacheLoadTime", |
base::TimeTicks::Now() - load_start_time_); |
return OK; |
} |
int DiskCacheBasedQuicServerInfo::DoSetDone() { |
- if (entry_) { |
+ if (entry_) |
entry_->Close(); |
- RecordDiskCacheEntryState(DISK_CACHE_ENTRY_CLOSED); |
- } |
entry_ = NULL; |
new_data_.clear(); |
state_ = NONE; |