Commit f90a0855 authored by Oscar Johansson's avatar Oscar Johansson Committed by Commit Bot

Resolve issues with WRITE_RESULT constants (net/)

When building using jumbo the WRITE_RESULT constants
defined in net/disk_cache/memory/mem_entry_impl.cc
and in net/disk_cache/simple/simple_entry_impl.cc
conflict with each other.

This commit solves the issue by renaming the constants to
something more file specific.

Bug: 772146
Change-Id: I118bea2e4943983975640ce178a48adb597f25f3
Reviewed-on: https://chromium-review.googlesource.com/1117066Reviewed-by: default avatarJosh Karlin <jkarlin@chromium.org>
Commit-Queue: Oscar Johansson <oscarj@opera.com>
Cr-Commit-Position: refs/heads/master@{#571042}
parent fb40db12
...@@ -35,16 +35,17 @@ const int kMaxSparseEntryBits = 12; ...@@ -35,16 +35,17 @@ const int kMaxSparseEntryBits = 12;
const int kMaxSparseEntrySize = 1 << kMaxSparseEntryBits; const int kMaxSparseEntrySize = 1 << kMaxSparseEntryBits;
// This enum is used for histograms, so only append to the end. // This enum is used for histograms, so only append to the end.
enum WriteResult { enum MemEntryWriteResult {
WRITE_RESULT_SUCCESS = 0, MEM_ENTRY_WRITE_RESULT_SUCCESS = 0,
WRITE_RESULT_INVALID_ARGUMENT = 1, MEM_ENTRY_WRITE_RESULT_INVALID_ARGUMENT = 1,
WRITE_RESULT_OVER_MAX_ENTRY_SIZE = 2, MEM_ENTRY_WRITE_RESULT_OVER_MAX_ENTRY_SIZE = 2,
WRITE_RESULT_EXCEEDED_CACHE_STORAGE_SIZE = 3, MEM_ENTRY_WRITE_RESULT_EXCEEDED_CACHE_STORAGE_SIZE = 3,
WRITE_RESULT_MAX = 4, MEM_ENTRY_WRITE_RESULT_MAX = 4,
}; };
void RecordWriteResult(WriteResult result) { void RecordWriteResult(MemEntryWriteResult result) {
UMA_HISTOGRAM_ENUMERATION("MemCache.WriteResult", result, WRITE_RESULT_MAX); UMA_HISTOGRAM_ENUMERATION("MemCache.WriteResult", result,
MEM_ENTRY_WRITE_RESULT_MAX);
} }
// Convert global offset to child index. // Convert global offset to child index.
...@@ -367,17 +368,17 @@ int MemEntryImpl::InternalWriteData(int index, int offset, IOBuffer* buf, ...@@ -367,17 +368,17 @@ int MemEntryImpl::InternalWriteData(int index, int offset, IOBuffer* buf,
if (!backend_) { if (!backend_) {
// We have to fail writes after the backend is destroyed since we can't // We have to fail writes after the backend is destroyed since we can't
// ensure we wouldn't use too much memory if it's gone. // ensure we wouldn't use too much memory if it's gone.
RecordWriteResult(WRITE_RESULT_EXCEEDED_CACHE_STORAGE_SIZE); RecordWriteResult(MEM_ENTRY_WRITE_RESULT_EXCEEDED_CACHE_STORAGE_SIZE);
return net::ERR_INSUFFICIENT_RESOURCES; return net::ERR_INSUFFICIENT_RESOURCES;
} }
if (index < 0 || index >= kNumStreams) { if (index < 0 || index >= kNumStreams) {
RecordWriteResult(WRITE_RESULT_INVALID_ARGUMENT); RecordWriteResult(MEM_ENTRY_WRITE_RESULT_INVALID_ARGUMENT);
return net::ERR_INVALID_ARGUMENT; return net::ERR_INVALID_ARGUMENT;
} }
if (offset < 0 || buf_len < 0) { if (offset < 0 || buf_len < 0) {
RecordWriteResult(WRITE_RESULT_INVALID_ARGUMENT); RecordWriteResult(MEM_ENTRY_WRITE_RESULT_INVALID_ARGUMENT);
return net::ERR_INVALID_ARGUMENT; return net::ERR_INVALID_ARGUMENT;
} }
...@@ -386,7 +387,7 @@ int MemEntryImpl::InternalWriteData(int index, int offset, IOBuffer* buf, ...@@ -386,7 +387,7 @@ int MemEntryImpl::InternalWriteData(int index, int offset, IOBuffer* buf,
// offset of buf_len could be negative numbers. // offset of buf_len could be negative numbers.
if (offset > max_file_size || buf_len > max_file_size || if (offset > max_file_size || buf_len > max_file_size ||
offset + buf_len > max_file_size) { offset + buf_len > max_file_size) {
RecordWriteResult(WRITE_RESULT_OVER_MAX_ENTRY_SIZE); RecordWriteResult(MEM_ENTRY_WRITE_RESULT_OVER_MAX_ENTRY_SIZE);
return net::ERR_FAILED; return net::ERR_FAILED;
} }
...@@ -396,7 +397,7 @@ int MemEntryImpl::InternalWriteData(int index, int offset, IOBuffer* buf, ...@@ -396,7 +397,7 @@ int MemEntryImpl::InternalWriteData(int index, int offset, IOBuffer* buf,
backend_->ModifyStorageSize(delta); backend_->ModifyStorageSize(delta);
if (backend_->HasExceededStorageSize()) { if (backend_->HasExceededStorageSize()) {
backend_->ModifyStorageSize(-delta); backend_->ModifyStorageSize(-delta);
RecordWriteResult(WRITE_RESULT_EXCEEDED_CACHE_STORAGE_SIZE); RecordWriteResult(MEM_ENTRY_WRITE_RESULT_EXCEEDED_CACHE_STORAGE_SIZE);
return net::ERR_INSUFFICIENT_RESOURCES; return net::ERR_INSUFFICIENT_RESOURCES;
} }
...@@ -410,7 +411,7 @@ int MemEntryImpl::InternalWriteData(int index, int offset, IOBuffer* buf, ...@@ -410,7 +411,7 @@ int MemEntryImpl::InternalWriteData(int index, int offset, IOBuffer* buf,
} }
UpdateStateOnUse(ENTRY_WAS_MODIFIED); UpdateStateOnUse(ENTRY_WAS_MODIFIED);
RecordWriteResult(WRITE_RESULT_SUCCESS); RecordWriteResult(MEM_ENTRY_WRITE_RESULT_SUCCESS);
if (!buf_len) if (!buf_len)
return 0; return 0;
......
...@@ -45,14 +45,14 @@ namespace { ...@@ -45,14 +45,14 @@ namespace {
const int64_t kMaxSparseDataSizeDivisor = 10; const int64_t kMaxSparseDataSizeDivisor = 10;
// Used in histograms, please only add entries at the end. // Used in histograms, please only add entries at the end.
enum WriteResult { enum SimpleEntryWriteResult {
WRITE_RESULT_SUCCESS = 0, SIMPLE_ENTRY_WRITE_RESULT_SUCCESS = 0,
WRITE_RESULT_INVALID_ARGUMENT = 1, SIMPLE_ENTRY_WRITE_RESULT_INVALID_ARGUMENT = 1,
WRITE_RESULT_OVER_MAX_SIZE = 2, SIMPLE_ENTRY_WRITE_RESULT_OVER_MAX_SIZE = 2,
WRITE_RESULT_BAD_STATE = 3, SIMPLE_ENTRY_WRITE_RESULT_BAD_STATE = 3,
WRITE_RESULT_SYNC_WRITE_FAILURE = 4, SIMPLE_ENTRY_WRITE_RESULT_SYNC_WRITE_FAILURE = 4,
WRITE_RESULT_FAST_EMPTY_RETURN = 5, SIMPLE_ENTRY_WRITE_RESULT_FAST_EMPTY_RETURN = 5,
WRITE_RESULT_MAX = 6, SIMPLE_ENTRY_WRITE_RESULT_MAX = 6,
}; };
void RecordReadResult(net::CacheType cache_type, SimpleReadResult result) { void RecordReadResult(net::CacheType cache_type, SimpleReadResult result) {
...@@ -60,9 +60,10 @@ void RecordReadResult(net::CacheType cache_type, SimpleReadResult result) { ...@@ -60,9 +60,10 @@ void RecordReadResult(net::CacheType cache_type, SimpleReadResult result) {
"ReadResult", cache_type, result, READ_RESULT_MAX); "ReadResult", cache_type, result, READ_RESULT_MAX);
} }
void RecordWriteResult(net::CacheType cache_type, WriteResult result) { void RecordWriteResult(net::CacheType cache_type,
SIMPLE_CACHE_UMA(ENUMERATION, SimpleEntryWriteResult result) {
"WriteResult2", cache_type, result, WRITE_RESULT_MAX); SIMPLE_CACHE_UMA(ENUMERATION, "WriteResult2", cache_type, result,
SIMPLE_ENTRY_WRITE_RESULT_MAX);
} }
void RecordHeaderSize(net::CacheType cache_type, int size) { void RecordHeaderSize(net::CacheType cache_type, int size) {
...@@ -428,7 +429,7 @@ int SimpleEntryImpl::WriteData(int stream_index, ...@@ -428,7 +429,7 @@ int SimpleEntryImpl::WriteData(int stream_index,
net::NetLogEventType::SIMPLE_CACHE_ENTRY_WRITE_END, net::NetLogEventType::SIMPLE_CACHE_ENTRY_WRITE_END,
CreateNetLogReadWriteCompleteCallback(net::ERR_INVALID_ARGUMENT)); CreateNetLogReadWriteCompleteCallback(net::ERR_INVALID_ARGUMENT));
} }
RecordWriteResult(cache_type_, WRITE_RESULT_INVALID_ARGUMENT); RecordWriteResult(cache_type_, SIMPLE_ENTRY_WRITE_RESULT_INVALID_ARGUMENT);
return net::ERR_INVALID_ARGUMENT; return net::ERR_INVALID_ARGUMENT;
} }
if (backend_.get() && offset + buf_len > backend_->GetMaxFileSize()) { if (backend_.get() && offset + buf_len > backend_->GetMaxFileSize()) {
...@@ -436,7 +437,7 @@ int SimpleEntryImpl::WriteData(int stream_index, ...@@ -436,7 +437,7 @@ int SimpleEntryImpl::WriteData(int stream_index,
net_log_.AddEvent(net::NetLogEventType::SIMPLE_CACHE_ENTRY_WRITE_END, net_log_.AddEvent(net::NetLogEventType::SIMPLE_CACHE_ENTRY_WRITE_END,
CreateNetLogReadWriteCompleteCallback(net::ERR_FAILED)); CreateNetLogReadWriteCompleteCallback(net::ERR_FAILED));
} }
RecordWriteResult(cache_type_, WRITE_RESULT_OVER_MAX_SIZE); RecordWriteResult(cache_type_, SIMPLE_ENTRY_WRITE_RESULT_OVER_MAX_SIZE);
return net::ERR_FAILED; return net::ERR_FAILED;
} }
ScopedOperationRunner operation_runner(this); ScopedOperationRunner operation_runner(this);
...@@ -949,7 +950,7 @@ void SimpleEntryImpl::WriteDataInternal(int stream_index, ...@@ -949,7 +950,7 @@ void SimpleEntryImpl::WriteDataInternal(int stream_index,
} }
if (state_ == STATE_FAILURE || state_ == STATE_UNINITIALIZED) { if (state_ == STATE_FAILURE || state_ == STATE_UNINITIALIZED) {
RecordWriteResult(cache_type_, WRITE_RESULT_BAD_STATE); RecordWriteResult(cache_type_, SIMPLE_ENTRY_WRITE_RESULT_BAD_STATE);
if (net_log_.IsCapturing()) { if (net_log_.IsCapturing()) {
net_log_.AddEvent(net::NetLogEventType::SIMPLE_CACHE_ENTRY_WRITE_END, net_log_.AddEvent(net::NetLogEventType::SIMPLE_CACHE_ENTRY_WRITE_END,
CreateNetLogReadWriteCompleteCallback(net::ERR_FAILED)); CreateNetLogReadWriteCompleteCallback(net::ERR_FAILED));
...@@ -978,7 +979,8 @@ void SimpleEntryImpl::WriteDataInternal(int stream_index, ...@@ -978,7 +979,8 @@ void SimpleEntryImpl::WriteDataInternal(int stream_index,
if (buf_len == 0) { if (buf_len == 0) {
int32_t data_size = data_size_[stream_index]; int32_t data_size = data_size_[stream_index];
if (truncate ? (offset == data_size) : (offset <= data_size)) { if (truncate ? (offset == data_size) : (offset <= data_size)) {
RecordWriteResult(cache_type_, WRITE_RESULT_FAST_EMPTY_RETURN); RecordWriteResult(cache_type_,
SIMPLE_ENTRY_WRITE_RESULT_FAST_EMPTY_RETURN);
if (!callback.is_null()) { if (!callback.is_null()) {
base::ThreadTaskRunnerHandle::Get()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), 0)); FROM_HERE, base::BindOnce(std::move(callback), 0));
...@@ -1400,9 +1402,10 @@ void SimpleEntryImpl::WriteOperationComplete( ...@@ -1400,9 +1402,10 @@ void SimpleEntryImpl::WriteOperationComplete(
net::IOBuffer* buf) { net::IOBuffer* buf) {
int result = write_result->result; int result = write_result->result;
if (result >= 0) if (result >= 0)
RecordWriteResult(cache_type_, WRITE_RESULT_SUCCESS); RecordWriteResult(cache_type_, SIMPLE_ENTRY_WRITE_RESULT_SUCCESS);
else else
RecordWriteResult(cache_type_, WRITE_RESULT_SYNC_WRITE_FAILURE); RecordWriteResult(cache_type_,
SIMPLE_ENTRY_WRITE_RESULT_SYNC_WRITE_FAILURE);
if (net_log_.IsCapturing()) { if (net_log_.IsCapturing()) {
net_log_.AddEvent(net::NetLogEventType::SIMPLE_CACHE_ENTRY_WRITE_END, net_log_.AddEvent(net::NetLogEventType::SIMPLE_CACHE_ENTRY_WRITE_END,
CreateNetLogReadWriteCompleteCallback(result)); CreateNetLogReadWriteCompleteCallback(result));
...@@ -1657,7 +1660,7 @@ int SimpleEntryImpl::SetStream0Data(net::IOBuffer* buf, ...@@ -1657,7 +1660,7 @@ int SimpleEntryImpl::SetStream0Data(net::IOBuffer* buf,
UpdateDataFromEntryStat( UpdateDataFromEntryStat(
SimpleEntryStat(modification_time, modification_time, data_size_, SimpleEntryStat(modification_time, modification_time, data_size_,
sparse_data_size_)); sparse_data_size_));
RecordWriteResult(cache_type_, WRITE_RESULT_SUCCESS); RecordWriteResult(cache_type_, SIMPLE_ENTRY_WRITE_RESULT_SUCCESS);
return buf_len; return buf_len;
} }
......
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