OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/simple/simple_entry_impl.h" | 5 #include "net/disk_cache/simple/simple_entry_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstring> | 8 #include <cstring> |
9 #include <limits> | 9 #include <limits> |
10 #include <utility> | 10 #include <utility> |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 offset < 0 || !buf_len)) { | 380 offset < 0 || !buf_len)) { |
381 if (net_log_.IsCapturing()) { | 381 if (net_log_.IsCapturing()) { |
382 net_log_.AddEvent(net::NetLogEventType::SIMPLE_CACHE_ENTRY_READ_END, | 382 net_log_.AddEvent(net::NetLogEventType::SIMPLE_CACHE_ENTRY_READ_END, |
383 CreateNetLogReadWriteCompleteCallback(0)); | 383 CreateNetLogReadWriteCompleteCallback(0)); |
384 } | 384 } |
385 | 385 |
386 RecordReadResult(cache_type_, READ_RESULT_NONBLOCK_EMPTY_RETURN); | 386 RecordReadResult(cache_type_, READ_RESULT_NONBLOCK_EMPTY_RETURN); |
387 return 0; | 387 return 0; |
388 } | 388 } |
389 | 389 |
390 // TODO(clamy): return immediatly when reading from stream 0. | |
391 | |
392 // TODO(felipeg): Optimization: Add support for truly parallel read | 390 // TODO(felipeg): Optimization: Add support for truly parallel read |
pasko
2017/04/07 16:13:39
fyi: this one did not show much opportunity on the
| |
393 // operations. | 391 // operations. |
394 bool alone_in_queue = | 392 bool alone_in_queue = |
395 pending_operations_.size() == 0 && state_ == STATE_READY; | 393 pending_operations_.size() == 0 && state_ == STATE_READY; |
394 if (alone_in_queue && stream_index == 0) { | |
395 buf_len = std::min(buf_len, GetDataSize(stream_index) - offset); | |
396 return ReadStream0Data(buf, offset, buf_len); | |
397 } | |
398 | |
396 pending_operations_.push(SimpleEntryOperation::ReadOperation( | 399 pending_operations_.push(SimpleEntryOperation::ReadOperation( |
397 this, stream_index, offset, buf_len, buf, callback, alone_in_queue)); | 400 this, stream_index, offset, buf_len, buf, callback, alone_in_queue)); |
398 RunNextOperationIfNeeded(); | 401 RunNextOperationIfNeeded(); |
399 return net::ERR_IO_PENDING; | 402 return net::ERR_IO_PENDING; |
400 } | 403 } |
401 | 404 |
402 int SimpleEntryImpl::WriteData(int stream_index, | 405 int SimpleEntryImpl::WriteData(int stream_index, |
403 int offset, | 406 int offset, |
404 net::IOBuffer* buf, | 407 net::IOBuffer* buf, |
405 int buf_len, | 408 int buf_len, |
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1562 } | 1565 } |
1563 crc32s_end_offset_[stream_index] = offset + length; | 1566 crc32s_end_offset_[stream_index] = offset + length; |
1564 } else if (offset < crc32s_end_offset_[stream_index]) { | 1567 } else if (offset < crc32s_end_offset_[stream_index]) { |
1565 // If a range for which the crc32 was already computed is rewritten, the | 1568 // If a range for which the crc32 was already computed is rewritten, the |
1566 // computation of the crc32 need to start from 0 again. | 1569 // computation of the crc32 need to start from 0 again. |
1567 crc32s_end_offset_[stream_index] = 0; | 1570 crc32s_end_offset_[stream_index] = 0; |
1568 } | 1571 } |
1569 } | 1572 } |
1570 | 1573 |
1571 } // namespace disk_cache | 1574 } // namespace disk_cache |
OLD | NEW |