Index: net/disk_cache/blockfile/sparse_control_v3.cc |
diff --git a/net/disk_cache/blockfile/sparse_control_v3.cc b/net/disk_cache/blockfile/sparse_control_v3.cc |
index 66a60a21bb135f0987515c00e9541867179098b3..63881e2c5412c8dcb60469bd93bdbec3d843cedc 100644 |
--- a/net/disk_cache/blockfile/sparse_control_v3.cc |
+++ b/net/disk_cache/blockfile/sparse_control_v3.cc |
@@ -42,16 +42,16 @@ const int kBlockSize = 1024; |
// If the entry is called entry_name, child entries will be named something |
// like Range_entry_name:XXX:YYY where XXX is the entry signature and YYY is the |
// number of the particular child. |
-std::string GenerateChildName(const std::string& base_name, int64 signature, |
+std::string GenerateChildName(const std::string& base_name, |
+ int64 signature, |
int64 child_id) { |
- return base::StringPrintf("Range_%s:%" PRIx64 ":%" PRIx64, base_name.c_str(), |
- signature, child_id); |
+ return base::StringPrintf( |
+ "Range_%s:%" PRIx64 ":%" PRIx64, base_name.c_str(), signature, child_id); |
} |
// This class deletes the children of a sparse entry. |
-class ChildrenDeleter |
- : public base::RefCounted<ChildrenDeleter>, |
- public disk_cache::FileIOCallback { |
+class ChildrenDeleter : public base::RefCounted<ChildrenDeleter>, |
+ public disk_cache::FileIOCallback { |
public: |
ChildrenDeleter(disk_cache::BackendImpl* backend, const std::string& name) |
: backend_(backend->GetWeakPtr()), name_(name), signature_(0) {} |
@@ -222,8 +222,11 @@ bool SparseControl::CouldBeSparse() const { |
return (entry_->GetDataSize(kSparseIndex) != 0); |
} |
-int SparseControl::StartIO(SparseOperation op, int64 offset, net::IOBuffer* buf, |
- int buf_len, const CompletionCallback& callback) { |
+int SparseControl::StartIO(SparseOperation op, |
+ int64 offset, |
+ net::IOBuffer* buf, |
+ int buf_len, |
+ const CompletionCallback& callback) { |
DCHECK(init_); |
// We don't support simultaneous IO for sparse data. |
if (operation_ != kNoOperation) |
@@ -281,8 +284,8 @@ int SparseControl::GetAvailableRange(int64 offset, int len, int64* start) { |
DCHECK(start); |
range_found_ = false; |
- int result = StartIO( |
- kGetRangeOperation, offset, NULL, len, CompletionCallback()); |
+ int result = |
+ StartIO(kGetRangeOperation, offset, NULL, len, CompletionCallback()); |
if (range_found_) { |
*start = offset_; |
return result; |
@@ -332,8 +335,8 @@ void SparseControl::DeleteChildren(EntryImpl* entry) { |
entry->net_log().AddEvent(net::NetLog::TYPE_SPARSE_DELETE_CHILDREN); |
DCHECK(entry->backend_); |
- ChildrenDeleter* deleter = new ChildrenDeleter(entry->backend_.get(), |
- entry->GetKey()); |
+ ChildrenDeleter* deleter = |
+ new ChildrenDeleter(entry->backend_.get(), entry->GetKey()); |
// The object will self destruct when finished. |
deleter->AddRef(); |
@@ -387,8 +390,12 @@ int SparseControl::CreateSparseEntry() { |
scoped_refptr<net::IOBuffer> buf( |
new net::WrappedIOBuffer(reinterpret_cast<char*>(&sparse_header_))); |
- int rv = entry_->WriteData(kSparseIndex, 0, buf.get(), sizeof(sparse_header_), |
- CompletionCallback(), false); |
+ int rv = entry_->WriteData(kSparseIndex, |
+ 0, |
+ buf.get(), |
+ sizeof(sparse_header_), |
+ CompletionCallback(), |
+ false); |
if (rv != sizeof(sparse_header_)) { |
DLOG(ERROR) << "Unable to save sparse_header_"; |
return net::ERR_CACHE_OPERATION_NOT_SUPPORTED; |
@@ -418,8 +425,8 @@ int SparseControl::OpenSparseEntry(int data_len) { |
new net::WrappedIOBuffer(reinterpret_cast<char*>(&sparse_header_))); |
// Read header. |
- int rv = entry_->ReadData(kSparseIndex, 0, buf.get(), sizeof(sparse_header_), |
- CompletionCallback()); |
+ int rv = entry_->ReadData( |
+ kSparseIndex, 0, buf.get(), sizeof(sparse_header_), CompletionCallback()); |
if (rv != static_cast<int>(sizeof(sparse_header_))) |
return net::ERR_CACHE_READ_FAILURE; |
@@ -432,8 +439,11 @@ int SparseControl::OpenSparseEntry(int data_len) { |
// Read the actual bitmap. |
buf = new net::IOBuffer(map_len); |
- rv = entry_->ReadData(kSparseIndex, sizeof(sparse_header_), buf.get(), |
- map_len, CompletionCallback()); |
+ rv = entry_->ReadData(kSparseIndex, |
+ sizeof(sparse_header_), |
+ buf.get(), |
+ map_len, |
+ CompletionCallback()); |
if (rv != map_len) |
return net::ERR_CACHE_READ_FAILURE; |
@@ -467,16 +477,15 @@ bool SparseControl::OpenChild() { |
EntryImpl* child = static_cast<EntryImpl*>(child_); |
if (!(CHILD_ENTRY & child->GetEntryFlags()) || |
- child->GetDataSize(kSparseIndex) < |
- static_cast<int>(sizeof(child_data_))) |
+ child->GetDataSize(kSparseIndex) < static_cast<int>(sizeof(child_data_))) |
return KillChildAndContinue(key, false); |
scoped_refptr<net::WrappedIOBuffer> buf( |
new net::WrappedIOBuffer(reinterpret_cast<char*>(&child_data_))); |
// Read signature. |
- int rv = child_->ReadData(kSparseIndex, 0, buf.get(), sizeof(child_data_), |
- CompletionCallback()); |
+ int rv = child_->ReadData( |
+ kSparseIndex, 0, buf.get(), sizeof(child_data_), CompletionCallback()); |
if (rv != sizeof(child_data_)) |
return KillChildAndContinue(key, true); // This is a fatal failure. |
@@ -499,9 +508,12 @@ void SparseControl::CloseChild() { |
new net::WrappedIOBuffer(reinterpret_cast<char*>(&child_data_))); |
// Save the allocation bitmap before closing the child entry. |
- int rv = child_->WriteData(kSparseIndex, 0, buf.get(), sizeof(child_data_), |
+ int rv = child_->WriteData(kSparseIndex, |
+ 0, |
+ buf.get(), |
+ sizeof(child_data_), |
CompletionCallback(), |
- false); |
+ false); |
if (rv != sizeof(child_data_)) |
DLOG(ERROR) << "Failed to save child data"; |
child_->Release(); |
@@ -534,8 +546,12 @@ void SparseControl::WriteSparseData() { |
reinterpret_cast<const char*>(children_map_.GetMap()))); |
int len = children_map_.ArraySize() * 4; |
- int rv = entry_->WriteData(kSparseIndex, sizeof(sparse_header_), buf.get(), |
- len, CompletionCallback(), false); |
+ int rv = entry_->WriteData(kSparseIndex, |
+ sizeof(sparse_header_), |
+ buf.get(), |
+ len, |
+ CompletionCallback(), |
+ false); |
if (rv != len) { |
DLOG(ERROR) << "Unable to save sparse map"; |
} |
@@ -569,8 +585,8 @@ bool SparseControl::DoChildIO() { |
CreateNetLogSparseReadWriteCallback(child_->net_log().source(), |
child_len_)); |
} |
- rv = child_->ReadDataImpl(kSparseData, child_offset_, user_buf_.get(), |
- child_len_, callback); |
+ rv = child_->ReadDataImpl( |
+ kSparseData, child_offset_, user_buf_.get(), child_len_, callback); |
break; |
case kWriteOperation: |
if (entry_->net_log().IsLogging()) { |
@@ -579,8 +595,12 @@ bool SparseControl::DoChildIO() { |
CreateNetLogSparseReadWriteCallback(child_->net_log().source(), |
child_len_)); |
} |
- rv = child_->WriteDataImpl(kSparseData, child_offset_, user_buf_.get(), |
- child_len_, callback, false); |
+ rv = child_->WriteDataImpl(kSparseData, |
+ child_offset_, |
+ user_buf_.get(), |
+ child_len_, |
+ callback, |
+ false); |
break; |
case kGetRangeOperation: |
rv = DoGetAvailableRange(); |
@@ -627,8 +647,8 @@ void SparseControl::DoChildIOCompleted(int result) { |
} |
std::string SparseControl::GenerateChildKey() { |
- return GenerateChildName(entry_->GetKey(), sparse_header_.signature, |
- offset_ >> 20); |
+ return GenerateChildName( |
+ entry_->GetKey(), sparse_header_.signature, offset_ >> 20); |
} |
// We are deleting the child because something went wrong. |
@@ -759,8 +779,12 @@ void SparseControl::InitChildData() { |
scoped_refptr<net::WrappedIOBuffer> buf( |
new net::WrappedIOBuffer(reinterpret_cast<char*>(&child_data_))); |
- int rv = child_->WriteData(kSparseIndex, 0, buf.get(), sizeof(child_data_), |
- CompletionCallback(), false); |
+ int rv = child_->WriteData(kSparseIndex, |
+ 0, |
+ buf.get(), |
+ sizeof(child_data_), |
+ CompletionCallback(), |
+ false); |
if (rv != sizeof(child_data_)) |
DLOG(ERROR) << "Failed to save child data"; |
SetChildBit(true); |