| 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/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/values.h" | |
| 11 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| 12 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 13 #include "net/disk_cache/backend_impl.h" | 12 #include "net/disk_cache/backend_impl.h" |
| 14 #include "net/disk_cache/bitmap.h" | 13 #include "net/disk_cache/bitmap.h" |
| 15 #include "net/disk_cache/cache_util.h" | 14 #include "net/disk_cache/cache_util.h" |
| 16 #include "net/disk_cache/histogram_macros.h" | 15 #include "net/disk_cache/histogram_macros.h" |
| 17 #include "net/disk_cache/sparse_control.h" | 16 #include "net/disk_cache/sparse_control.h" |
| 18 | 17 |
| 19 using base::Time; | 18 using base::Time; |
| 20 using base::TimeDelta; | 19 using base::TimeDelta; |
| 21 using base::TimeTicks; | 20 using base::TimeTicks; |
| 22 | 21 |
| 23 namespace { | 22 namespace { |
| 24 | 23 |
| 25 // Index for the file used to store the key, if any (files_[kKeyFileIndex]). | 24 // Index for the file used to store the key, if any (files_[kKeyFileIndex]). |
| 26 const int kKeyFileIndex = 3; | 25 const int kKeyFileIndex = 3; |
| 27 | 26 |
| 28 // NetLog parameters for the creation of an EntryImpl. Contains an entry's name | |
| 29 // and whether it was created or opened. | |
| 30 class EntryCreationParameters : public net::NetLog::EventParameters { | |
| 31 public: | |
| 32 EntryCreationParameters(const std::string& key, bool created) | |
| 33 : key_(key), created_(created) { | |
| 34 } | |
| 35 | |
| 36 Value* ToValue() const { | |
| 37 DictionaryValue* dict = new DictionaryValue(); | |
| 38 dict->SetString("key", key_); | |
| 39 dict->SetBoolean("created", created_); | |
| 40 return dict; | |
| 41 } | |
| 42 | |
| 43 private: | |
| 44 const std::string key_; | |
| 45 const bool created_; | |
| 46 | |
| 47 DISALLOW_COPY_AND_ASSIGN(EntryCreationParameters); | |
| 48 }; | |
| 49 | |
| 50 // NetLog parameters for non-sparse reading and writing to an EntryImpl. | |
| 51 class ReadWriteDataParams : public net::NetLog::EventParameters { | |
| 52 public: | |
| 53 // For reads, |truncate| must be false. | |
| 54 ReadWriteDataParams(int index, int offset, int buf_len, bool truncate) | |
| 55 : index_(index), offset_(offset), buf_len_(buf_len), truncate_(truncate) { | |
| 56 } | |
| 57 | |
| 58 Value* ToValue() const { | |
| 59 DictionaryValue* dict = new DictionaryValue(); | |
| 60 dict->SetInteger("index", index_); | |
| 61 dict->SetInteger("offset", offset_); | |
| 62 dict->SetInteger("buf_len", buf_len_); | |
| 63 if (truncate_) | |
| 64 dict->SetBoolean("truncate", truncate_); | |
| 65 return dict; | |
| 66 } | |
| 67 | |
| 68 private: | |
| 69 const int index_; | |
| 70 const int offset_; | |
| 71 const int buf_len_; | |
| 72 const bool truncate_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(ReadWriteDataParams); | |
| 75 }; | |
| 76 | |
| 77 // NetLog parameters logged when non-sparse reads and writes complete. | |
| 78 class FileIOCompleteParameters : public net::NetLog::EventParameters { | |
| 79 public: | |
| 80 // |bytes_copied| is either the number of bytes copied or a network error | |
| 81 // code. |bytes_copied| must not be ERR_IO_PENDING, as it's not a valid | |
| 82 // result for an operation. | |
| 83 explicit FileIOCompleteParameters(int bytes_copied) | |
| 84 : bytes_copied_(bytes_copied) { | |
| 85 } | |
| 86 | |
| 87 Value* ToValue() const { | |
| 88 DCHECK_NE(bytes_copied_, net::ERR_IO_PENDING); | |
| 89 DictionaryValue* dict = new DictionaryValue(); | |
| 90 if (bytes_copied_ < 0) { | |
| 91 dict->SetInteger("net_error", bytes_copied_); | |
| 92 } else { | |
| 93 dict->SetInteger("bytes_copied", bytes_copied_); | |
| 94 } | |
| 95 return dict; | |
| 96 } | |
| 97 | |
| 98 private: | |
| 99 const int bytes_copied_; | |
| 100 | |
| 101 DISALLOW_COPY_AND_ASSIGN(FileIOCompleteParameters); | |
| 102 }; | |
| 103 | |
| 104 // This class implements FileIOCallback to buffer the callback from a file IO | 27 // This class implements FileIOCallback to buffer the callback from a file IO |
| 105 // operation from the actual net class. | 28 // operation from the actual net class. |
| 106 class SyncCallback: public disk_cache::FileIOCallback { | 29 class SyncCallback: public disk_cache::FileIOCallback { |
| 107 public: | 30 public: |
| 108 // |end_event_type| is the event type to log on completion. Logs nothing on | |
| 109 // discard, or when the NetLog is not set to log all events. | |
| 110 SyncCallback(disk_cache::EntryImpl* entry, net::IOBuffer* buffer, | 31 SyncCallback(disk_cache::EntryImpl* entry, net::IOBuffer* buffer, |
| 111 net::CompletionCallback* callback, | 32 net::CompletionCallback* callback ) |
| 112 net::NetLog::EventType end_event_type) | |
| 113 : entry_(entry), callback_(callback), buf_(buffer), | 33 : entry_(entry), callback_(callback), buf_(buffer), |
| 114 start_(TimeTicks::Now()), end_event_type_(end_event_type) { | 34 start_(TimeTicks::Now()) { |
| 115 entry->AddRef(); | 35 entry->AddRef(); |
| 116 entry->IncrementIoCount(); | 36 entry->IncrementIoCount(); |
| 117 } | 37 } |
| 118 ~SyncCallback() {} | 38 ~SyncCallback() {} |
| 119 | 39 |
| 120 virtual void OnFileIOComplete(int bytes_copied); | 40 virtual void OnFileIOComplete(int bytes_copied); |
| 121 void Discard(); | 41 void Discard(); |
| 122 | |
| 123 private: | 42 private: |
| 124 disk_cache::EntryImpl* entry_; | 43 disk_cache::EntryImpl* entry_; |
| 125 net::CompletionCallback* callback_; | 44 net::CompletionCallback* callback_; |
| 126 scoped_refptr<net::IOBuffer> buf_; | 45 scoped_refptr<net::IOBuffer> buf_; |
| 127 TimeTicks start_; | 46 TimeTicks start_; |
| 128 net::NetLog::EventType end_event_type_; | |
| 129 | 47 |
| 130 DISALLOW_COPY_AND_ASSIGN(SyncCallback); | 48 DISALLOW_COPY_AND_ASSIGN(SyncCallback); |
| 131 }; | 49 }; |
| 132 | 50 |
| 133 void SyncCallback::OnFileIOComplete(int bytes_copied) { | 51 void SyncCallback::OnFileIOComplete(int bytes_copied) { |
| 134 entry_->DecrementIoCount(); | 52 entry_->DecrementIoCount(); |
| 135 if (callback_) { | 53 if (callback_) { |
| 136 if (entry_->net_log().IsLoggingAllEvents()) { | |
| 137 entry_->net_log().EndEvent( | |
| 138 end_event_type_, | |
| 139 make_scoped_refptr(new FileIOCompleteParameters(bytes_copied))); | |
| 140 } | |
| 141 entry_->ReportIOTime(disk_cache::EntryImpl::kAsyncIO, start_); | 54 entry_->ReportIOTime(disk_cache::EntryImpl::kAsyncIO, start_); |
| 142 callback_->Run(bytes_copied); | 55 callback_->Run(bytes_copied); |
| 143 } | 56 } |
| 144 entry_->Release(); | 57 entry_->Release(); |
| 145 delete this; | 58 delete this; |
| 146 } | 59 } |
| 147 | 60 |
| 148 void SyncCallback::Discard() { | 61 void SyncCallback::Discard() { |
| 149 callback_ = NULL; | 62 callback_ = NULL; |
| 150 buf_ = NULL; | 63 buf_ = NULL; |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 // maybe for a child entry, so it is important to do it before deleting this | 301 // maybe for a child entry, so it is important to do it before deleting this |
| 389 // entry. | 302 // entry. |
| 390 sparse_.reset(); | 303 sparse_.reset(); |
| 391 | 304 |
| 392 // Remove this entry from the list of open entries. | 305 // Remove this entry from the list of open entries. |
| 393 backend_->OnEntryDestroyBegin(entry_.address()); | 306 backend_->OnEntryDestroyBegin(entry_.address()); |
| 394 | 307 |
| 395 if (doomed_) { | 308 if (doomed_) { |
| 396 DeleteEntryData(true); | 309 DeleteEntryData(true); |
| 397 } else { | 310 } else { |
| 398 net_log_.AddEvent(net::NetLog::TYPE_DISK_CACHE_CLOSE, NULL); | |
| 399 bool ret = true; | 311 bool ret = true; |
| 400 for (int index = 0; index < kNumStreams; index++) { | 312 for (int index = 0; index < kNumStreams; index++) { |
| 401 if (user_buffers_[index].get()) { | 313 if (user_buffers_[index].get()) { |
| 402 if (!(ret = Flush(index, 0))) | 314 if (!(ret = Flush(index, 0))) |
| 403 LOG(ERROR) << "Failed to save user data"; | 315 LOG(ERROR) << "Failed to save user data"; |
| 404 } | 316 } |
| 405 if (unreported_size_[index]) { | 317 if (unreported_size_[index]) { |
| 406 backend_->ModifyStorageSize( | 318 backend_->ModifyStorageSize( |
| 407 entry_.Data()->data_size[index] - unreported_size_[index], | 319 entry_.Data()->data_size[index] - unreported_size_[index], |
| 408 entry_.Data()->data_size[index]); | 320 entry_.Data()->data_size[index]); |
| 409 } | 321 } |
| 410 } | 322 } |
| 411 | 323 |
| 412 if (!ret) { | 324 if (!ret) { |
| 413 // There was a failure writing the actual data. Mark the entry as dirty. | 325 // There was a failure writing the actual data. Mark the entry as dirty. |
| 414 int current_id = backend_->GetCurrentEntryId(); | 326 int current_id = backend_->GetCurrentEntryId(); |
| 415 node_.Data()->dirty = current_id == 1 ? -1 : current_id - 1; | 327 node_.Data()->dirty = current_id == 1 ? -1 : current_id - 1; |
| 416 node_.Store(); | 328 node_.Store(); |
| 417 } else if (node_.HasData() && node_.Data()->dirty) { | 329 } else if (node_.HasData() && node_.Data()->dirty) { |
| 418 node_.Data()->dirty = 0; | 330 node_.Data()->dirty = 0; |
| 419 node_.Store(); | 331 node_.Store(); |
| 420 } | 332 } |
| 421 } | 333 } |
| 422 | 334 |
| 423 Trace("~EntryImpl out 0x%p", reinterpret_cast<void*>(this)); | 335 Trace("~EntryImpl out 0x%p", reinterpret_cast<void*>(this)); |
| 424 net_log_.EndEvent(net::NetLog::TYPE_DISK_CACHE_ENTRY, NULL); | |
| 425 backend_->OnEntryDestroyEnd(); | 336 backend_->OnEntryDestroyEnd(); |
| 426 } | 337 } |
| 427 | 338 |
| 428 void EntryImpl::Doom() { | 339 void EntryImpl::Doom() { |
| 429 backend_->background_queue()->DoomEntryImpl(this); | 340 backend_->background_queue()->DoomEntryImpl(this); |
| 430 } | 341 } |
| 431 | 342 |
| 432 void EntryImpl::Close() { | 343 void EntryImpl::Close() { |
| 433 backend_->background_queue()->CloseEntryImpl(this); | 344 backend_->background_queue()->CloseEntryImpl(this); |
| 434 } | 345 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 void EntryImpl::DoomImpl() { | 480 void EntryImpl::DoomImpl() { |
| 570 if (doomed_) | 481 if (doomed_) |
| 571 return; | 482 return; |
| 572 | 483 |
| 573 SetPointerForInvalidEntry(backend_->GetCurrentEntryId()); | 484 SetPointerForInvalidEntry(backend_->GetCurrentEntryId()); |
| 574 backend_->InternalDoomEntry(this); | 485 backend_->InternalDoomEntry(this); |
| 575 } | 486 } |
| 576 | 487 |
| 577 int EntryImpl::ReadDataImpl(int index, int offset, net::IOBuffer* buf, | 488 int EntryImpl::ReadDataImpl(int index, int offset, net::IOBuffer* buf, |
| 578 int buf_len, CompletionCallback* callback) { | 489 int buf_len, CompletionCallback* callback) { |
| 579 if (net_log_.IsLoggingAllEvents()) { | |
| 580 net_log_.BeginEvent( | |
| 581 net::NetLog::TYPE_DISK_CACHE_READ_DATA, | |
| 582 make_scoped_refptr( | |
| 583 new ReadWriteDataParams(index, offset, buf_len, false))); | |
| 584 } | |
| 585 | |
| 586 int result = InternalReadData(index, offset, buf, buf_len, callback); | |
| 587 | |
| 588 if (result != net::ERR_IO_PENDING && net_log_.IsLoggingAllEvents()) { | |
| 589 net_log_.EndEvent( | |
| 590 net::NetLog::TYPE_DISK_CACHE_READ_DATA, | |
| 591 make_scoped_refptr(new FileIOCompleteParameters(result))); | |
| 592 } | |
| 593 return result; | |
| 594 } | |
| 595 | |
| 596 int EntryImpl::WriteDataImpl(int index, int offset, net::IOBuffer* buf, | |
| 597 int buf_len, CompletionCallback* callback, | |
| 598 bool truncate) { | |
| 599 if (net_log_.IsLoggingAllEvents()) { | |
| 600 net_log_.BeginEvent( | |
| 601 net::NetLog::TYPE_DISK_CACHE_WRITE_DATA, | |
| 602 make_scoped_refptr( | |
| 603 new ReadWriteDataParams(index, offset, buf_len, truncate))); | |
| 604 } | |
| 605 | |
| 606 int result = InternalWriteData(index, offset, buf, buf_len, callback, | |
| 607 truncate); | |
| 608 | |
| 609 if (result != net::ERR_IO_PENDING && net_log_.IsLoggingAllEvents()) { | |
| 610 net_log_.EndEvent( | |
| 611 net::NetLog::TYPE_DISK_CACHE_WRITE_DATA, | |
| 612 make_scoped_refptr(new FileIOCompleteParameters(result))); | |
| 613 } | |
| 614 return result; | |
| 615 } | |
| 616 | |
| 617 int EntryImpl::InternalReadData(int index, int offset, net::IOBuffer* buf, | |
| 618 int buf_len, CompletionCallback* callback) { | |
| 619 DCHECK(node_.Data()->dirty || read_only_); | 490 DCHECK(node_.Data()->dirty || read_only_); |
| 620 DVLOG(2) << "Read from " << index << " at " << offset << " : " << buf_len; | 491 DVLOG(2) << "Read from " << index << " at " << offset << " : " << buf_len; |
| 621 if (index < 0 || index >= kNumStreams) | 492 if (index < 0 || index >= kNumStreams) |
| 622 return net::ERR_INVALID_ARGUMENT; | 493 return net::ERR_INVALID_ARGUMENT; |
| 623 | 494 |
| 624 int entry_size = entry_.Data()->data_size[index]; | 495 int entry_size = entry_.Data()->data_size[index]; |
| 625 if (offset >= entry_size || offset < 0 || !buf_len) | 496 if (offset >= entry_size || offset < 0 || !buf_len) |
| 626 return 0; | 497 return 0; |
| 627 | 498 |
| 628 if (buf_len < 0) | 499 if (buf_len < 0) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 658 return net::ERR_FAILED; | 529 return net::ERR_FAILED; |
| 659 | 530 |
| 660 size_t file_offset = offset; | 531 size_t file_offset = offset; |
| 661 if (address.is_block_file()) { | 532 if (address.is_block_file()) { |
| 662 DCHECK_LE(offset + buf_len, kMaxBlockSize); | 533 DCHECK_LE(offset + buf_len, kMaxBlockSize); |
| 663 file_offset += address.start_block() * address.BlockSize() + | 534 file_offset += address.start_block() * address.BlockSize() + |
| 664 kBlockHeaderSize; | 535 kBlockHeaderSize; |
| 665 } | 536 } |
| 666 | 537 |
| 667 SyncCallback* io_callback = NULL; | 538 SyncCallback* io_callback = NULL; |
| 668 if (callback) { | 539 if (callback) |
| 669 io_callback = new SyncCallback(this, buf, callback, | 540 io_callback = new SyncCallback(this, buf, callback); |
| 670 net::NetLog::TYPE_DISK_CACHE_READ_DATA); | |
| 671 } | |
| 672 | 541 |
| 673 bool completed; | 542 bool completed; |
| 674 if (!file->Read(buf->data(), buf_len, file_offset, io_callback, &completed)) { | 543 if (!file->Read(buf->data(), buf_len, file_offset, io_callback, &completed)) { |
| 675 if (io_callback) | 544 if (io_callback) |
| 676 io_callback->Discard(); | 545 io_callback->Discard(); |
| 677 return net::ERR_FAILED; | 546 return net::ERR_FAILED; |
| 678 } | 547 } |
| 679 | 548 |
| 680 if (io_callback && completed) | 549 if (io_callback && completed) |
| 681 io_callback->Discard(); | 550 io_callback->Discard(); |
| 682 | 551 |
| 683 ReportIOTime(kRead, start); | 552 ReportIOTime(kRead, start); |
| 684 return (completed || !callback) ? buf_len : net::ERR_IO_PENDING; | 553 return (completed || !callback) ? buf_len : net::ERR_IO_PENDING; |
| 685 } | 554 } |
| 686 | 555 |
| 687 int EntryImpl::InternalWriteData(int index, int offset, net::IOBuffer* buf, | 556 int EntryImpl::WriteDataImpl(int index, int offset, net::IOBuffer* buf, |
| 688 int buf_len, CompletionCallback* callback, | 557 int buf_len, CompletionCallback* callback, |
| 689 bool truncate) { | 558 bool truncate) { |
| 690 DCHECK(node_.Data()->dirty || read_only_); | 559 DCHECK(node_.Data()->dirty || read_only_); |
| 691 DVLOG(2) << "Write to " << index << " at " << offset << " : " << buf_len; | 560 DVLOG(2) << "Write to " << index << " at " << offset << " : " << buf_len; |
| 692 if (index < 0 || index >= kNumStreams) | 561 if (index < 0 || index >= kNumStreams) |
| 693 return net::ERR_INVALID_ARGUMENT; | 562 return net::ERR_INVALID_ARGUMENT; |
| 694 | 563 |
| 695 if (offset < 0 || buf_len < 0) | 564 if (offset < 0 || buf_len < 0) |
| 696 return net::ERR_INVALID_ARGUMENT; | 565 return net::ERR_INVALID_ARGUMENT; |
| 697 | 566 |
| 698 int max_file_size = backend_->MaxFileSize(); | 567 int max_file_size = backend_->MaxFileSize(); |
| 699 | 568 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 kBlockHeaderSize; | 621 kBlockHeaderSize; |
| 753 } else if (truncate || (extending && !buf_len)) { | 622 } else if (truncate || (extending && !buf_len)) { |
| 754 if (!file->SetLength(offset + buf_len)) | 623 if (!file->SetLength(offset + buf_len)) |
| 755 return net::ERR_FAILED; | 624 return net::ERR_FAILED; |
| 756 } | 625 } |
| 757 | 626 |
| 758 if (!buf_len) | 627 if (!buf_len) |
| 759 return 0; | 628 return 0; |
| 760 | 629 |
| 761 SyncCallback* io_callback = NULL; | 630 SyncCallback* io_callback = NULL; |
| 762 if (callback) { | 631 if (callback) |
| 763 io_callback = new SyncCallback(this, buf, callback, | 632 io_callback = new SyncCallback(this, buf, callback); |
| 764 net::NetLog::TYPE_DISK_CACHE_WRITE_DATA); | |
| 765 } | |
| 766 | 633 |
| 767 bool completed; | 634 bool completed; |
| 768 if (!file->Write(buf->data(), buf_len, file_offset, io_callback, | 635 if (!file->Write(buf->data(), buf_len, file_offset, io_callback, |
| 769 &completed)) { | 636 &completed)) { |
| 770 if (io_callback) | 637 if (io_callback) |
| 771 io_callback->Discard(); | 638 io_callback->Discard(); |
| 772 return net::ERR_FAILED; | 639 return net::ERR_FAILED; |
| 773 } | 640 } |
| 774 | 641 |
| 775 if (io_callback && completed) | 642 if (io_callback && completed) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 bool EntryImpl::IsSameEntry(const std::string& key, uint32 hash) { | 750 bool EntryImpl::IsSameEntry(const std::string& key, uint32 hash) { |
| 884 if (entry_.Data()->hash != hash || | 751 if (entry_.Data()->hash != hash || |
| 885 static_cast<size_t>(entry_.Data()->key_len) != key.size()) | 752 static_cast<size_t>(entry_.Data()->key_len) != key.size()) |
| 886 return false; | 753 return false; |
| 887 | 754 |
| 888 std::string my_key = GetKey(); | 755 std::string my_key = GetKey(); |
| 889 return key.compare(my_key) ? false : true; | 756 return key.compare(my_key) ? false : true; |
| 890 } | 757 } |
| 891 | 758 |
| 892 void EntryImpl::InternalDoom() { | 759 void EntryImpl::InternalDoom() { |
| 893 net_log_.AddEvent(net::NetLog::TYPE_DISK_CACHE_DOOM, NULL); | |
| 894 DCHECK(node_.HasData()); | 760 DCHECK(node_.HasData()); |
| 895 if (!node_.Data()->dirty) { | 761 if (!node_.Data()->dirty) { |
| 896 node_.Data()->dirty = backend_->GetCurrentEntryId(); | 762 node_.Data()->dirty = backend_->GetCurrentEntryId(); |
| 897 node_.Store(); | 763 node_.Store(); |
| 898 } | 764 } |
| 899 doomed_ = true; | 765 doomed_ = true; |
| 900 } | 766 } |
| 901 | 767 |
| 902 void EntryImpl::DeleteEntryData(bool everything) { | 768 void EntryImpl::DeleteEntryData(bool everything) { |
| 903 DCHECK(doomed_ || !everything); | 769 DCHECK(doomed_ || !everything); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 CACHE_UMA(AGE_MS, "SparseWriteTime", 0, start); | 907 CACHE_UMA(AGE_MS, "SparseWriteTime", 0, start); |
| 1042 break; | 908 break; |
| 1043 case kAsyncIO: | 909 case kAsyncIO: |
| 1044 CACHE_UMA(AGE_MS, "AsyncIOTime", group, start); | 910 CACHE_UMA(AGE_MS, "AsyncIOTime", group, start); |
| 1045 break; | 911 break; |
| 1046 default: | 912 default: |
| 1047 NOTREACHED(); | 913 NOTREACHED(); |
| 1048 } | 914 } |
| 1049 } | 915 } |
| 1050 | 916 |
| 1051 void EntryImpl::BeginLogging(net::NetLog* net_log, bool created) { | |
| 1052 DCHECK(!net_log_.net_log()); | |
| 1053 net_log_ = net::BoundNetLog::Make( | |
| 1054 net_log, net::NetLog::SOURCE_DISK_CACHE_ENTRY); | |
| 1055 net_log_.BeginEvent( | |
| 1056 net::NetLog::TYPE_DISK_CACHE_ENTRY, | |
| 1057 make_scoped_refptr(new EntryCreationParameters(GetKey(), created))); | |
| 1058 } | |
| 1059 | |
| 1060 const net::BoundNetLog& EntryImpl::net_log() const { | |
| 1061 return net_log_; | |
| 1062 } | |
| 1063 | |
| 1064 // ------------------------------------------------------------------------ | 917 // ------------------------------------------------------------------------ |
| 1065 | 918 |
| 1066 bool EntryImpl::CreateDataBlock(int index, int size) { | 919 bool EntryImpl::CreateDataBlock(int index, int size) { |
| 1067 DCHECK(index >= 0 && index < kNumStreams); | 920 DCHECK(index >= 0 && index < kNumStreams); |
| 1068 | 921 |
| 1069 Addr address(entry_.Data()->data_addr[index]); | 922 Addr address(entry_.Data()->data_addr[index]); |
| 1070 if (!CreateBlock(size, &address)) | 923 if (!CreateBlock(size, &address)) |
| 1071 return false; | 924 return false; |
| 1072 | 925 |
| 1073 entry_.Data()->data_addr[index] = address.value(); | 926 entry_.Data()->data_addr[index] = address.value(); |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1437 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), | 1290 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), |
| 1438 entry_.address().value(), node_.address().value()); | 1291 entry_.address().value(), node_.address().value()); |
| 1439 | 1292 |
| 1440 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], | 1293 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], |
| 1441 entry_.Data()->data_addr[1], entry_.Data()->long_key); | 1294 entry_.Data()->data_addr[1], entry_.Data()->long_key); |
| 1442 | 1295 |
| 1443 Trace(" doomed: %d 0x%x", doomed_, dirty); | 1296 Trace(" doomed: %d 0x%x", doomed_, dirty); |
| 1444 } | 1297 } |
| 1445 | 1298 |
| 1446 } // namespace disk_cache | 1299 } // namespace disk_cache |
| OLD | NEW |