Index: net/disk_cache/memory/mem_entry_impl.cc |
diff --git a/net/disk_cache/memory/mem_entry_impl.cc b/net/disk_cache/memory/mem_entry_impl.cc |
index 7c6199b951b28febf2c2d2cb3b1c595a67ab0324..c9fded928cf50dc31e89c5fd13e573fd4d1a3510 100644 |
--- a/net/disk_cache/memory/mem_entry_impl.cc |
+++ b/net/disk_cache/memory/mem_entry_impl.cc |
@@ -80,12 +80,11 @@ bool MemEntryImpl::CreateEntry(const std::string& key, net::NetLog* net_log) { |
last_modified_ = current; |
last_used_ = current; |
- net_log_ = net::BoundNetLog::Make(net_log, |
- net::NetLog::SOURCE_MEMORY_CACHE_ENTRY); |
+ net_log_ = |
+ net::BoundNetLog::Make(net_log, net::NetLog::SOURCE_MEMORY_CACHE_ENTRY); |
// Must be called after |key_| is set, so GetKey() works. |
- net_log_.BeginEvent( |
- net::NetLog::TYPE_DISK_CACHE_MEM_ENTRY_IMPL, |
- CreateNetLogEntryCreationCallback(this, true)); |
+ net_log_.BeginEvent(net::NetLog::TYPE_DISK_CACHE_MEM_ENTRY_IMPL, |
+ CreateNetLogEntryCreationCallback(this, true)); |
Open(); |
backend_->ModifyStorageSize(0, static_cast<int32>(key.size())); |
@@ -101,8 +100,8 @@ void MemEntryImpl::InternalDoom() { |
if (children_.get()) { |
EntryMap children; |
children.swap(*children_); |
- for (EntryMap::iterator i = children.begin(); |
- i != children.end(); ++i) { |
+ for (EntryMap::iterator i = children.begin(); i != children.end(); |
+ ++i) { |
// Since a pointer to this object is also saved in the map, avoid |
// dooming it. |
if (i->second != this) |
@@ -183,7 +182,10 @@ int32 MemEntryImpl::GetDataSize(int index) const { |
return data_size_[index]; |
} |
-int MemEntryImpl::ReadData(int index, int offset, IOBuffer* buf, int buf_len, |
+int MemEntryImpl::ReadData(int index, |
+ int offset, |
+ IOBuffer* buf, |
+ int buf_len, |
const CompletionCallback& callback) { |
if (net_log_.IsLogging()) { |
net_log_.BeginEvent( |
@@ -194,15 +196,18 @@ int MemEntryImpl::ReadData(int index, int offset, IOBuffer* buf, int buf_len, |
int result = InternalReadData(index, offset, buf, buf_len); |
if (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 MemEntryImpl::WriteData(int index, int offset, IOBuffer* buf, int buf_len, |
- const CompletionCallback& callback, bool truncate) { |
+int MemEntryImpl::WriteData(int index, |
+ int offset, |
+ IOBuffer* buf, |
+ int buf_len, |
+ const CompletionCallback& callback, |
+ bool truncate) { |
if (net_log_.IsLogging()) { |
net_log_.BeginEvent( |
net::NetLog::TYPE_ENTRY_WRITE_DATA, |
@@ -212,19 +217,19 @@ int MemEntryImpl::WriteData(int index, int offset, IOBuffer* buf, int buf_len, |
int result = InternalWriteData(index, offset, buf, buf_len, truncate); |
if (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 MemEntryImpl::ReadSparseData(int64 offset, IOBuffer* buf, int buf_len, |
+int MemEntryImpl::ReadSparseData(int64 offset, |
+ IOBuffer* buf, |
+ int buf_len, |
const CompletionCallback& callback) { |
if (net_log_.IsLogging()) { |
- net_log_.BeginEvent( |
- net::NetLog::TYPE_SPARSE_READ, |
- CreateNetLogSparseOperationCallback(offset, buf_len)); |
+ net_log_.BeginEvent(net::NetLog::TYPE_SPARSE_READ, |
+ CreateNetLogSparseOperationCallback(offset, buf_len)); |
} |
int result = InternalReadSparseData(offset, buf, buf_len); |
if (net_log_.IsLogging()) |
@@ -232,12 +237,13 @@ int MemEntryImpl::ReadSparseData(int64 offset, IOBuffer* buf, int buf_len, |
return result; |
} |
-int MemEntryImpl::WriteSparseData(int64 offset, IOBuffer* buf, int buf_len, |
+int MemEntryImpl::WriteSparseData(int64 offset, |
+ IOBuffer* buf, |
+ int buf_len, |
const CompletionCallback& callback) { |
if (net_log_.IsLogging()) { |
- net_log_.BeginEvent( |
- net::NetLog::TYPE_SPARSE_WRITE, |
- CreateNetLogSparseOperationCallback(offset, buf_len)); |
+ net_log_.BeginEvent(net::NetLog::TYPE_SPARSE_WRITE, |
+ CreateNetLogSparseOperationCallback(offset, buf_len)); |
} |
int result = InternalWriteSparseData(offset, buf, buf_len); |
if (net_log_.IsLogging()) |
@@ -245,12 +251,13 @@ int MemEntryImpl::WriteSparseData(int64 offset, IOBuffer* buf, int buf_len, |
return result; |
} |
-int MemEntryImpl::GetAvailableRange(int64 offset, int len, int64* start, |
+int MemEntryImpl::GetAvailableRange(int64 offset, |
+ int len, |
+ int64* start, |
const CompletionCallback& callback) { |
if (net_log_.IsLogging()) { |
- net_log_.BeginEvent( |
- net::NetLog::TYPE_SPARSE_GET_RANGE, |
- CreateNetLogSparseOperationCallback(offset, len)); |
+ net_log_.BeginEvent(net::NetLog::TYPE_SPARSE_GET_RANGE, |
+ CreateNetLogSparseOperationCallback(offset, len)); |
} |
int result = GetAvailableRange(offset, len, start); |
if (net_log_.IsLogging()) { |
@@ -279,7 +286,9 @@ MemEntryImpl::~MemEntryImpl() { |
net_log_.EndEvent(net::NetLog::TYPE_DISK_CACHE_MEM_ENTRY_IMPL); |
} |
-int MemEntryImpl::InternalReadData(int index, int offset, IOBuffer* buf, |
+int MemEntryImpl::InternalReadData(int index, |
+ int offset, |
+ IOBuffer* buf, |
int buf_len) { |
DCHECK(type() == kParentEntry || index == kSparseData); |
@@ -302,8 +311,11 @@ int MemEntryImpl::InternalReadData(int index, int offset, IOBuffer* buf, |
return buf_len; |
} |
-int MemEntryImpl::InternalWriteData(int index, int offset, IOBuffer* buf, |
- int buf_len, bool truncate) { |
+int MemEntryImpl::InternalWriteData(int index, |
+ int offset, |
+ IOBuffer* buf, |
+ int buf_len, |
+ bool truncate) { |
DCHECK(type() == kParentEntry || index == kSparseData); |
if (index < 0 || index >= NUM_STREAMS) |
@@ -344,7 +356,8 @@ int MemEntryImpl::InternalWriteData(int index, int offset, IOBuffer* buf, |
return buf_len; |
} |
-int MemEntryImpl::InternalReadSparseData(int64 offset, IOBuffer* buf, |
+int MemEntryImpl::InternalReadSparseData(int64 offset, |
+ IOBuffer* buf, |
int buf_len) { |
DCHECK(type() == kParentEntry); |
@@ -379,8 +392,11 @@ int MemEntryImpl::InternalReadSparseData(int64 offset, IOBuffer* buf, |
CreateNetLogSparseReadWriteCallback(child->net_log().source(), |
io_buf->BytesRemaining())); |
} |
- int ret = child->ReadData(kSparseData, child_offset, io_buf.get(), |
- io_buf->BytesRemaining(), CompletionCallback()); |
+ int ret = child->ReadData(kSparseData, |
+ child_offset, |
+ io_buf.get(), |
+ io_buf->BytesRemaining(), |
+ CompletionCallback()); |
if (net_log_.IsLogging()) { |
net_log_.EndEventWithNetErrorCode( |
net::NetLog::TYPE_SPARSE_READ_CHILD_DATA, ret); |
@@ -401,7 +417,8 @@ int MemEntryImpl::InternalReadSparseData(int64 offset, IOBuffer* buf, |
return io_buf->BytesConsumed(); |
} |
-int MemEntryImpl::InternalWriteSparseData(int64 offset, IOBuffer* buf, |
+int MemEntryImpl::InternalWriteSparseData(int64 offset, |
+ IOBuffer* buf, |
int buf_len) { |
DCHECK(type() == kParentEntry); |
@@ -431,18 +448,21 @@ int MemEntryImpl::InternalWriteSparseData(int64 offset, IOBuffer* buf, |
int data_size = child->GetDataSize(kSparseData); |
if (net_log_.IsLogging()) { |
- net_log_.BeginEvent( |
- net::NetLog::TYPE_SPARSE_WRITE_CHILD_DATA, |
- CreateNetLogSparseReadWriteCallback(child->net_log().source(), |
- write_len)); |
+ net_log_.BeginEvent(net::NetLog::TYPE_SPARSE_WRITE_CHILD_DATA, |
+ CreateNetLogSparseReadWriteCallback( |
+ child->net_log().source(), write_len)); |
} |
// Always writes to the child entry. This operation may overwrite data |
// previously written. |
// TODO(hclam): if there is data in the entry and this write is not |
// continuous we may want to discard this write. |
- int ret = child->WriteData(kSparseData, child_offset, io_buf.get(), |
- write_len, CompletionCallback(), true); |
+ int ret = child->WriteData(kSparseData, |
+ child_offset, |
+ io_buf.get(), |
+ write_len, |
+ CompletionCallback(), |
+ true); |
if (net_log_.IsLogging()) { |
net_log_.EndEventWithNetErrorCode( |
net::NetLog::TYPE_SPARSE_WRITE_CHILD_DATA, ret); |
@@ -556,13 +576,14 @@ bool MemEntryImpl::InitSparseInfo() { |
return true; |
} |
-bool MemEntryImpl::InitChildEntry(MemEntryImpl* parent, int child_id, |
+bool MemEntryImpl::InitChildEntry(MemEntryImpl* parent, |
+ int child_id, |
net::NetLog* net_log) { |
DCHECK(!parent_); |
DCHECK(!child_id_); |
- net_log_ = net::BoundNetLog::Make(net_log, |
- net::NetLog::SOURCE_MEMORY_CACHE_ENTRY); |
+ net_log_ = |
+ net::BoundNetLog::Make(net_log, net::NetLog::SOURCE_MEMORY_CACHE_ENTRY); |
net_log_.BeginEvent( |
net::NetLog::TYPE_DISK_CACHE_MEM_ENTRY_IMPL, |
base::Bind(&NetLogChildEntryCreationCallback, parent, child_id_)); |
@@ -607,16 +628,16 @@ int MemEntryImpl::FindNextChild(int64 offset, int len, MemEntryImpl** child) { |
// This points to the first byte that we should be reading from, we need |
// to take care of the filled region and the current offset in the child. |
- int first_pos = std::max(current_child_offset, child_first_pos); |
+ int first_pos = std::max(current_child_offset, child_first_pos); |
// If the first byte position we should read from doesn't exceed the |
// filled region, we have found the first child. |
if (first_pos < current_child->GetDataSize(kSparseData)) { |
- *child = current_child; |
+ *child = current_child; |
- // We need to advance the scanned length. |
- scanned_len += first_pos - current_child_offset; |
- break; |
+ // We need to advance the scanned length. |
+ scanned_len += first_pos - current_child_offset; |
+ break; |
} |
} |
scanned_len += kMaxSparseEntrySize - current_child_offset; |