| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/disk_cache/blockfile/entry_impl.h" | 5 #include "net/disk_cache/blockfile/entry_impl.h" |
| 6 | 6 |
| 7 #include "base/hash.h" | 7 #include "base/hash.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 scoped_refptr<net::IOBuffer> buf_; | 55 scoped_refptr<net::IOBuffer> buf_; |
| 56 TimeTicks start_; | 56 TimeTicks start_; |
| 57 const net::NetLog::EventType end_event_type_; | 57 const net::NetLog::EventType end_event_type_; |
| 58 | 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(SyncCallback); | 59 DISALLOW_COPY_AND_ASSIGN(SyncCallback); |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 void SyncCallback::OnFileIOComplete(int bytes_copied) { | 62 void SyncCallback::OnFileIOComplete(int bytes_copied) { |
| 63 entry_->DecrementIoCount(); | 63 entry_->DecrementIoCount(); |
| 64 if (!callback_.is_null()) { | 64 if (!callback_.is_null()) { |
| 65 if (entry_->net_log().GetCaptureMode().enabled()) { | 65 if (entry_->net_log().HasObservers()) { |
| 66 entry_->net_log().EndEvent( | 66 entry_->net_log().EndEvent( |
| 67 end_event_type_, | 67 end_event_type_, |
| 68 disk_cache::CreateNetLogReadWriteCompleteCallback(bytes_copied)); | 68 disk_cache::CreateNetLogReadWriteCompleteCallback(bytes_copied)); |
| 69 } | 69 } |
| 70 entry_->ReportIOTime(disk_cache::EntryImpl::kAsyncIO, start_); | 70 entry_->ReportIOTime(disk_cache::EntryImpl::kAsyncIO, start_); |
| 71 buf_ = NULL; // Release the buffer before invoking the callback. | 71 buf_ = NULL; // Release the buffer before invoking the callback. |
| 72 callback_.Run(bytes_copied); | 72 callback_.Run(bytes_copied); |
| 73 } | 73 } |
| 74 entry_->Release(); | 74 entry_->Release(); |
| 75 delete this; | 75 delete this; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 void EntryImpl::DoomImpl() { | 308 void EntryImpl::DoomImpl() { |
| 309 if (doomed_ || !backend_.get()) | 309 if (doomed_ || !backend_.get()) |
| 310 return; | 310 return; |
| 311 | 311 |
| 312 SetPointerForInvalidEntry(backend_->GetCurrentEntryId()); | 312 SetPointerForInvalidEntry(backend_->GetCurrentEntryId()); |
| 313 backend_->InternalDoomEntry(this); | 313 backend_->InternalDoomEntry(this); |
| 314 } | 314 } |
| 315 | 315 |
| 316 int EntryImpl::ReadDataImpl(int index, int offset, IOBuffer* buf, int buf_len, | 316 int EntryImpl::ReadDataImpl(int index, int offset, IOBuffer* buf, int buf_len, |
| 317 const CompletionCallback& callback) { | 317 const CompletionCallback& callback) { |
| 318 if (net_log_.GetCaptureMode().enabled()) { | 318 if (net_log_.HasObservers()) { |
| 319 net_log_.BeginEvent( | 319 net_log_.BeginEvent( |
| 320 net::NetLog::TYPE_ENTRY_READ_DATA, | 320 net::NetLog::TYPE_ENTRY_READ_DATA, |
| 321 CreateNetLogReadWriteDataCallback(index, offset, buf_len, false)); | 321 CreateNetLogReadWriteDataCallback(index, offset, buf_len, false)); |
| 322 } | 322 } |
| 323 | 323 |
| 324 int result = InternalReadData(index, offset, buf, buf_len, callback); | 324 int result = InternalReadData(index, offset, buf, buf_len, callback); |
| 325 | 325 |
| 326 if (result != net::ERR_IO_PENDING && net_log_.GetCaptureMode().enabled()) { | 326 if (result != net::ERR_IO_PENDING && net_log_.HasObservers()) { |
| 327 net_log_.EndEvent( | 327 net_log_.EndEvent( |
| 328 net::NetLog::TYPE_ENTRY_READ_DATA, | 328 net::NetLog::TYPE_ENTRY_READ_DATA, |
| 329 CreateNetLogReadWriteCompleteCallback(result)); | 329 CreateNetLogReadWriteCompleteCallback(result)); |
| 330 } | 330 } |
| 331 return result; | 331 return result; |
| 332 } | 332 } |
| 333 | 333 |
| 334 int EntryImpl::WriteDataImpl(int index, int offset, IOBuffer* buf, int buf_len, | 334 int EntryImpl::WriteDataImpl(int index, int offset, IOBuffer* buf, int buf_len, |
| 335 const CompletionCallback& callback, | 335 const CompletionCallback& callback, |
| 336 bool truncate) { | 336 bool truncate) { |
| 337 if (net_log_.GetCaptureMode().enabled()) { | 337 if (net_log_.HasObservers()) { |
| 338 net_log_.BeginEvent( | 338 net_log_.BeginEvent( |
| 339 net::NetLog::TYPE_ENTRY_WRITE_DATA, | 339 net::NetLog::TYPE_ENTRY_WRITE_DATA, |
| 340 CreateNetLogReadWriteDataCallback(index, offset, buf_len, truncate)); | 340 CreateNetLogReadWriteDataCallback(index, offset, buf_len, truncate)); |
| 341 } | 341 } |
| 342 | 342 |
| 343 int result = InternalWriteData(index, offset, buf, buf_len, callback, | 343 int result = InternalWriteData(index, offset, buf, buf_len, callback, |
| 344 truncate); | 344 truncate); |
| 345 | 345 |
| 346 if (result != net::ERR_IO_PENDING && net_log_.GetCaptureMode().enabled()) { | 346 if (result != net::ERR_IO_PENDING && net_log_.HasObservers()) { |
| 347 net_log_.EndEvent( | 347 net_log_.EndEvent( |
| 348 net::NetLog::TYPE_ENTRY_WRITE_DATA, | 348 net::NetLog::TYPE_ENTRY_WRITE_DATA, |
| 349 CreateNetLogReadWriteCompleteCallback(result)); | 349 CreateNetLogReadWriteCompleteCallback(result)); |
| 350 } | 350 } |
| 351 return result; | 351 return result; |
| 352 } | 352 } |
| 353 | 353 |
| 354 int EntryImpl::ReadSparseDataImpl(int64 offset, IOBuffer* buf, int buf_len, | 354 int EntryImpl::ReadSparseDataImpl(int64 offset, IOBuffer* buf, int buf_len, |
| 355 const CompletionCallback& callback) { | 355 const CompletionCallback& callback) { |
| 356 DCHECK(node_.Data()->dirty || read_only_); | 356 DCHECK(node_.Data()->dirty || read_only_); |
| (...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1545 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), | 1545 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), |
| 1546 entry_.address().value(), node_.address().value()); | 1546 entry_.address().value(), node_.address().value()); |
| 1547 | 1547 |
| 1548 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], | 1548 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], |
| 1549 entry_.Data()->data_addr[1], entry_.Data()->long_key); | 1549 entry_.Data()->data_addr[1], entry_.Data()->long_key); |
| 1550 | 1550 |
| 1551 Trace(" doomed: %d 0x%x", doomed_, dirty); | 1551 Trace(" doomed: %d 0x%x", doomed_, dirty); |
| 1552 } | 1552 } |
| 1553 | 1553 |
| 1554 } // namespace disk_cache | 1554 } // namespace disk_cache |
| OLD | NEW |