Commit ddd25bc4 authored by rtenneti's avatar rtenneti Committed by Commit bot

QUIC - track the open and close states of disk cache entries of

QuicServerInfo.

BUG=417835
R=rch@chromium.org, asvitkine@chromium.org

Review URL: https://codereview.chromium.org/618083003

Cr-Commit-Position: refs/heads/master@{#297776}
parent 479fb92f
......@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "net/base/completion_callback.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
......@@ -16,6 +17,18 @@
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,
};
void RecordDiskCacheEntryState(DiskCacheEntryState entry_state) {
UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.EntryState", entry_state,
DISK_CACHE_ENTRY_NUM_STATES);
}
// Some APIs inside disk_cache take a handle that the caller must keep alive
// until the API has finished its asynchronous execution.
//
......@@ -119,8 +132,10 @@ 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 {
......@@ -201,6 +216,7 @@ int DiskCacheBasedQuicServerInfo::DoOpenComplete(int rv) {
entry_ = data_shim_->entry;
state_ = READ;
found_entry_ = true;
RecordDiskCacheEntryState(DISK_CACHE_ENTRY_OPENED);
} else {
state_ = WAIT_FOR_DATA_READY_DONE;
}
......@@ -228,6 +244,7 @@ int DiskCacheBasedQuicServerInfo::DoCreateOrOpenComplete(int rv) {
if (!entry_) {
entry_ = data_shim_->entry;
found_entry_ = true;
RecordDiskCacheEntryState(DISK_CACHE_ENTRY_OPENED);
}
DCHECK(entry_);
state_ = WRITE;
......@@ -289,16 +306,20 @@ 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_);
return OK;
}
int DiskCacheBasedQuicServerInfo::DoSetDone() {
if (entry_)
if (entry_) {
entry_->Close();
RecordDiskCacheEntryState(DISK_CACHE_ENTRY_CLOSED);
}
entry_ = NULL;
new_data_.clear();
state_ = NONE;
......
......@@ -16836,6 +16836,14 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary>
</histogram>
<histogram name="Net.QuicDiskCache.EntryState" enum="QuicDiskCacheEntryState">
<owner>rtenneti@chromium.org</owner>
<summary>
Tracks the opening and closing of disk cache entries. Recorded each time a
disk cache entry is either opened or closed.
</summary>
</histogram>
<histogram name="Net.QuicEphemeralPortsSuggested">
<owner>rch@chromium.org</owner>
<summary>The number of ports suggested per server.</summary>
......@@ -49711,6 +49719,11 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="7" label="Address and port match: IPv6 IPv6"/>
</enum>
<enum name="QuicDiskCacheEntryState" type="int">
<int value="0" label="Opened"/>
<int value="1" label="Closed"/>
</enum>
<enum name="QuicErrorCodes" type="int">
<int value="0" label="NO_ERROR"/>
<int value="1" label="INTERNAL_ERROR"/>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment