| OLD | NEW |
| 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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/entry_impl.h" | 5 #include "net/disk_cache/entry_impl.h" |
| 6 | 6 |
| 7 #include "base/histogram.h" | 7 #include "base/histogram.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 int EntryImpl::WriteSparseData(int64 offset, net::IOBuffer* buf, int buf_len, | 234 int EntryImpl::WriteSparseData(int64 offset, net::IOBuffer* buf, int buf_len, |
| 235 net::CompletionCallback* callback) { | 235 net::CompletionCallback* callback) { |
| 236 if (!callback) | 236 if (!callback) |
| 237 return WriteSparseDataImpl(offset, buf, buf_len, callback); | 237 return WriteSparseDataImpl(offset, buf, buf_len, callback); |
| 238 | 238 |
| 239 backend_->background_queue()->WriteSparseData(this, offset, buf, buf_len, | 239 backend_->background_queue()->WriteSparseData(this, offset, buf, buf_len, |
| 240 callback); | 240 callback); |
| 241 return net::ERR_IO_PENDING; | 241 return net::ERR_IO_PENDING; |
| 242 } | 242 } |
| 243 | 243 |
| 244 int EntryImpl::GetAvailableRangeImpl(int64 offset, int len, int64* start) { | |
| 245 int result = InitSparseData(); | |
| 246 if (net::OK != result) | |
| 247 return result; | |
| 248 | |
| 249 return sparse_->GetAvailableRange(offset, len, start); | |
| 250 } | |
| 251 | |
| 252 int EntryImpl::GetAvailableRange(int64 offset, int len, int64* start, | 244 int EntryImpl::GetAvailableRange(int64 offset, int len, int64* start, |
| 253 CompletionCallback* callback) { | 245 CompletionCallback* callback) { |
| 254 backend_->background_queue()->GetAvailableRange(this, offset, len, start, | 246 backend_->background_queue()->GetAvailableRange(this, offset, len, start, |
| 255 callback); | 247 callback); |
| 256 return net::ERR_IO_PENDING; | 248 return net::ERR_IO_PENDING; |
| 257 } | 249 } |
| 258 | 250 |
| 259 bool EntryImpl::CouldBeSparse() const { | 251 bool EntryImpl::CouldBeSparse() const { |
| 260 if (sparse_.get()) | 252 if (sparse_.get()) |
| 261 return true; | 253 return true; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 if (net::OK != result) | 464 if (net::OK != result) |
| 473 return result; | 465 return result; |
| 474 | 466 |
| 475 TimeTicks start = TimeTicks::Now(); | 467 TimeTicks start = TimeTicks::Now(); |
| 476 result = sparse_->StartIO(SparseControl::kWriteOperation, offset, buf, | 468 result = sparse_->StartIO(SparseControl::kWriteOperation, offset, buf, |
| 477 buf_len, callback); | 469 buf_len, callback); |
| 478 ReportIOTime(kSparseWrite, start); | 470 ReportIOTime(kSparseWrite, start); |
| 479 return result; | 471 return result; |
| 480 } | 472 } |
| 481 | 473 |
| 474 int EntryImpl::GetAvailableRangeImpl(int64 offset, int len, int64* start) { |
| 475 int result = InitSparseData(); |
| 476 if (net::OK != result) |
| 477 return result; |
| 478 |
| 479 return sparse_->GetAvailableRange(offset, len, start); |
| 480 } |
| 481 |
| 482 void EntryImpl::CancelSparseIOImpl() { | 482 void EntryImpl::CancelSparseIOImpl() { |
| 483 if (!sparse_.get()) | 483 if (!sparse_.get()) |
| 484 return; | 484 return; |
| 485 | 485 |
| 486 sparse_->CancelIO(); | 486 sparse_->CancelIO(); |
| 487 } | 487 } |
| 488 | 488 |
| 489 int EntryImpl::ReadyForSparseIOImpl(CompletionCallback* callback) { | 489 int EntryImpl::ReadyForSparseIOImpl(CompletionCallback* callback) { |
| 490 DCHECK(sparse_.get()); | 490 DCHECK(sparse_.get()); |
| 491 return sparse_->ReadyToUse(callback); | 491 return sparse_->ReadyToUse(callback); |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), | 1014 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), |
| 1015 entry_.address().value(), node_.address().value()); | 1015 entry_.address().value(), node_.address().value()); |
| 1016 | 1016 |
| 1017 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], | 1017 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], |
| 1018 entry_.Data()->data_addr[1], entry_.Data()->long_key); | 1018 entry_.Data()->data_addr[1], entry_.Data()->long_key); |
| 1019 | 1019 |
| 1020 Trace(" doomed: %d 0x%x", doomed_, dirty); | 1020 Trace(" doomed: %d 0x%x", doomed_, dirty); |
| 1021 } | 1021 } |
| 1022 | 1022 |
| 1023 } // namespace disk_cache | 1023 } // namespace disk_cache |
| OLD | NEW |