| 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_v3.h" | 5 #include "net/disk_cache/blockfile/entry_impl_v3.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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 | 540 |
| 541 if (!background_queue_) | 541 if (!background_queue_) |
| 542 return net::ERR_UNEXPECTED; | 542 return net::ERR_UNEXPECTED; |
| 543 | 543 |
| 544 background_queue_->ReadData(this, index, offset, buf, buf_len, callback); | 544 background_queue_->ReadData(this, index, offset, buf, buf_len, callback); |
| 545 return net::ERR_IO_PENDING; | 545 return net::ERR_IO_PENDING; |
| 546 } | 546 } |
| 547 | 547 |
| 548 int EntryImpl::ReadDataImpl(int index, int offset, IOBuffer* buf, int buf_len, | 548 int EntryImpl::ReadDataImpl(int index, int offset, IOBuffer* buf, int buf_len, |
| 549 const CompletionCallback& callback) { | 549 const CompletionCallback& callback) { |
| 550 if (net_log_.GetCaptureMode().enabled()) { | 550 if (net_log_.HasObservers()) { |
| 551 net_log_.BeginEvent( | 551 net_log_.BeginEvent( |
| 552 net::NetLog::TYPE_ENTRY_READ_DATA, | 552 net::NetLog::TYPE_ENTRY_READ_DATA, |
| 553 CreateNetLogReadWriteDataCallback(index, offset, buf_len, false)); | 553 CreateNetLogReadWriteDataCallback(index, offset, buf_len, false)); |
| 554 } | 554 } |
| 555 | 555 |
| 556 int result = InternalReadData(index, offset, buf, buf_len, callback); | 556 int result = InternalReadData(index, offset, buf, buf_len, callback); |
| 557 | 557 |
| 558 if (result != net::ERR_IO_PENDING && net_log_.GetCaptureMode().enabled()) { | 558 if (result != net::ERR_IO_PENDING && net_log_.HasObservers()) { |
| 559 net_log_.EndEvent( | 559 net_log_.EndEvent( |
| 560 net::NetLog::TYPE_ENTRY_READ_DATA, | 560 net::NetLog::TYPE_ENTRY_READ_DATA, |
| 561 CreateNetLogReadWriteCompleteCallback(result)); | 561 CreateNetLogReadWriteCompleteCallback(result)); |
| 562 } | 562 } |
| 563 return result; | 563 return result; |
| 564 } | 564 } |
| 565 | 565 |
| 566 int EntryImplV3::WriteData(int index, int offset, IOBuffer* buf, int buf_len, | 566 int EntryImplV3::WriteData(int index, int offset, IOBuffer* buf, int buf_len, |
| 567 const CompletionCallback& callback, bool truncate) { | 567 const CompletionCallback& callback, bool truncate) { |
| 568 if (callback.is_null()) | 568 if (callback.is_null()) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 579 return net::ERR_UNEXPECTED; | 579 return net::ERR_UNEXPECTED; |
| 580 | 580 |
| 581 background_queue_->WriteData(this, index, offset, buf, buf_len, truncate, | 581 background_queue_->WriteData(this, index, offset, buf, buf_len, truncate, |
| 582 callback); | 582 callback); |
| 583 return net::ERR_IO_PENDING; | 583 return net::ERR_IO_PENDING; |
| 584 } | 584 } |
| 585 | 585 |
| 586 int EntryImpl::WriteDataImpl(int index, int offset, IOBuffer* buf, int buf_len, | 586 int EntryImpl::WriteDataImpl(int index, int offset, IOBuffer* buf, int buf_len, |
| 587 const CompletionCallback& callback, | 587 const CompletionCallback& callback, |
| 588 bool truncate) { | 588 bool truncate) { |
| 589 if (net_log_.GetCaptureMode().enabled()) { | 589 if (net_log_.HasObservers()) { |
| 590 net_log_.BeginEvent( | 590 net_log_.BeginEvent( |
| 591 net::NetLog::TYPE_ENTRY_WRITE_DATA, | 591 net::NetLog::TYPE_ENTRY_WRITE_DATA, |
| 592 CreateNetLogReadWriteDataCallback(index, offset, buf_len, truncate)); | 592 CreateNetLogReadWriteDataCallback(index, offset, buf_len, truncate)); |
| 593 } | 593 } |
| 594 | 594 |
| 595 int result = InternalWriteData(index, offset, buf, buf_len, callback, | 595 int result = InternalWriteData(index, offset, buf, buf_len, callback, |
| 596 truncate); | 596 truncate); |
| 597 | 597 |
| 598 if (result != net::ERR_IO_PENDING && net_log_.GetCaptureMode().enabled()) { | 598 if (result != net::ERR_IO_PENDING && net_log_.HasObservers()) { |
| 599 net_log_.EndEvent( | 599 net_log_.EndEvent( |
| 600 net::NetLog::TYPE_ENTRY_WRITE_DATA, | 600 net::NetLog::TYPE_ENTRY_WRITE_DATA, |
| 601 CreateNetLogReadWriteCompleteCallback(result)); | 601 CreateNetLogReadWriteCompleteCallback(result)); |
| 602 } | 602 } |
| 603 return result; | 603 return result; |
| 604 } | 604 } |
| 605 | 605 |
| 606 int EntryImplV3::ReadSparseData(int64 offset, IOBuffer* buf, int buf_len, | 606 int EntryImplV3::ReadSparseData(int64 offset, IOBuffer* buf, int buf_len, |
| 607 const CompletionCallback& callback) { | 607 const CompletionCallback& callback) { |
| 608 if (callback.is_null()) | 608 if (callback.is_null()) |
| (...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 | 1455 |
| 1456 int EntryImplV3::ReadyForSparseIO(const CompletionCallback& callback) { | 1456 int EntryImplV3::ReadyForSparseIO(const CompletionCallback& callback) { |
| 1457 return net::ERR_FAILED; | 1457 return net::ERR_FAILED; |
| 1458 } | 1458 } |
| 1459 | 1459 |
| 1460 EntryImplV3::~EntryImplV3() { | 1460 EntryImplV3::~EntryImplV3() { |
| 1461 NOTIMPLEMENTED(); | 1461 NOTIMPLEMENTED(); |
| 1462 } | 1462 } |
| 1463 | 1463 |
| 1464 } // namespace disk_cache | 1464 } // namespace disk_cache |
| OLD | NEW |