Index: net/disk_cache/blockfile/entry_impl_v3.cc |
diff --git a/net/disk_cache/blockfile/entry_impl_v3.cc b/net/disk_cache/blockfile/entry_impl_v3.cc |
index c8898e069d62fd6a317c6dbb71013daa97b587bc..d847b181c09da847f0978d41fe277a112f8b09e1 100644 |
--- a/net/disk_cache/blockfile/entry_impl_v3.cc |
+++ b/net/disk_cache/blockfile/entry_impl_v3.cc |
@@ -258,7 +258,8 @@ EntryImplV3::EntryImplV3(BackendImplV3* backend, Addr address, bool read_only) |
#if defined(V3_NOT_JUST_YET_READY) |
-bool EntryImplV3::CreateEntry(Addr node_address, const std::string& key, |
+bool EntryImplV3::CreateEntry(Addr node_address, |
+ const std::string& key, |
uint32 hash) { |
Trace("Create entry In"); |
EntryStore* entry_store = entry_.Data(); |
@@ -441,11 +442,10 @@ void EntryImplV3::SetTimes(base::Time last_used, base::Time last_modified) { |
void EntryImplV3::BeginLogging(net::NetLog* net_log, bool created) { |
DCHECK(!net_log_.net_log()); |
- net_log_ = net::BoundNetLog::Make( |
- net_log, net::NetLog::SOURCE_DISK_CACHE_ENTRY); |
- net_log_.BeginEvent( |
- net::NetLog::TYPE_DISK_CACHE_ENTRY_IMPL, |
- CreateNetLogEntryCreationCallback(this, created)); |
+ net_log_ = |
+ net::BoundNetLog::Make(net_log, net::NetLog::SOURCE_DISK_CACHE_ENTRY); |
+ net_log_.BeginEvent(net::NetLog::TYPE_DISK_CACHE_ENTRY_IMPL, |
+ CreateNetLogEntryCreationCallback(this, created)); |
} |
const net::BoundNetLog& EntryImplV3::net_log() const { |
@@ -490,8 +490,8 @@ std::string EntryImplV3::GetKey() const { |
offset = address.start_block() * address.BlockSize() + kBlockHeaderSize; |
COMPILE_ASSERT(kNumStreams == kKeyFileIndex, invalid_key_index); |
- File* key_file = const_cast<EntryImpl*>(this)->GetBackingFile(address, |
- kKeyFileIndex); |
+ File* key_file = |
+ const_cast<EntryImpl*>(this)->GetBackingFile(address, kKeyFileIndex); |
if (!key_file) |
return std::string(); |
@@ -522,7 +522,10 @@ int32 EntryImplV3::GetDataSize(int index) const { |
return entry->Data()->data_size[index]; |
} |
-int EntryImplV3::ReadData(int index, int offset, IOBuffer* buf, int buf_len, |
+int EntryImplV3::ReadData(int index, |
+ int offset, |
+ IOBuffer* buf, |
+ int buf_len, |
const CompletionCallback& callback) { |
if (callback.is_null()) |
return ReadDataImpl(index, offset, buf, buf_len, callback); |
@@ -545,7 +548,10 @@ int EntryImplV3::ReadData(int index, int offset, IOBuffer* buf, int buf_len, |
return net::ERR_IO_PENDING; |
} |
-int EntryImpl::ReadDataImpl(int index, int offset, IOBuffer* buf, int buf_len, |
+int EntryImpl::ReadDataImpl(int index, |
+ int offset, |
+ IOBuffer* buf, |
+ int buf_len, |
const CompletionCallback& callback) { |
if (net_log_.IsLogging()) { |
net_log_.BeginEvent( |
@@ -556,15 +562,18 @@ int EntryImpl::ReadDataImpl(int index, int offset, IOBuffer* buf, int buf_len, |
int result = InternalReadData(index, offset, buf, buf_len, callback); |
if (result != net::ERR_IO_PENDING && net_log_.IsLogging()) { |
- net_log_.EndEvent( |
- net::NetLog::TYPE_ENTRY_READ_DATA, |
- CreateNetLogReadWriteCompleteCallback(result)); |
+ net_log_.EndEvent(net::NetLog::TYPE_ENTRY_READ_DATA, |
+ CreateNetLogReadWriteCompleteCallback(result)); |
} |
return result; |
} |
-int EntryImplV3::WriteData(int index, int offset, IOBuffer* buf, int buf_len, |
- const CompletionCallback& callback, bool truncate) { |
+int EntryImplV3::WriteData(int index, |
+ int offset, |
+ IOBuffer* buf, |
+ int buf_len, |
+ const CompletionCallback& callback, |
+ bool truncate) { |
if (callback.is_null()) |
return WriteDataImpl(index, offset, buf, buf_len, callback, truncate); |
@@ -578,12 +587,15 @@ int EntryImplV3::WriteData(int index, int offset, IOBuffer* buf, int buf_len, |
if (!background_queue_) |
return net::ERR_UNEXPECTED; |
- background_queue_->WriteData(this, index, offset, buf, buf_len, truncate, |
- callback); |
+ background_queue_->WriteData( |
+ this, index, offset, buf, buf_len, truncate, callback); |
return net::ERR_IO_PENDING; |
} |
-int EntryImpl::WriteDataImpl(int index, int offset, IOBuffer* buf, int buf_len, |
+int EntryImpl::WriteDataImpl(int index, |
+ int offset, |
+ IOBuffer* buf, |
+ int buf_len, |
const CompletionCallback& callback, |
bool truncate) { |
if (net_log_.IsLogging()) { |
@@ -592,18 +604,19 @@ int EntryImpl::WriteDataImpl(int index, int offset, IOBuffer* buf, int buf_len, |
CreateNetLogReadWriteDataCallback(index, offset, buf_len, truncate)); |
} |
- int result = InternalWriteData(index, offset, buf, buf_len, callback, |
- truncate); |
+ int result = |
+ InternalWriteData(index, offset, buf, buf_len, callback, truncate); |
if (result != net::ERR_IO_PENDING && net_log_.IsLogging()) { |
- net_log_.EndEvent( |
- net::NetLog::TYPE_ENTRY_WRITE_DATA, |
- CreateNetLogReadWriteCompleteCallback(result)); |
+ net_log_.EndEvent(net::NetLog::TYPE_ENTRY_WRITE_DATA, |
+ CreateNetLogReadWriteCompleteCallback(result)); |
} |
return result; |
} |
-int EntryImplV3::ReadSparseData(int64 offset, IOBuffer* buf, int buf_len, |
+int EntryImplV3::ReadSparseData(int64 offset, |
+ IOBuffer* buf, |
+ int buf_len, |
const CompletionCallback& callback) { |
if (callback.is_null()) |
return ReadSparseDataImpl(offset, buf, buf_len, callback); |
@@ -615,7 +628,9 @@ int EntryImplV3::ReadSparseData(int64 offset, IOBuffer* buf, int buf_len, |
return net::ERR_IO_PENDING; |
} |
-int EntryImpl::ReadSparseDataImpl(int64 offset, IOBuffer* buf, int buf_len, |
+int EntryImpl::ReadSparseDataImpl(int64 offset, |
+ IOBuffer* buf, |
+ int buf_len, |
const CompletionCallback& callback) { |
DCHECK(node_.Data()->dirty || read_only_); |
int result = InitSparseData(); |
@@ -623,13 +638,15 @@ int EntryImpl::ReadSparseDataImpl(int64 offset, IOBuffer* buf, int buf_len, |
return result; |
TimeTicks start = TimeTicks::Now(); |
- result = sparse_->StartIO(SparseControl::kReadOperation, offset, buf, buf_len, |
- callback); |
+ result = sparse_->StartIO( |
+ SparseControl::kReadOperation, offset, buf, buf_len, callback); |
ReportIOTime(kSparseRead, start); |
return result; |
} |
-int EntryImplV3::WriteSparseData(int64 offset, IOBuffer* buf, int buf_len, |
+int EntryImplV3::WriteSparseData(int64 offset, |
+ IOBuffer* buf, |
+ int buf_len, |
const CompletionCallback& callback) { |
if (callback.is_null()) |
return WriteSparseDataImpl(offset, buf, buf_len, callback); |
@@ -641,7 +658,9 @@ int EntryImplV3::WriteSparseData(int64 offset, IOBuffer* buf, int buf_len, |
return net::ERR_IO_PENDING; |
} |
-int EntryImpl::WriteSparseDataImpl(int64 offset, IOBuffer* buf, int buf_len, |
+int EntryImpl::WriteSparseDataImpl(int64 offset, |
+ IOBuffer* buf, |
+ int buf_len, |
const CompletionCallback& callback) { |
DCHECK(node_.Data()->dirty || read_only_); |
int result = InitSparseData(); |
@@ -649,13 +668,15 @@ int EntryImpl::WriteSparseDataImpl(int64 offset, IOBuffer* buf, int buf_len, |
return result; |
TimeTicks start = TimeTicks::Now(); |
- result = sparse_->StartIO(SparseControl::kWriteOperation, offset, buf, |
- buf_len, callback); |
+ result = sparse_->StartIO( |
+ SparseControl::kWriteOperation, offset, buf, buf_len, callback); |
ReportIOTime(kSparseWrite, start); |
return result; |
} |
-int EntryImplV3::GetAvailableRange(int64 offset, int len, int64* start, |
+int EntryImplV3::GetAvailableRange(int64 offset, |
+ int len, |
+ int64* start, |
const CompletionCallback& callback) { |
if (!background_queue_) |
return net::ERR_UNEXPECTED; |
@@ -769,8 +790,10 @@ EntryImplV3::~EntryImplV3() { |
backend_->OnEntryDestroyEnd(); |
} |
-int EntryImpl::InternalReadData(int index, int offset, |
- IOBuffer* buf, int buf_len, |
+int EntryImpl::InternalReadData(int index, |
+ int offset, |
+ IOBuffer* buf, |
+ int buf_len, |
const CompletionCallback& callback) { |
DCHECK(node_.Data()->dirty || read_only_); |
DVLOG(2) << "Read from " << index << " at " << offset << " : " << buf_len; |
@@ -824,14 +847,14 @@ int EntryImpl::InternalReadData(int index, int offset, |
size_t file_offset = offset; |
if (address.is_block_file()) { |
DCHECK_LE(offset + buf_len, kMaxBlockSize); |
- file_offset += address.start_block() * address.BlockSize() + |
- kBlockHeaderSize; |
+ file_offset += |
+ address.start_block() * address.BlockSize() + kBlockHeaderSize; |
} |
SyncCallback* io_callback = NULL; |
if (!callback.is_null()) { |
- io_callback = new SyncCallback(this, buf, callback, |
- net::NetLog::TYPE_ENTRY_READ_DATA); |
+ io_callback = new SyncCallback( |
+ this, buf, callback, net::NetLog::TYPE_ENTRY_READ_DATA); |
} |
TimeTicks start_async = TimeTicks::Now(); |
@@ -854,8 +877,10 @@ int EntryImpl::InternalReadData(int index, int offset, |
return (completed || callback.is_null()) ? buf_len : net::ERR_IO_PENDING; |
} |
-int EntryImpl::InternalWriteData(int index, int offset, |
- IOBuffer* buf, int buf_len, |
+int EntryImpl::InternalWriteData(int index, |
+ int offset, |
+ IOBuffer* buf, |
+ int buf_len, |
const CompletionCallback& callback, |
bool truncate) { |
DCHECK(node_.Data()->dirty || read_only_); |
@@ -922,8 +947,8 @@ int EntryImpl::InternalWriteData(int index, int offset, |
size_t file_offset = offset; |
if (address.is_block_file()) { |
DCHECK_LE(offset + buf_len, kMaxBlockSize); |
- file_offset += address.start_block() * address.BlockSize() + |
- kBlockHeaderSize; |
+ file_offset += |
+ address.start_block() * address.BlockSize() + kBlockHeaderSize; |
} else if (truncate || (extending && !buf_len)) { |
if (!file->SetLength(offset + buf_len)) |
return net::ERR_FAILED; |
@@ -934,15 +959,15 @@ int EntryImpl::InternalWriteData(int index, int offset, |
SyncCallback* io_callback = NULL; |
if (!callback.is_null()) { |
- io_callback = new SyncCallback(this, buf, callback, |
- net::NetLog::TYPE_ENTRY_WRITE_DATA); |
+ io_callback = new SyncCallback( |
+ this, buf, callback, net::NetLog::TYPE_ENTRY_WRITE_DATA); |
} |
TimeTicks start_async = TimeTicks::Now(); |
bool completed; |
- if (!file->Write(buf->data(), buf_len, file_offset, io_callback, |
- &completed)) { |
+ if (!file->Write( |
+ buf->data(), buf_len, file_offset, io_callback, &completed)) { |
if (io_callback) |
io_callback->Discard(); |
return net::ERR_CACHE_WRITE_FAILURE; |
@@ -1006,8 +1031,8 @@ void EntryImpl::DeleteData(Addr address, int index) { |
int failure = !DeleteCacheFile(backend_->GetFileName(address)); |
CACHE_UMA(COUNTS, "DeleteFailed", 0, failure); |
if (failure) { |
- LOG(ERROR) << "Failed to delete " << |
- backend_->GetFileName(address).value() << " from the cache."; |
+ LOG(ERROR) << "Failed to delete " << backend_->GetFileName(address) |
+ .value() << " from the cache."; |
} |
if (files_[index]) |
files_[index] = NULL; // Releases the object. |
@@ -1048,8 +1073,8 @@ void EntryImpl::DeleteEntryData(bool everything) { |
for (int index = 0; index < kNumStreams; index++) { |
Addr address(entry_.Data()->data_addr[index]); |
if (address.is_initialized()) { |
- backend_->ModifyStorageSize(entry_.Data()->data_size[index] - |
- unreported_size_[index], 0); |
+ backend_->ModifyStorageSize( |
+ entry_.Data()->data_size[index] - unreported_size_[index], 0); |
entry_.Data()->data_addr[index] = 0; |
entry_.Data()->data_size[index] = 0; |
entry_.Store(); |
@@ -1092,7 +1117,9 @@ void EntryImpl::DeleteEntryData(bool everything) { |
// reuse it for the new data. Keep in mind that the normal use pattern is quite |
// simple (write sequentially from the beginning), so we optimize for handling |
// that case. |
-bool EntryImpl::PrepareTarget(int index, int offset, int buf_len, |
+bool EntryImpl::PrepareTarget(int index, |
+ int offset, |
+ int buf_len, |
bool truncate) { |
if (truncate) |
return HandleTruncation(index, offset, buf_len); |
@@ -1350,8 +1377,8 @@ void EntryImpl::GetData(int index, char** buffer, Addr* address) { |
address->set_value(entry_.Data()->data_addr[index]); |
if (address->is_initialized()) { |
// Prevent us from deleting the block from the backing store. |
- backend_->ModifyStorageSize(entry_.Data()->data_size[index] - |
- unreported_size_[index], 0); |
+ backend_->ModifyStorageSize( |
+ entry_.Data()->data_size[index] - unreported_size_[index], 0); |
entry_.Data()->data_addr[index] = 0; |
entry_.Data()->data_size[index] = 0; |
} |
@@ -1420,27 +1447,40 @@ int32 EntryImplV3::GetDataSize(int index) const { |
return 0; |
} |
-int EntryImplV3::ReadData(int index, int offset, IOBuffer* buf, int buf_len, |
+int EntryImplV3::ReadData(int index, |
+ int offset, |
+ IOBuffer* buf, |
+ int buf_len, |
const CompletionCallback& callback) { |
return net::ERR_FAILED; |
} |
-int EntryImplV3::WriteData(int index, int offset, IOBuffer* buf, int buf_len, |
- const CompletionCallback& callback, bool truncate) { |
+int EntryImplV3::WriteData(int index, |
+ int offset, |
+ IOBuffer* buf, |
+ int buf_len, |
+ const CompletionCallback& callback, |
+ bool truncate) { |
return net::ERR_FAILED; |
} |
-int EntryImplV3::ReadSparseData(int64 offset, IOBuffer* buf, int buf_len, |
+int EntryImplV3::ReadSparseData(int64 offset, |
+ IOBuffer* buf, |
+ int buf_len, |
const CompletionCallback& callback) { |
return net::ERR_FAILED; |
} |
-int EntryImplV3::WriteSparseData(int64 offset, IOBuffer* buf, int buf_len, |
+int EntryImplV3::WriteSparseData(int64 offset, |
+ IOBuffer* buf, |
+ int buf_len, |
const CompletionCallback& callback) { |
return net::ERR_FAILED; |
} |
-int EntryImplV3::GetAvailableRange(int64 offset, int len, int64* start, |
+int EntryImplV3::GetAvailableRange(int64 offset, |
+ int len, |
+ int64* start, |
const CompletionCallback& callback) { |
return net::ERR_FAILED; |
} |