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/mem_entry_impl.h" | 5 #include "net/disk_cache/mem_entry_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // If we are trying to read from a position that the child entry has no data | 371 // If we are trying to read from a position that the child entry has no data |
372 // we should stop. | 372 // we should stop. |
373 if (child_offset < child->child_first_pos_) | 373 if (child_offset < child->child_first_pos_) |
374 break; | 374 break; |
375 if (net_log_.IsLoggingAllEvents()) { | 375 if (net_log_.IsLoggingAllEvents()) { |
376 net_log_.BeginEvent( | 376 net_log_.BeginEvent( |
377 net::NetLog::TYPE_SPARSE_READ_CHILD_DATA, | 377 net::NetLog::TYPE_SPARSE_READ_CHILD_DATA, |
378 CreateNetLogSparseReadWriteCallback(child->net_log().source(), | 378 CreateNetLogSparseReadWriteCallback(child->net_log().source(), |
379 io_buf->BytesRemaining())); | 379 io_buf->BytesRemaining())); |
380 } | 380 } |
381 int ret = child->ReadData(kSparseData, child_offset, io_buf, | 381 int ret = child->ReadData(kSparseData, |
382 io_buf->BytesRemaining(), CompletionCallback()); | 382 child_offset, |
| 383 io_buf.get(), |
| 384 io_buf->BytesRemaining(), |
| 385 CompletionCallback()); |
383 if (net_log_.IsLoggingAllEvents()) { | 386 if (net_log_.IsLoggingAllEvents()) { |
384 net_log_.EndEventWithNetErrorCode( | 387 net_log_.EndEventWithNetErrorCode( |
385 net::NetLog::TYPE_SPARSE_READ_CHILD_DATA, ret); | 388 net::NetLog::TYPE_SPARSE_READ_CHILD_DATA, ret); |
386 } | 389 } |
387 | 390 |
388 // If we encounter an error in one entry, return immediately. | 391 // If we encounter an error in one entry, return immediately. |
389 if (ret < 0) | 392 if (ret < 0) |
390 return ret; | 393 return ret; |
391 else if (ret == 0) | 394 else if (ret == 0) |
392 break; | 395 break; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 net_log_.BeginEvent( | 436 net_log_.BeginEvent( |
434 net::NetLog::TYPE_SPARSE_WRITE_CHILD_DATA, | 437 net::NetLog::TYPE_SPARSE_WRITE_CHILD_DATA, |
435 CreateNetLogSparseReadWriteCallback(child->net_log().source(), | 438 CreateNetLogSparseReadWriteCallback(child->net_log().source(), |
436 write_len)); | 439 write_len)); |
437 } | 440 } |
438 | 441 |
439 // Always writes to the child entry. This operation may overwrite data | 442 // Always writes to the child entry. This operation may overwrite data |
440 // previously written. | 443 // previously written. |
441 // TODO(hclam): if there is data in the entry and this write is not | 444 // TODO(hclam): if there is data in the entry and this write is not |
442 // continuous we may want to discard this write. | 445 // continuous we may want to discard this write. |
443 int ret = child->WriteData(kSparseData, child_offset, io_buf, write_len, | 446 int ret = child->WriteData(kSparseData, |
444 CompletionCallback(), true); | 447 child_offset, |
| 448 io_buf.get(), |
| 449 write_len, |
| 450 CompletionCallback(), |
| 451 true); |
445 if (net_log_.IsLoggingAllEvents()) { | 452 if (net_log_.IsLoggingAllEvents()) { |
446 net_log_.EndEventWithNetErrorCode( | 453 net_log_.EndEventWithNetErrorCode( |
447 net::NetLog::TYPE_SPARSE_WRITE_CHILD_DATA, ret); | 454 net::NetLog::TYPE_SPARSE_WRITE_CHILD_DATA, ret); |
448 } | 455 } |
449 if (ret < 0) | 456 if (ret < 0) |
450 return ret; | 457 return ret; |
451 else if (ret == 0) | 458 else if (ret == 0) |
452 break; | 459 break; |
453 | 460 |
454 // Keep a record of the first byte position in the child if the write was | 461 // Keep a record of the first byte position in the child if the write was |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 scanned_len += kMaxSparseEntrySize - current_child_offset; | 628 scanned_len += kMaxSparseEntrySize - current_child_offset; |
622 } | 629 } |
623 return scanned_len; | 630 return scanned_len; |
624 } | 631 } |
625 | 632 |
626 void MemEntryImpl::DetachChild(int child_id) { | 633 void MemEntryImpl::DetachChild(int child_id) { |
627 children_->erase(child_id); | 634 children_->erase(child_id); |
628 } | 635 } |
629 | 636 |
630 } // namespace disk_cache | 637 } // namespace disk_cache |
OLD | NEW |