Index: net/disk_cache/simple/simple_entry_impl.cc |
diff --git a/net/disk_cache/simple/simple_entry_impl.cc b/net/disk_cache/simple/simple_entry_impl.cc |
index cc2a1ea032da1798e790f6a83922b52f4eb99d2c..b31410a2868ead5f98ed9492ba5ea95bb416c063 100644 |
--- a/net/disk_cache/simple/simple_entry_impl.cc |
+++ b/net/disk_cache/simple/simple_entry_impl.cc |
@@ -69,19 +69,20 @@ enum HeaderSizeChange { |
}; |
void RecordReadResult(net::CacheType cache_type, ReadResult result) { |
- SIMPLE_CACHE_UMA(ENUMERATION, |
- "ReadResult", cache_type, result, READ_RESULT_MAX); |
+ SIMPLE_CACHE_UMA( |
+ ENUMERATION, "ReadResult", cache_type, result, READ_RESULT_MAX); |
} |
void RecordWriteResult(net::CacheType cache_type, WriteResult result) { |
- SIMPLE_CACHE_UMA(ENUMERATION, |
- "WriteResult2", cache_type, result, WRITE_RESULT_MAX); |
+ SIMPLE_CACHE_UMA( |
+ ENUMERATION, "WriteResult2", cache_type, result, WRITE_RESULT_MAX); |
} |
// TODO(ttuttle): Consider removing this once we have a good handle on header |
// size changes. |
void RecordHeaderSizeChange(net::CacheType cache_type, |
- int old_size, int new_size) { |
+ int old_size, |
+ int new_size) { |
HeaderSizeChange size_change; |
SIMPLE_CACHE_UMA(COUNTS_10000, "HeaderSize", cache_type, new_size); |
@@ -92,39 +93,45 @@ void RecordHeaderSizeChange(net::CacheType cache_type, |
size_change = HEADER_SIZE_CHANGE_SAME; |
} else if (new_size > old_size) { |
int delta = new_size - old_size; |
- SIMPLE_CACHE_UMA(COUNTS_10000, |
- "HeaderSizeIncreaseAbsolute", cache_type, delta); |
+ SIMPLE_CACHE_UMA( |
+ COUNTS_10000, "HeaderSizeIncreaseAbsolute", cache_type, delta); |
SIMPLE_CACHE_UMA(PERCENTAGE, |
- "HeaderSizeIncreasePercentage", cache_type, |
+ "HeaderSizeIncreasePercentage", |
+ cache_type, |
delta * 100 / old_size); |
size_change = HEADER_SIZE_CHANGE_INCREASE; |
} else { // new_size < old_size |
int delta = old_size - new_size; |
- SIMPLE_CACHE_UMA(COUNTS_10000, |
- "HeaderSizeDecreaseAbsolute", cache_type, delta); |
+ SIMPLE_CACHE_UMA( |
+ COUNTS_10000, "HeaderSizeDecreaseAbsolute", cache_type, delta); |
SIMPLE_CACHE_UMA(PERCENTAGE, |
- "HeaderSizeDecreasePercentage", cache_type, |
+ "HeaderSizeDecreasePercentage", |
+ cache_type, |
delta * 100 / old_size); |
size_change = HEADER_SIZE_CHANGE_DECREASE; |
} |
SIMPLE_CACHE_UMA(ENUMERATION, |
- "HeaderSizeChange", cache_type, |
- size_change, HEADER_SIZE_CHANGE_MAX); |
+ "HeaderSizeChange", |
+ cache_type, |
+ size_change, |
+ HEADER_SIZE_CHANGE_MAX); |
} |
void RecordUnexpectedStream0Write(net::CacheType cache_type) { |
SIMPLE_CACHE_UMA(ENUMERATION, |
- "HeaderSizeChange", cache_type, |
- HEADER_SIZE_CHANGE_UNEXPECTED_WRITE, HEADER_SIZE_CHANGE_MAX); |
+ "HeaderSizeChange", |
+ cache_type, |
+ HEADER_SIZE_CHANGE_UNEXPECTED_WRITE, |
+ HEADER_SIZE_CHANGE_MAX); |
} |
int g_open_entry_count = 0; |
void AdjustOpenEntryCountBy(net::CacheType cache_type, int offset) { |
g_open_entry_count += offset; |
- SIMPLE_CACHE_UMA(COUNTS_10000, |
- "GlobalOpenEntryCount", cache_type, g_open_entry_count); |
+ SIMPLE_CACHE_UMA( |
+ COUNTS_10000, "GlobalOpenEntryCount", cache_type, g_open_entry_count); |
} |
void InvokeCallbackIfBackendIsAlive( |
@@ -149,12 +156,9 @@ using base::TaskRunner; |
// exiting the current stack frame. |
class SimpleEntryImpl::ScopedOperationRunner { |
public: |
- explicit ScopedOperationRunner(SimpleEntryImpl* entry) : entry_(entry) { |
- } |
+ explicit ScopedOperationRunner(SimpleEntryImpl* entry) : entry_(entry) {} |
- ~ScopedOperationRunner() { |
- entry_->RunNextOperationIfNeeded(); |
- } |
+ ~ScopedOperationRunner() { entry_->RunNextOperationIfNeeded(); } |
private: |
SimpleEntryImpl* const entry_; |
@@ -179,8 +183,8 @@ SimpleEntryImpl::SimpleEntryImpl(net::CacheType cache_type, |
doomed_(false), |
state_(STATE_UNINITIALIZED), |
synchronous_entry_(NULL), |
- net_log_(net::BoundNetLog::Make( |
- net_log, net::NetLog::SOURCE_DISK_CACHE_ENTRY)), |
+ net_log_(net::BoundNetLog::Make(net_log, |
+ net::NetLog::SOURCE_DISK_CACHE_ENTRY)), |
stream_0_data_(new net::GrowableIOBuffer()) { |
COMPILE_ASSERT(arraysize(data_size_) == arraysize(crc32s_end_offset_), |
arrays_should_be_same_size); |
@@ -192,7 +196,7 @@ SimpleEntryImpl::SimpleEntryImpl(net::CacheType cache_type, |
arrays_should_be_same_size); |
MakeUninitialized(); |
net_log_.BeginEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY, |
- CreateNetLogSimpleEntryConstructionCallback(this)); |
+ CreateNetLogSimpleEntryConstructionCallback(this)); |
} |
int SimpleEntryImpl::OpenEntry(Entry** out_entry, |
@@ -217,14 +221,15 @@ int SimpleEntryImpl::OpenEntry(Entry** out_entry, |
open_entry_index_enum = INDEX_MISS; |
} |
SIMPLE_CACHE_UMA(ENUMERATION, |
- "OpenEntryIndexState", cache_type_, |
- open_entry_index_enum, INDEX_MAX); |
+ "OpenEntryIndexState", |
+ cache_type_, |
+ open_entry_index_enum, |
+ INDEX_MAX); |
// If entry is not known to the index, initiate fast failover to the network. |
if (open_entry_index_enum == INDEX_MISS) { |
net_log_.AddEventWithNetErrorCode( |
- net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_OPEN_END, |
- net::ERR_FAILED); |
+ net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_OPEN_END, net::ERR_FAILED); |
return net::ERR_FAILED; |
} |
@@ -243,8 +248,8 @@ int SimpleEntryImpl::CreateEntry(Entry** out_entry, |
bool have_index = backend_->index()->initialized(); |
int ret_value = net::ERR_FAILED; |
- if (use_optimistic_operations_ && |
- state_ == STATE_UNINITIALIZED && pending_operations_.size() == 0) { |
+ if (use_optimistic_operations_ && state_ == STATE_UNINITIALIZED && |
+ pending_operations_.size() == 0) { |
net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_CREATE_OPTIMISTIC); |
ReturnEntryToCaller(out_entry); |
@@ -285,7 +290,7 @@ int SimpleEntryImpl::DoomEntry(const CompletionCallback& callback) { |
void SimpleEntryImpl::SetKey(const std::string& key) { |
key_ = key; |
net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_SET_KEY, |
- net::NetLog::StringCallback("key", &key)); |
+ net::NetLog::StringCallback("key", &key)); |
} |
void SimpleEntryImpl::Doom() { |
@@ -340,25 +345,26 @@ int SimpleEntryImpl::ReadData(int stream_index, |
if (net_log_.IsLogging()) { |
net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_CALL, |
- CreateNetLogReadWriteDataCallback(stream_index, offset, buf_len, |
- false)); |
+ CreateNetLogReadWriteDataCallback( |
+ stream_index, offset, buf_len, false)); |
} |
if (stream_index < 0 || stream_index >= kSimpleEntryStreamCount || |
buf_len < 0) { |
if (net_log_.IsLogging()) { |
- net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, |
+ net_log_.AddEvent( |
+ net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, |
CreateNetLogReadWriteCompleteCallback(net::ERR_INVALID_ARGUMENT)); |
} |
RecordReadResult(cache_type_, READ_RESULT_INVALID_ARGUMENT); |
return net::ERR_INVALID_ARGUMENT; |
} |
- if (pending_operations_.empty() && (offset >= GetDataSize(stream_index) || |
- offset < 0 || !buf_len)) { |
+ if (pending_operations_.empty() && |
+ (offset >= GetDataSize(stream_index) || offset < 0 || !buf_len)) { |
if (net_log_.IsLogging()) { |
net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, |
- CreateNetLogReadWriteCompleteCallback(0)); |
+ CreateNetLogReadWriteCompleteCallback(0)); |
} |
RecordReadResult(cache_type_, READ_RESULT_NONBLOCK_EMPTY_RETURN); |
@@ -386,10 +392,9 @@ int SimpleEntryImpl::WriteData(int stream_index, |
DCHECK(io_thread_checker_.CalledOnValidThread()); |
if (net_log_.IsLogging()) { |
- net_log_.AddEvent( |
- net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_CALL, |
- CreateNetLogReadWriteDataCallback(stream_index, offset, buf_len, |
- truncate)); |
+ net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_CALL, |
+ CreateNetLogReadWriteDataCallback( |
+ stream_index, offset, buf_len, truncate)); |
} |
if (stream_index < 0 || stream_index >= kSimpleEntryStreamCount || |
@@ -404,9 +409,8 @@ int SimpleEntryImpl::WriteData(int stream_index, |
} |
if (backend_.get() && offset + buf_len > backend_->GetMaxFileSize()) { |
if (net_log_.IsLogging()) { |
- net_log_.AddEvent( |
- net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_END, |
- CreateNetLogReadWriteCompleteCallback(net::ERR_FAILED)); |
+ net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_END, |
+ CreateNetLogReadWriteCompleteCallback(net::ERR_FAILED)); |
} |
RecordWriteResult(cache_type_, WRITE_RESULT_OVER_MAX_SIZE); |
return net::ERR_FAILED; |
@@ -446,9 +450,8 @@ int SimpleEntryImpl::WriteData(int stream_index, |
op_callback = CompletionCallback(); |
ret_value = buf_len; |
if (net_log_.IsLogging()) { |
- net_log_.AddEvent( |
- net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_OPTIMISTIC, |
- CreateNetLogReadWriteCompleteCallback(buf_len)); |
+ net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_OPTIMISTIC, |
+ CreateNetLogReadWriteCompleteCallback(buf_len)); |
} |
} |
@@ -584,8 +587,12 @@ void SimpleEntryImpl::MarkAsDoomed() { |
void SimpleEntryImpl::RunNextOperationIfNeeded() { |
DCHECK(io_thread_checker_.CalledOnValidThread()); |
SIMPLE_CACHE_UMA(CUSTOM_COUNTS, |
- "EntryOperationsPending", cache_type_, |
- pending_operations_.size(), 0, 100, 20); |
+ "EntryOperationsPending", |
+ cache_type_, |
+ pending_operations_.size(), |
+ 0, |
+ 100, |
+ 20); |
if (!pending_operations_.empty() && state_ != STATE_IO_PENDING) { |
scoped_ptr<SimpleEntryOperation> operation( |
new SimpleEntryOperation(pending_operations_.front())); |
@@ -663,9 +670,8 @@ void SimpleEntryImpl::OpenEntryInternal(bool have_index, |
if (state_ == STATE_READY) { |
ReturnEntryToCaller(out_entry); |
PostClientCallback(callback, net::OK); |
- net_log_.AddEvent( |
- net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_OPEN_END, |
- CreateNetLogSimpleEntryCreationCallback(this, net::OK)); |
+ net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_OPEN_END, |
+ CreateNetLogSimpleEntryCreationCallback(this, net::OK)); |
return; |
} |
if (state_ == STATE_FAILURE) { |
@@ -681,9 +687,8 @@ void SimpleEntryImpl::OpenEntryInternal(bool have_index, |
state_ = STATE_IO_PENDING; |
const base::TimeTicks start_time = base::TimeTicks::Now(); |
scoped_ptr<SimpleEntryCreationResults> results( |
- new SimpleEntryCreationResults( |
- SimpleEntryStat(last_used_, last_modified_, data_size_, |
- sparse_data_size_))); |
+ new SimpleEntryCreationResults(SimpleEntryStat( |
+ last_used_, last_modified_, data_size_, sparse_data_size_))); |
Closure task = base::Bind(&SimpleSynchronousEntry::OpenEntry, |
cache_type_, |
path_, |
@@ -730,9 +735,8 @@ void SimpleEntryImpl::CreateEntryInternal(bool have_index, |
const base::TimeTicks start_time = base::TimeTicks::Now(); |
scoped_ptr<SimpleEntryCreationResults> results( |
- new SimpleEntryCreationResults( |
- SimpleEntryStat(last_used_, last_modified_, data_size_, |
- sparse_data_size_))); |
+ new SimpleEntryCreationResults(SimpleEntryStat( |
+ last_used_, last_modified_, data_size_, sparse_data_size_))); |
Closure task = base::Bind(&SimpleSynchronousEntry::CreateEntry, |
cache_type_, |
path_, |
@@ -753,8 +757,8 @@ void SimpleEntryImpl::CreateEntryInternal(bool have_index, |
void SimpleEntryImpl::CloseInternal() { |
DCHECK(io_thread_checker_.CalledOnValidThread()); |
typedef SimpleSynchronousEntry::CRCRecord CRCRecord; |
- scoped_ptr<std::vector<CRCRecord> > |
- crc32s_to_write(new std::vector<CRCRecord>()); |
+ scoped_ptr<std::vector<CRCRecord> > crc32s_to_write( |
+ new std::vector<CRCRecord>()); |
net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_CLOSE_BEGIN); |
@@ -776,13 +780,13 @@ void SimpleEntryImpl::CloseInternal() { |
} |
if (synchronous_entry_) { |
- Closure task = |
- base::Bind(&SimpleSynchronousEntry::Close, |
- base::Unretained(synchronous_entry_), |
- SimpleEntryStat(last_used_, last_modified_, data_size_, |
- sparse_data_size_), |
- base::Passed(&crc32s_to_write), |
- stream_0_data_); |
+ Closure task = base::Bind( |
+ &SimpleSynchronousEntry::Close, |
+ base::Unretained(synchronous_entry_), |
+ SimpleEntryStat( |
+ last_used_, last_modified_, data_size_, sparse_data_size_), |
+ base::Passed(&crc32s_to_write), |
+ stream_0_data_); |
Closure reply = base::Bind(&SimpleEntryImpl::CloseOperationComplete, this); |
synchronous_entry_ = NULL; |
worker_pool_->PostTaskAndReply(FROM_HERE, task, reply); |
@@ -790,8 +794,10 @@ void SimpleEntryImpl::CloseInternal() { |
for (int i = 0; i < kSimpleEntryStreamCount; ++i) { |
if (!have_written_[i]) { |
SIMPLE_CACHE_UMA(ENUMERATION, |
- "CheckCRCResult", cache_type_, |
- crc_check_state_[i], CRC_CHECK_MAX); |
+ "CheckCRCResult", |
+ cache_type_, |
+ crc_check_state_[i], |
+ CRC_CHECK_MAX); |
} |
} |
} else { |
@@ -808,10 +814,9 @@ void SimpleEntryImpl::ReadDataInternal(int stream_index, |
ScopedOperationRunner operation_runner(this); |
if (net_log_.IsLogging()) { |
- net_log_.AddEvent( |
- net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_BEGIN, |
- CreateNetLogReadWriteDataCallback(stream_index, offset, buf_len, |
- false)); |
+ net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_BEGIN, |
+ CreateNetLogReadWriteDataCallback( |
+ stream_index, offset, buf_len, false)); |
} |
if (state_ == STATE_FAILURE || state_ == STATE_UNINITIALIZED) { |
@@ -824,9 +829,8 @@ void SimpleEntryImpl::ReadDataInternal(int stream_index, |
FROM_HERE, base::Bind(callback, net::ERR_FAILED)); |
} |
if (net_log_.IsLogging()) { |
- net_log_.AddEvent( |
- net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, |
- CreateNetLogReadWriteCompleteCallback(net::ERR_FAILED)); |
+ net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, |
+ CreateNetLogReadWriteCompleteCallback(net::ERR_FAILED)); |
} |
return; |
} |
@@ -858,9 +862,8 @@ void SimpleEntryImpl::ReadDataInternal(int stream_index, |
scoped_ptr<uint32> read_crc32(new uint32()); |
scoped_ptr<int> result(new int()); |
- scoped_ptr<SimpleEntryStat> entry_stat( |
- new SimpleEntryStat(last_used_, last_modified_, data_size_, |
- sparse_data_size_)); |
+ scoped_ptr<SimpleEntryStat> entry_stat(new SimpleEntryStat( |
+ last_used_, last_modified_, data_size_, sparse_data_size_)); |
Closure task = base::Bind( |
&SimpleSynchronousEntry::ReadData, |
base::Unretained(synchronous_entry_), |
@@ -881,27 +884,25 @@ void SimpleEntryImpl::ReadDataInternal(int stream_index, |
} |
void SimpleEntryImpl::WriteDataInternal(int stream_index, |
- int offset, |
- net::IOBuffer* buf, |
- int buf_len, |
- const CompletionCallback& callback, |
- bool truncate) { |
+ int offset, |
+ net::IOBuffer* buf, |
+ int buf_len, |
+ const CompletionCallback& callback, |
+ bool truncate) { |
DCHECK(io_thread_checker_.CalledOnValidThread()); |
ScopedOperationRunner operation_runner(this); |
if (net_log_.IsLogging()) { |
- net_log_.AddEvent( |
- net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_BEGIN, |
- CreateNetLogReadWriteDataCallback(stream_index, offset, buf_len, |
- truncate)); |
+ net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_BEGIN, |
+ CreateNetLogReadWriteDataCallback( |
+ stream_index, offset, buf_len, truncate)); |
} |
if (state_ == STATE_FAILURE || state_ == STATE_UNINITIALIZED) { |
RecordWriteResult(cache_type_, WRITE_RESULT_BAD_STATE); |
if (net_log_.IsLogging()) { |
- net_log_.AddEvent( |
- net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_END, |
- CreateNetLogReadWriteCompleteCallback(net::ERR_FAILED)); |
+ net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_END, |
+ CreateNetLogReadWriteCompleteCallback(net::ERR_FAILED)); |
} |
if (!callback.is_null()) { |
MessageLoopProxy::current()->PostTask( |
@@ -929,8 +930,8 @@ void SimpleEntryImpl::WriteDataInternal(int stream_index, |
if (truncate ? (offset == data_size) : (offset <= data_size)) { |
RecordWriteResult(cache_type_, WRITE_RESULT_FAST_EMPTY_RETURN); |
if (!callback.is_null()) { |
- MessageLoopProxy::current()->PostTask(FROM_HERE, base::Bind( |
- callback, 0)); |
+ MessageLoopProxy::current()->PostTask(FROM_HERE, |
+ base::Bind(callback, 0)); |
} |
return; |
} |
@@ -942,14 +943,13 @@ void SimpleEntryImpl::WriteDataInternal(int stream_index, |
AdvanceCrc(buf, offset, buf_len, stream_index); |
// |entry_stat| needs to be initialized before modifying |data_size_|. |
- scoped_ptr<SimpleEntryStat> entry_stat( |
- new SimpleEntryStat(last_used_, last_modified_, data_size_, |
- sparse_data_size_)); |
+ scoped_ptr<SimpleEntryStat> entry_stat(new SimpleEntryStat( |
+ last_used_, last_modified_, data_size_, sparse_data_size_)); |
if (truncate) { |
data_size_[stream_index] = offset + buf_len; |
} else { |
- data_size_[stream_index] = std::max(offset + buf_len, |
- GetDataSize(stream_index)); |
+ data_size_[stream_index] = |
+ std::max(offset + buf_len, GetDataSize(stream_index)); |
} |
// Since we don't know the correct values for |last_used_| and |
@@ -963,14 +963,14 @@ void SimpleEntryImpl::WriteDataInternal(int stream_index, |
have_written_[0] = true; |
scoped_ptr<int> result(new int()); |
- Closure task = base::Bind(&SimpleSynchronousEntry::WriteData, |
- base::Unretained(synchronous_entry_), |
- SimpleSynchronousEntry::EntryOperationData( |
- stream_index, offset, buf_len, truncate, |
- doomed_), |
- make_scoped_refptr(buf), |
- entry_stat.get(), |
- result.get()); |
+ Closure task = |
+ base::Bind(&SimpleSynchronousEntry::WriteData, |
+ base::Unretained(synchronous_entry_), |
+ SimpleSynchronousEntry::EntryOperationData( |
+ stream_index, offset, buf_len, truncate, doomed_), |
+ make_scoped_refptr(buf), |
+ entry_stat.get(), |
+ result.get()); |
Closure reply = base::Bind(&SimpleEntryImpl::WriteOperationComplete, |
this, |
stream_index, |
@@ -993,13 +993,13 @@ void SimpleEntryImpl::ReadSparseDataInternal( |
scoped_ptr<int> result(new int()); |
scoped_ptr<base::Time> last_used(new base::Time()); |
- Closure task = base::Bind(&SimpleSynchronousEntry::ReadSparseData, |
- base::Unretained(synchronous_entry_), |
- SimpleSynchronousEntry::EntryOperationData( |
- sparse_offset, buf_len), |
- make_scoped_refptr(buf), |
- last_used.get(), |
- result.get()); |
+ Closure task = base::Bind( |
+ &SimpleSynchronousEntry::ReadSparseData, |
+ base::Unretained(synchronous_entry_), |
+ SimpleSynchronousEntry::EntryOperationData(sparse_offset, buf_len), |
+ make_scoped_refptr(buf), |
+ last_used.get(), |
+ result.get()); |
Closure reply = base::Bind(&SimpleEntryImpl::ReadSparseOperationComplete, |
this, |
callback, |
@@ -1025,21 +1025,20 @@ void SimpleEntryImpl::WriteSparseDataInternal( |
max_sparse_data_size = max_cache_size / kMaxSparseDataSizeDivisor; |
} |
- scoped_ptr<SimpleEntryStat> entry_stat( |
- new SimpleEntryStat(last_used_, last_modified_, data_size_, |
- sparse_data_size_)); |
+ scoped_ptr<SimpleEntryStat> entry_stat(new SimpleEntryStat( |
+ last_used_, last_modified_, data_size_, sparse_data_size_)); |
last_used_ = last_modified_ = base::Time::Now(); |
scoped_ptr<int> result(new int()); |
- Closure task = base::Bind(&SimpleSynchronousEntry::WriteSparseData, |
- base::Unretained(synchronous_entry_), |
- SimpleSynchronousEntry::EntryOperationData( |
- sparse_offset, buf_len), |
- make_scoped_refptr(buf), |
- max_sparse_data_size, |
- entry_stat.get(), |
- result.get()); |
+ Closure task = base::Bind( |
+ &SimpleSynchronousEntry::WriteSparseData, |
+ base::Unretained(synchronous_entry_), |
+ SimpleSynchronousEntry::EntryOperationData(sparse_offset, buf_len), |
+ make_scoped_refptr(buf), |
+ max_sparse_data_size, |
+ entry_stat.get(), |
+ result.get()); |
Closure reply = base::Bind(&SimpleEntryImpl::WriteSparseOperationComplete, |
this, |
callback, |
@@ -1060,26 +1059,27 @@ void SimpleEntryImpl::GetAvailableRangeInternal( |
state_ = STATE_IO_PENDING; |
scoped_ptr<int> result(new int()); |
- Closure task = base::Bind(&SimpleSynchronousEntry::GetAvailableRange, |
- base::Unretained(synchronous_entry_), |
- SimpleSynchronousEntry::EntryOperationData( |
- sparse_offset, len), |
- out_start, |
- result.get()); |
- Closure reply = base::Bind( |
- &SimpleEntryImpl::GetAvailableRangeOperationComplete, |
- this, |
- callback, |
- base::Passed(&result)); |
+ Closure task = |
+ base::Bind(&SimpleSynchronousEntry::GetAvailableRange, |
+ base::Unretained(synchronous_entry_), |
+ SimpleSynchronousEntry::EntryOperationData(sparse_offset, len), |
+ out_start, |
+ result.get()); |
+ Closure reply = |
+ base::Bind(&SimpleEntryImpl::GetAvailableRangeOperationComplete, |
+ this, |
+ callback, |
+ base::Passed(&result)); |
worker_pool_->PostTaskAndReply(FROM_HERE, task, reply); |
} |
void SimpleEntryImpl::DoomEntryInternal(const CompletionCallback& callback) { |
PostTaskAndReplyWithResult( |
- worker_pool_, FROM_HERE, |
+ worker_pool_, |
+ FROM_HERE, |
base::Bind(&SimpleSynchronousEntry::DoomEntry, path_, entry_hash_), |
- base::Bind(&SimpleEntryImpl::DoomOperationComplete, this, callback, |
- state_)); |
+ base::Bind( |
+ &SimpleEntryImpl::DoomOperationComplete, this, callback, state_)); |
state_ = STATE_IO_PENDING; |
} |
@@ -1094,7 +1094,8 @@ void SimpleEntryImpl::CreationOperationComplete( |
DCHECK(in_results); |
ScopedOperationRunner operation_runner(this); |
SIMPLE_CACHE_UMA(BOOLEAN, |
- "EntryCreationResult", cache_type_, |
+ "EntryCreationResult", |
+ cache_type_, |
in_results->result == net::OK); |
if (in_results->result != net::OK) { |
if (in_results->result != net::ERR_FILE_EXISTS) |
@@ -1128,7 +1129,8 @@ void SimpleEntryImpl::CreationOperationComplete( |
} |
UpdateDataFromEntryStat(in_results->entry_stat); |
SIMPLE_CACHE_UMA(TIMES, |
- "EntryCreationTime", cache_type_, |
+ "EntryCreationTime", |
+ cache_type_, |
(base::TimeTicks::Now() - start_time)); |
AdjustOpenEntryCountBy(cache_type_, 1); |
@@ -1153,8 +1155,8 @@ void SimpleEntryImpl::EntryOperationComplete( |
} |
if (!completion_callback.is_null()) { |
- MessageLoopProxy::current()->PostTask(FROM_HERE, base::Bind( |
- completion_callback, *result)); |
+ MessageLoopProxy::current()->PostTask( |
+ FROM_HERE, base::Bind(completion_callback, *result)); |
} |
RunNextOperationIfNeeded(); |
} |
@@ -1178,8 +1180,8 @@ void SimpleEntryImpl::ReadOperationComplete( |
} |
if (*result > 0 && crc32s_end_offset_[stream_index] == offset) { |
- uint32 current_crc = offset == 0 ? crc32(0, Z_NULL, 0) |
- : crc32s_[stream_index]; |
+ uint32 current_crc = |
+ offset == 0 ? crc32(0, Z_NULL, 0) : crc32s_[stream_index]; |
crc32s_[stream_index] = crc32_combine(current_crc, *read_crc32, *result); |
crc32s_end_offset_[stream_index] += *result; |
if (!have_written_[stream_index] && |
@@ -1204,7 +1206,9 @@ void SimpleEntryImpl::ReadOperationComplete( |
crc32s_[stream_index], |
new_result.get()); |
Closure reply = base::Bind(&SimpleEntryImpl::ChecksumOperationComplete, |
- this, *result, stream_index, |
+ this, |
+ *result, |
+ stream_index, |
completion_callback, |
base::Passed(&new_result)); |
worker_pool_->PostTaskAndReply(FROM_HERE, task, reply); |
@@ -1227,9 +1231,8 @@ void SimpleEntryImpl::ReadOperationComplete( |
} |
} |
if (net_log_.IsLogging()) { |
- net_log_.AddEvent( |
- net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, |
- CreateNetLogReadWriteCompleteCallback(*result)); |
+ net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, |
+ CreateNetLogReadWriteCompleteCallback(*result)); |
} |
EntryOperationComplete(completion_callback, *entry_stat, result.Pass()); |
@@ -1246,7 +1249,7 @@ void SimpleEntryImpl::WriteOperationComplete( |
RecordWriteResult(cache_type_, WRITE_RESULT_SYNC_WRITE_FAILURE); |
if (net_log_.IsLogging()) { |
net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_WRITE_END, |
- CreateNetLogReadWriteCompleteCallback(*result)); |
+ CreateNetLogReadWriteCompleteCallback(*result)); |
} |
if (*result < 0) { |
@@ -1264,8 +1267,8 @@ void SimpleEntryImpl::ReadSparseOperationComplete( |
DCHECK(synchronous_entry_); |
DCHECK(result); |
- SimpleEntryStat entry_stat(*last_used, last_modified_, data_size_, |
- sparse_data_size_); |
+ SimpleEntryStat entry_stat( |
+ *last_used, last_modified_, data_size_, sparse_data_size_); |
EntryOperationComplete(completion_callback, entry_stat, result.Pass()); |
} |
@@ -1287,15 +1290,14 @@ void SimpleEntryImpl::GetAvailableRangeOperationComplete( |
DCHECK(synchronous_entry_); |
DCHECK(result); |
- SimpleEntryStat entry_stat(last_used_, last_modified_, data_size_, |
- sparse_data_size_); |
+ SimpleEntryStat entry_stat( |
+ last_used_, last_modified_, data_size_, sparse_data_size_); |
EntryOperationComplete(completion_callback, entry_stat, result.Pass()); |
} |
-void SimpleEntryImpl::DoomOperationComplete( |
- const CompletionCallback& callback, |
- State state_to_restore, |
- int result) { |
+void SimpleEntryImpl::DoomOperationComplete(const CompletionCallback& callback, |
+ State state_to_restore, |
+ int result) { |
state_ = state_to_restore; |
if (!callback.is_null()) |
callback.Run(result); |
@@ -1316,8 +1318,7 @@ void SimpleEntryImpl::ChecksumOperationComplete( |
if (net_log_.IsLogging()) { |
net_log_.AddEventWithNetErrorCode( |
- net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_CHECKSUM_END, |
- *result); |
+ net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_CHECKSUM_END, *result); |
} |
if (*result == net::OK) { |
@@ -1331,11 +1332,11 @@ void SimpleEntryImpl::ChecksumOperationComplete( |
} |
if (net_log_.IsLogging()) { |
net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_END, |
- CreateNetLogReadWriteCompleteCallback(*result)); |
+ CreateNetLogReadWriteCompleteCallback(*result)); |
} |
- SimpleEntryStat entry_stat(last_used_, last_modified_, data_size_, |
- sparse_data_size_); |
+ SimpleEntryStat entry_stat( |
+ last_used_, last_modified_, data_size_, sparse_data_size_); |
EntryOperationComplete(completion_callback, entry_stat, result.Pass()); |
} |
@@ -1403,8 +1404,10 @@ void SimpleEntryImpl::RecordReadIsParallelizable( |
type = READ_FOLLOWS_NON_CONFLICTING_WRITE; |
} |
SIMPLE_CACHE_UMA(ENUMERATION, |
- "ReadIsParallelizable", cache_type_, |
- type, READ_DEPENDENCY_TYPE_MAX); |
+ "ReadIsParallelizable", |
+ cache_type_, |
+ type, |
+ READ_DEPENDENCY_TYPE_MAX); |
} |
void SimpleEntryImpl::RecordWriteDependencyType( |
@@ -1443,8 +1446,10 @@ void SimpleEntryImpl::RecordWriteDependencyType( |
} |
} |
SIMPLE_CACHE_UMA(ENUMERATION, |
- "WriteDependencyType", cache_type_, |
- type, WRITE_DEPENDENCY_TYPE_MAX); |
+ "WriteDependencyType", |
+ cache_type_, |
+ type, |
+ WRITE_DEPENDENCY_TYPE_MAX); |
} |
int SimpleEntryImpl::ReadStream0Data(net::IOBuffer* buf, |
@@ -1455,9 +1460,8 @@ int SimpleEntryImpl::ReadStream0Data(net::IOBuffer* buf, |
return 0; |
} |
memcpy(buf->data(), stream_0_data_->data() + offset, buf_len); |
- UpdateDataFromEntryStat( |
- SimpleEntryStat(base::Time::Now(), last_modified_, data_size_, |
- sparse_data_size_)); |
+ UpdateDataFromEntryStat(SimpleEntryStat( |
+ base::Time::Now(), last_modified_, data_size_, sparse_data_size_)); |
RecordReadResult(cache_type_, READ_RESULT_SUCCESS); |
return buf_len; |
} |
@@ -1494,9 +1498,8 @@ int SimpleEntryImpl::SetStream0Data(net::IOBuffer* buf, |
} |
base::Time modification_time = base::Time::Now(); |
AdvanceCrc(buf, offset, buf_len, 0); |
- UpdateDataFromEntryStat( |
- SimpleEntryStat(modification_time, modification_time, data_size_, |
- sparse_data_size_)); |
+ UpdateDataFromEntryStat(SimpleEntryStat( |
+ modification_time, modification_time, data_size_, sparse_data_size_)); |
RecordWriteResult(cache_type_, WRITE_RESULT_SUCCESS); |
return buf_len; |
} |