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, child_offset, io_buf.get(), |
382 io_buf->BytesRemaining(), CompletionCallback()); | 382 io_buf->BytesRemaining(), CompletionCallback()); |
383 if (net_log_.IsLoggingAllEvents()) { | 383 if (net_log_.IsLoggingAllEvents()) { |
384 net_log_.EndEventWithNetErrorCode( | 384 net_log_.EndEventWithNetErrorCode( |
385 net::NetLog::TYPE_SPARSE_READ_CHILD_DATA, ret); | 385 net::NetLog::TYPE_SPARSE_READ_CHILD_DATA, ret); |
386 } | 386 } |
387 | 387 |
388 // If we encounter an error in one entry, return immediately. | 388 // If we encounter an error in one entry, return immediately. |
389 if (ret < 0) | 389 if (ret < 0) |
390 return ret; | 390 return ret; |
391 else if (ret == 0) | 391 else if (ret == 0) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 net_log_.BeginEvent( | 433 net_log_.BeginEvent( |
434 net::NetLog::TYPE_SPARSE_WRITE_CHILD_DATA, | 434 net::NetLog::TYPE_SPARSE_WRITE_CHILD_DATA, |
435 CreateNetLogSparseReadWriteCallback(child->net_log().source(), | 435 CreateNetLogSparseReadWriteCallback(child->net_log().source(), |
436 write_len)); | 436 write_len)); |
437 } | 437 } |
438 | 438 |
439 // Always writes to the child entry. This operation may overwrite data | 439 // Always writes to the child entry. This operation may overwrite data |
440 // previously written. | 440 // previously written. |
441 // TODO(hclam): if there is data in the entry and this write is not | 441 // TODO(hclam): if there is data in the entry and this write is not |
442 // continuous we may want to discard this write. | 442 // continuous we may want to discard this write. |
443 int ret = child->WriteData(kSparseData, child_offset, io_buf, write_len, | 443 int ret = child->WriteData(kSparseData, child_offset, io_buf.get(), |
444 CompletionCallback(), true); | 444 write_len, CompletionCallback(), true); |
445 if (net_log_.IsLoggingAllEvents()) { | 445 if (net_log_.IsLoggingAllEvents()) { |
446 net_log_.EndEventWithNetErrorCode( | 446 net_log_.EndEventWithNetErrorCode( |
447 net::NetLog::TYPE_SPARSE_WRITE_CHILD_DATA, ret); | 447 net::NetLog::TYPE_SPARSE_WRITE_CHILD_DATA, ret); |
448 } | 448 } |
449 if (ret < 0) | 449 if (ret < 0) |
450 return ret; | 450 return ret; |
451 else if (ret == 0) | 451 else if (ret == 0) |
452 break; | 452 break; |
453 | 453 |
454 // Keep a record of the first byte position in the child if the write was | 454 // 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; | 621 scanned_len += kMaxSparseEntrySize - current_child_offset; |
622 } | 622 } |
623 return scanned_len; | 623 return scanned_len; |
624 } | 624 } |
625 | 625 |
626 void MemEntryImpl::DetachChild(int child_id) { | 626 void MemEntryImpl::DetachChild(int child_id) { |
627 children_->erase(child_id); | 627 children_->erase(child_id); |
628 } | 628 } |
629 | 629 |
630 } // namespace disk_cache | 630 } // namespace disk_cache |
OLD | NEW |