diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-19 20:59:27 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-19 20:59:27 +0000 |
commit | 2a65aceb8e3ed63fecf62191ef6fb64d257bf484 (patch) | |
tree | 5f27b5c30f11f32cb8ca87126ef744d637c14590 /net/disk_cache/entry_impl.cc | |
parent | a18c4a5c9a056a2f49eccf360d141c215c85d053 (diff) | |
download | chromium_src-2a65aceb8e3ed63fecf62191ef6fb64d257bf484.zip chromium_src-2a65aceb8e3ed63fecf62191ef6fb64d257bf484.tar.gz chromium_src-2a65aceb8e3ed63fecf62191ef6fb64d257bf484.tar.bz2 |
base::Bind: Convert most of disk_cache.
BUG=none
TEST=none
R=csilv
Review URL: http://codereview.chromium.org/8963030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115019 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/entry_impl.cc')
-rw-r--r-- | net/disk_cache/entry_impl.cc | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/net/disk_cache/entry_impl.cc b/net/disk_cache/entry_impl.cc index b0226a7..ad745a7 100644 --- a/net/disk_cache/entry_impl.cc +++ b/net/disk_cache/entry_impl.cc @@ -33,7 +33,7 @@ class SyncCallback: public disk_cache::FileIOCallback { // |end_event_type| is the event type to log on completion. Logs nothing on // discard, or when the NetLog is not set to log all events. SyncCallback(disk_cache::EntryImpl* entry, net::IOBuffer* buffer, - net::OldCompletionCallback* callback, + const net::CompletionCallback& callback, net::NetLog::EventType end_event_type) : entry_(entry), callback_(callback), buf_(buffer), start_(TimeTicks::Now()), end_event_type_(end_event_type) { @@ -47,7 +47,7 @@ class SyncCallback: public disk_cache::FileIOCallback { private: disk_cache::EntryImpl* entry_; - net::OldCompletionCallback* callback_; + net::CompletionCallback callback_; scoped_refptr<net::IOBuffer> buf_; TimeTicks start_; const net::NetLog::EventType end_event_type_; @@ -57,7 +57,7 @@ class SyncCallback: public disk_cache::FileIOCallback { void SyncCallback::OnFileIOComplete(int bytes_copied) { entry_->DecrementIoCount(); - if (callback_) { + if (!callback_.is_null()) { if (entry_->net_log().IsLoggingAllEvents()) { entry_->net_log().EndEvent( end_event_type_, @@ -65,14 +65,14 @@ void SyncCallback::OnFileIOComplete(int bytes_copied) { new disk_cache::ReadWriteCompleteParameters(bytes_copied))); } entry_->ReportIOTime(disk_cache::EntryImpl::kAsyncIO, start_); - callback_->Run(bytes_copied); + callback_.Run(bytes_copied); } entry_->Release(); delete this; } void SyncCallback::Discard() { - callback_ = NULL; + callback_.Reset(); buf_ = NULL; OnFileIOComplete(0); } @@ -308,8 +308,9 @@ void EntryImpl::DoomImpl() { backend_->InternalDoomEntry(this); } -int EntryImpl::ReadDataImpl(int index, int offset, net::IOBuffer* buf, - int buf_len, OldCompletionCallback* callback) { +int EntryImpl::ReadDataImpl( + int index, int offset, net::IOBuffer* buf, int buf_len, + const net::CompletionCallback& callback) { if (net_log_.IsLoggingAllEvents()) { net_log_.BeginEvent( net::NetLog::TYPE_ENTRY_READ_DATA, @@ -327,9 +328,9 @@ int EntryImpl::ReadDataImpl(int index, int offset, net::IOBuffer* buf, return result; } -int EntryImpl::WriteDataImpl(int index, int offset, net::IOBuffer* buf, - int buf_len, OldCompletionCallback* callback, - bool truncate) { +int EntryImpl::WriteDataImpl( + int index, int offset, net::IOBuffer* buf, int buf_len, + const net::CompletionCallback& callback, bool truncate) { if (net_log_.IsLoggingAllEvents()) { net_log_.BeginEvent( net::NetLog::TYPE_ENTRY_WRITE_DATA, @@ -349,7 +350,7 @@ int EntryImpl::WriteDataImpl(int index, int offset, net::IOBuffer* buf, } int EntryImpl::ReadSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, - OldCompletionCallback* callback) { + const net::CompletionCallback& callback) { DCHECK(node_.Data()->dirty || read_only_); int result = InitSparseData(); if (net::OK != result) @@ -362,8 +363,9 @@ int EntryImpl::ReadSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, return result; } -int EntryImpl::WriteSparseDataImpl(int64 offset, net::IOBuffer* buf, - int buf_len, OldCompletionCallback* callback) { +int EntryImpl::WriteSparseDataImpl( + int64 offset, net::IOBuffer* buf, int buf_len, + const net::CompletionCallback& callback) { DCHECK(node_.Data()->dirty || read_only_); int result = InitSparseData(); if (net::OK != result) @@ -391,7 +393,7 @@ void EntryImpl::CancelSparseIOImpl() { sparse_->CancelIO(); } -int EntryImpl::ReadyForSparseIOImpl(OldCompletionCallback* callback) { +int EntryImpl::ReadyForSparseIOImpl(const net::CompletionCallback& callback) { DCHECK(sparse_.get()); return sparse_->ReadyToUse(callback); } @@ -798,8 +800,8 @@ int32 EntryImpl::GetDataSize(int index) const { } int EntryImpl::ReadData(int index, int offset, net::IOBuffer* buf, int buf_len, - net::OldCompletionCallback* callback) { - if (!callback) + const net::CompletionCallback& callback) { + if (callback.is_null()) return ReadDataImpl(index, offset, buf, buf_len, callback); DCHECK(node_.Data()->dirty || read_only_); @@ -818,9 +820,10 @@ int EntryImpl::ReadData(int index, int offset, net::IOBuffer* buf, int buf_len, return net::ERR_IO_PENDING; } -int EntryImpl::WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, - OldCompletionCallback* callback, bool truncate) { - if (!callback) +int EntryImpl::WriteData( + int index, int offset, net::IOBuffer* buf, int buf_len, + const net::CompletionCallback& callback, bool truncate) { + if (callback.is_null()) return WriteDataImpl(index, offset, buf, buf_len, callback, truncate); DCHECK(node_.Data()->dirty || read_only_); @@ -836,8 +839,8 @@ int EntryImpl::WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, } int EntryImpl::ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len, - net::OldCompletionCallback* callback) { - if (!callback) + const net::CompletionCallback& callback) { + if (callback.is_null()) return ReadSparseDataImpl(offset, buf, buf_len, callback); backend_->background_queue()->ReadSparseData(this, offset, buf, buf_len, @@ -846,8 +849,8 @@ int EntryImpl::ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len, } int EntryImpl::WriteSparseData(int64 offset, net::IOBuffer* buf, int buf_len, - net::OldCompletionCallback* callback) { - if (!callback) + const net::CompletionCallback& callback) { + if (callback.is_null()) return WriteSparseDataImpl(offset, buf, buf_len, callback); backend_->background_queue()->WriteSparseData(this, offset, buf, buf_len, @@ -856,7 +859,7 @@ int EntryImpl::WriteSparseData(int64 offset, net::IOBuffer* buf, int buf_len, } int EntryImpl::GetAvailableRange(int64 offset, int len, int64* start, - OldCompletionCallback* callback) { + const net::CompletionCallback& callback) { backend_->background_queue()->GetAvailableRange(this, offset, len, start, callback); return net::ERR_IO_PENDING; @@ -875,7 +878,7 @@ void EntryImpl::CancelSparseIO() { backend_->background_queue()->CancelSparseIO(this); } -int EntryImpl::ReadyForSparseIO(net::OldCompletionCallback* callback) { +int EntryImpl::ReadyForSparseIO(const net::CompletionCallback& callback) { if (!sparse_.get()) return net::OK; @@ -938,8 +941,9 @@ EntryImpl::~EntryImpl() { // ------------------------------------------------------------------------ -int EntryImpl::InternalReadData(int index, int offset, net::IOBuffer* buf, - int buf_len, OldCompletionCallback* callback) { +int EntryImpl::InternalReadData( + int index, int offset, net::IOBuffer* buf, int buf_len, + const net::CompletionCallback& callback) { DCHECK(node_.Data()->dirty || read_only_); DVLOG(2) << "Read from " << index << " at " << offset << " : " << buf_len; if (index < 0 || index >= kNumStreams) @@ -993,7 +997,7 @@ int EntryImpl::InternalReadData(int index, int offset, net::IOBuffer* buf, } SyncCallback* io_callback = NULL; - if (callback) { + if (!callback.is_null()) { io_callback = new SyncCallback(this, buf, callback, net::NetLog::TYPE_ENTRY_READ_DATA); } @@ -1015,12 +1019,12 @@ int EntryImpl::InternalReadData(int index, int offset, net::IOBuffer* buf, ReportIOTime(kReadAsync1, start_async); ReportIOTime(kRead, start); - return (completed || !callback) ? buf_len : net::ERR_IO_PENDING; + return (completed || callback.is_null()) ? buf_len : net::ERR_IO_PENDING; } -int EntryImpl::InternalWriteData(int index, int offset, net::IOBuffer* buf, - int buf_len, OldCompletionCallback* callback, - bool truncate) { +int EntryImpl::InternalWriteData( + int index, int offset, net::IOBuffer* buf, int buf_len, + const net::CompletionCallback& callback, bool truncate) { DCHECK(node_.Data()->dirty || read_only_); DVLOG(2) << "Write to " << index << " at " << offset << " : " << buf_len; if (index < 0 || index >= kNumStreams) @@ -1093,7 +1097,7 @@ int EntryImpl::InternalWriteData(int index, int offset, net::IOBuffer* buf, return 0; SyncCallback* io_callback = NULL; - if (callback) { + if (!callback.is_null()) { io_callback = new SyncCallback(this, buf, callback, net::NetLog::TYPE_ENTRY_WRITE_DATA); } @@ -1115,7 +1119,7 @@ int EntryImpl::InternalWriteData(int index, int offset, net::IOBuffer* buf, ReportIOTime(kWriteAsync1, start_async); ReportIOTime(kWrite, start); - return (completed || !callback) ? buf_len : net::ERR_IO_PENDING; + return (completed || callback.is_null()) ? buf_len : net::ERR_IO_PENDING; } // ------------------------------------------------------------------------ |