| 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" |
| 16 #include "net/disk_cache/net_log_parameters.h" |
| 17 #include "net/disk_cache/sparse_control.h" | 17 #include "net/disk_cache/sparse_control.h" |
| 18 | 18 |
| 19 using base::Time; | 19 using base::Time; |
| 20 using base::TimeDelta; | 20 using base::TimeDelta; |
| 21 using base::TimeTicks; | 21 using base::TimeTicks; |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // Index for the file used to store the key, if any (files_[kKeyFileIndex]). | 25 // Index for the file used to store the key, if any (files_[kKeyFileIndex]). |
| 26 const int kKeyFileIndex = 3; | 26 const int kKeyFileIndex = 3; |
| 27 | 27 |
| 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 | 28 // This class implements FileIOCallback to buffer the callback from a file IO |
| 105 // operation from the actual net class. | 29 // operation from the actual net class. |
| 106 class SyncCallback: public disk_cache::FileIOCallback { | 30 class SyncCallback: public disk_cache::FileIOCallback { |
| 107 public: | 31 public: |
| 108 // |end_event_type| is the event type to log on completion. Logs nothing on | 32 // |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. | 33 // discard, or when the NetLog is not set to log all events. |
| 110 SyncCallback(disk_cache::EntryImpl* entry, net::IOBuffer* buffer, | 34 SyncCallback(disk_cache::EntryImpl* entry, net::IOBuffer* buffer, |
| 111 net::CompletionCallback* callback, | 35 net::CompletionCallback* callback, |
| 112 net::NetLog::EventType end_event_type) | 36 net::NetLog::EventType end_event_type) |
| 113 : entry_(entry), callback_(callback), buf_(buffer), | 37 : entry_(entry), callback_(callback), buf_(buffer), |
| 114 start_(TimeTicks::Now()), end_event_type_(end_event_type) { | 38 start_(TimeTicks::Now()), end_event_type_(end_event_type) { |
| 115 entry->AddRef(); | 39 entry->AddRef(); |
| 116 entry->IncrementIoCount(); | 40 entry->IncrementIoCount(); |
| 117 } | 41 } |
| 118 ~SyncCallback() {} | 42 ~SyncCallback() {} |
| 119 | 43 |
| 120 virtual void OnFileIOComplete(int bytes_copied); | 44 virtual void OnFileIOComplete(int bytes_copied); |
| 121 void Discard(); | 45 void Discard(); |
| 122 | 46 |
| 123 private: | 47 private: |
| 124 disk_cache::EntryImpl* entry_; | 48 disk_cache::EntryImpl* entry_; |
| 125 net::CompletionCallback* callback_; | 49 net::CompletionCallback* callback_; |
| 126 scoped_refptr<net::IOBuffer> buf_; | 50 scoped_refptr<net::IOBuffer> buf_; |
| 127 TimeTicks start_; | 51 TimeTicks start_; |
| 128 net::NetLog::EventType end_event_type_; | 52 const net::NetLog::EventType end_event_type_; |
| 129 | 53 |
| 130 DISALLOW_COPY_AND_ASSIGN(SyncCallback); | 54 DISALLOW_COPY_AND_ASSIGN(SyncCallback); |
| 131 }; | 55 }; |
| 132 | 56 |
| 133 void SyncCallback::OnFileIOComplete(int bytes_copied) { | 57 void SyncCallback::OnFileIOComplete(int bytes_copied) { |
| 134 entry_->DecrementIoCount(); | 58 entry_->DecrementIoCount(); |
| 135 if (callback_) { | 59 if (callback_) { |
| 136 if (entry_->net_log().IsLoggingAllEvents()) { | 60 if (entry_->net_log().IsLoggingAllEvents()) { |
| 137 entry_->net_log().EndEvent( | 61 entry_->net_log().EndEvent( |
| 138 end_event_type_, | 62 end_event_type_, |
| 139 make_scoped_refptr(new FileIOCompleteParameters(bytes_copied))); | 63 make_scoped_refptr( |
| 64 new disk_cache::ReadWriteCompleteParameters(bytes_copied))); |
| 140 } | 65 } |
| 141 entry_->ReportIOTime(disk_cache::EntryImpl::kAsyncIO, start_); | 66 entry_->ReportIOTime(disk_cache::EntryImpl::kAsyncIO, start_); |
| 142 callback_->Run(bytes_copied); | 67 callback_->Run(bytes_copied); |
| 143 } | 68 } |
| 144 entry_->Release(); | 69 entry_->Release(); |
| 145 delete this; | 70 delete this; |
| 146 } | 71 } |
| 147 | 72 |
| 148 void SyncCallback::Discard() { | 73 void SyncCallback::Discard() { |
| 149 callback_ = NULL; | 74 callback_ = NULL; |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 return; | 304 return; |
| 380 | 305 |
| 381 SetPointerForInvalidEntry(backend_->GetCurrentEntryId()); | 306 SetPointerForInvalidEntry(backend_->GetCurrentEntryId()); |
| 382 backend_->InternalDoomEntry(this); | 307 backend_->InternalDoomEntry(this); |
| 383 } | 308 } |
| 384 | 309 |
| 385 int EntryImpl::ReadDataImpl(int index, int offset, net::IOBuffer* buf, | 310 int EntryImpl::ReadDataImpl(int index, int offset, net::IOBuffer* buf, |
| 386 int buf_len, CompletionCallback* callback) { | 311 int buf_len, CompletionCallback* callback) { |
| 387 if (net_log_.IsLoggingAllEvents()) { | 312 if (net_log_.IsLoggingAllEvents()) { |
| 388 net_log_.BeginEvent( | 313 net_log_.BeginEvent( |
| 389 net::NetLog::TYPE_DISK_CACHE_READ_DATA, | 314 net::NetLog::TYPE_ENTRY_READ_DATA, |
| 390 make_scoped_refptr( | 315 make_scoped_refptr( |
| 391 new ReadWriteDataParams(index, offset, buf_len, false))); | 316 new ReadWriteDataParameters(index, offset, buf_len, false))); |
| 392 } | 317 } |
| 393 | 318 |
| 394 int result = InternalReadData(index, offset, buf, buf_len, callback); | 319 int result = InternalReadData(index, offset, buf, buf_len, callback); |
| 395 | 320 |
| 396 if (result != net::ERR_IO_PENDING && net_log_.IsLoggingAllEvents()) { | 321 if (result != net::ERR_IO_PENDING && net_log_.IsLoggingAllEvents()) { |
| 397 net_log_.EndEvent( | 322 net_log_.EndEvent( |
| 398 net::NetLog::TYPE_DISK_CACHE_READ_DATA, | 323 net::NetLog::TYPE_ENTRY_READ_DATA, |
| 399 make_scoped_refptr(new FileIOCompleteParameters(result))); | 324 make_scoped_refptr(new ReadWriteCompleteParameters(result))); |
| 400 } | 325 } |
| 401 return result; | 326 return result; |
| 402 } | 327 } |
| 403 | 328 |
| 404 int EntryImpl::WriteDataImpl(int index, int offset, net::IOBuffer* buf, | 329 int EntryImpl::WriteDataImpl(int index, int offset, net::IOBuffer* buf, |
| 405 int buf_len, CompletionCallback* callback, | 330 int buf_len, CompletionCallback* callback, |
| 406 bool truncate) { | 331 bool truncate) { |
| 407 if (net_log_.IsLoggingAllEvents()) { | 332 if (net_log_.IsLoggingAllEvents()) { |
| 408 net_log_.BeginEvent( | 333 net_log_.BeginEvent( |
| 409 net::NetLog::TYPE_DISK_CACHE_WRITE_DATA, | 334 net::NetLog::TYPE_ENTRY_WRITE_DATA, |
| 410 make_scoped_refptr( | 335 make_scoped_refptr( |
| 411 new ReadWriteDataParams(index, offset, buf_len, truncate))); | 336 new ReadWriteDataParameters(index, offset, buf_len, truncate))); |
| 412 } | 337 } |
| 413 | 338 |
| 414 int result = InternalWriteData(index, offset, buf, buf_len, callback, | 339 int result = InternalWriteData(index, offset, buf, buf_len, callback, |
| 415 truncate); | 340 truncate); |
| 416 | 341 |
| 417 if (result != net::ERR_IO_PENDING && net_log_.IsLoggingAllEvents()) { | 342 if (result != net::ERR_IO_PENDING && net_log_.IsLoggingAllEvents()) { |
| 418 net_log_.EndEvent( | 343 net_log_.EndEvent( |
| 419 net::NetLog::TYPE_DISK_CACHE_WRITE_DATA, | 344 net::NetLog::TYPE_ENTRY_WRITE_DATA, |
| 420 make_scoped_refptr(new FileIOCompleteParameters(result))); | 345 make_scoped_refptr(new ReadWriteCompleteParameters(result))); |
| 421 } | 346 } |
| 422 return result; | 347 return result; |
| 423 } | 348 } |
| 424 | 349 |
| 425 int EntryImpl::ReadSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, | 350 int EntryImpl::ReadSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, |
| 426 CompletionCallback* callback) { | 351 CompletionCallback* callback) { |
| 427 DCHECK(node_.Data()->dirty || read_only_); | 352 DCHECK(node_.Data()->dirty || read_only_); |
| 428 int result = InitSparseData(); | 353 int result = InitSparseData(); |
| 429 if (net::OK != result) | 354 if (net::OK != result) |
| 430 return result; | 355 return result; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 bool EntryImpl::IsSameEntry(const std::string& key, uint32 hash) { | 449 bool EntryImpl::IsSameEntry(const std::string& key, uint32 hash) { |
| 525 if (entry_.Data()->hash != hash || | 450 if (entry_.Data()->hash != hash || |
| 526 static_cast<size_t>(entry_.Data()->key_len) != key.size()) | 451 static_cast<size_t>(entry_.Data()->key_len) != key.size()) |
| 527 return false; | 452 return false; |
| 528 | 453 |
| 529 std::string my_key = GetKey(); | 454 std::string my_key = GetKey(); |
| 530 return key.compare(my_key) ? false : true; | 455 return key.compare(my_key) ? false : true; |
| 531 } | 456 } |
| 532 | 457 |
| 533 void EntryImpl::InternalDoom() { | 458 void EntryImpl::InternalDoom() { |
| 534 net_log_.AddEvent(net::NetLog::TYPE_DISK_CACHE_DOOM, NULL); | 459 net_log_.AddEvent(net::NetLog::TYPE_ENTRY_DOOM, NULL); |
| 535 DCHECK(node_.HasData()); | 460 DCHECK(node_.HasData()); |
| 536 if (!node_.Data()->dirty) { | 461 if (!node_.Data()->dirty) { |
| 537 node_.Data()->dirty = backend_->GetCurrentEntryId(); | 462 node_.Data()->dirty = backend_->GetCurrentEntryId(); |
| 538 node_.Store(); | 463 node_.Store(); |
| 539 } | 464 } |
| 540 doomed_ = true; | 465 doomed_ = true; |
| 541 } | 466 } |
| 542 | 467 |
| 543 void EntryImpl::DeleteEntryData(bool everything) { | 468 void EntryImpl::DeleteEntryData(bool everything) { |
| 544 DCHECK(doomed_ || !everything); | 469 DCHECK(doomed_ || !everything); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 default: | 610 default: |
| 686 NOTREACHED(); | 611 NOTREACHED(); |
| 687 } | 612 } |
| 688 } | 613 } |
| 689 | 614 |
| 690 void EntryImpl::BeginLogging(net::NetLog* net_log, bool created) { | 615 void EntryImpl::BeginLogging(net::NetLog* net_log, bool created) { |
| 691 DCHECK(!net_log_.net_log()); | 616 DCHECK(!net_log_.net_log()); |
| 692 net_log_ = net::BoundNetLog::Make( | 617 net_log_ = net::BoundNetLog::Make( |
| 693 net_log, net::NetLog::SOURCE_DISK_CACHE_ENTRY); | 618 net_log, net::NetLog::SOURCE_DISK_CACHE_ENTRY); |
| 694 net_log_.BeginEvent( | 619 net_log_.BeginEvent( |
| 695 net::NetLog::TYPE_DISK_CACHE_ENTRY, | 620 net::NetLog::TYPE_DISK_CACHE_ENTRY_IMPL, |
| 696 make_scoped_refptr(new EntryCreationParameters(GetKey(), created))); | 621 make_scoped_refptr(new EntryCreationParameters(GetKey(), created))); |
| 697 } | 622 } |
| 698 | 623 |
| 699 const net::BoundNetLog& EntryImpl::net_log() const { | 624 const net::BoundNetLog& EntryImpl::net_log() const { |
| 700 return net_log_; | 625 return net_log_; |
| 701 } | 626 } |
| 702 | 627 |
| 703 void EntryImpl::Doom() { | 628 void EntryImpl::Doom() { |
| 704 backend_->background_queue()->DoomEntryImpl(this); | 629 backend_->background_queue()->DoomEntryImpl(this); |
| 705 } | 630 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 // maybe for a child entry, so it is important to do it before deleting this | 777 // maybe for a child entry, so it is important to do it before deleting this |
| 853 // entry. | 778 // entry. |
| 854 sparse_.reset(); | 779 sparse_.reset(); |
| 855 | 780 |
| 856 // Remove this entry from the list of open entries. | 781 // Remove this entry from the list of open entries. |
| 857 backend_->OnEntryDestroyBegin(entry_.address()); | 782 backend_->OnEntryDestroyBegin(entry_.address()); |
| 858 | 783 |
| 859 if (doomed_) { | 784 if (doomed_) { |
| 860 DeleteEntryData(true); | 785 DeleteEntryData(true); |
| 861 } else { | 786 } else { |
| 862 net_log_.AddEvent(net::NetLog::TYPE_DISK_CACHE_CLOSE, NULL); | 787 net_log_.AddEvent(net::NetLog::TYPE_ENTRY_CLOSE, NULL); |
| 863 bool ret = true; | 788 bool ret = true; |
| 864 for (int index = 0; index < kNumStreams; index++) { | 789 for (int index = 0; index < kNumStreams; index++) { |
| 865 if (user_buffers_[index].get()) { | 790 if (user_buffers_[index].get()) { |
| 866 if (!(ret = Flush(index, 0))) | 791 if (!(ret = Flush(index, 0))) |
| 867 LOG(ERROR) << "Failed to save user data"; | 792 LOG(ERROR) << "Failed to save user data"; |
| 868 } | 793 } |
| 869 if (unreported_size_[index]) { | 794 if (unreported_size_[index]) { |
| 870 backend_->ModifyStorageSize( | 795 backend_->ModifyStorageSize( |
| 871 entry_.Data()->data_size[index] - unreported_size_[index], | 796 entry_.Data()->data_size[index] - unreported_size_[index], |
| 872 entry_.Data()->data_size[index]); | 797 entry_.Data()->data_size[index]); |
| 873 } | 798 } |
| 874 } | 799 } |
| 875 | 800 |
| 876 if (!ret) { | 801 if (!ret) { |
| 877 // There was a failure writing the actual data. Mark the entry as dirty. | 802 // There was a failure writing the actual data. Mark the entry as dirty. |
| 878 int current_id = backend_->GetCurrentEntryId(); | 803 int current_id = backend_->GetCurrentEntryId(); |
| 879 node_.Data()->dirty = current_id == 1 ? -1 : current_id - 1; | 804 node_.Data()->dirty = current_id == 1 ? -1 : current_id - 1; |
| 880 node_.Store(); | 805 node_.Store(); |
| 881 } else if (node_.HasData() && !dirty_) { | 806 } else if (node_.HasData() && !dirty_) { |
| 882 node_.Data()->dirty = 0; | 807 node_.Data()->dirty = 0; |
| 883 node_.Store(); | 808 node_.Store(); |
| 884 } | 809 } |
| 885 } | 810 } |
| 886 | 811 |
| 887 Trace("~EntryImpl out 0x%p", reinterpret_cast<void*>(this)); | 812 Trace("~EntryImpl out 0x%p", reinterpret_cast<void*>(this)); |
| 888 net_log_.EndEvent(net::NetLog::TYPE_DISK_CACHE_ENTRY, NULL); | 813 net_log_.EndEvent(net::NetLog::TYPE_DISK_CACHE_ENTRY_IMPL, NULL); |
| 889 backend_->OnEntryDestroyEnd(); | 814 backend_->OnEntryDestroyEnd(); |
| 890 } | 815 } |
| 891 | 816 |
| 892 // ------------------------------------------------------------------------ | 817 // ------------------------------------------------------------------------ |
| 893 | 818 |
| 894 int EntryImpl::InternalReadData(int index, int offset, net::IOBuffer* buf, | 819 int EntryImpl::InternalReadData(int index, int offset, net::IOBuffer* buf, |
| 895 int buf_len, CompletionCallback* callback) { | 820 int buf_len, CompletionCallback* callback) { |
| 896 DCHECK(node_.Data()->dirty || read_only_); | 821 DCHECK(node_.Data()->dirty || read_only_); |
| 897 DVLOG(2) << "Read from " << index << " at " << offset << " : " << buf_len; | 822 DVLOG(2) << "Read from " << index << " at " << offset << " : " << buf_len; |
| 898 if (index < 0 || index >= kNumStreams) | 823 if (index < 0 || index >= kNumStreams) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 size_t file_offset = offset; | 862 size_t file_offset = offset; |
| 938 if (address.is_block_file()) { | 863 if (address.is_block_file()) { |
| 939 DCHECK_LE(offset + buf_len, kMaxBlockSize); | 864 DCHECK_LE(offset + buf_len, kMaxBlockSize); |
| 940 file_offset += address.start_block() * address.BlockSize() + | 865 file_offset += address.start_block() * address.BlockSize() + |
| 941 kBlockHeaderSize; | 866 kBlockHeaderSize; |
| 942 } | 867 } |
| 943 | 868 |
| 944 SyncCallback* io_callback = NULL; | 869 SyncCallback* io_callback = NULL; |
| 945 if (callback) { | 870 if (callback) { |
| 946 io_callback = new SyncCallback(this, buf, callback, | 871 io_callback = new SyncCallback(this, buf, callback, |
| 947 net::NetLog::TYPE_DISK_CACHE_READ_DATA); | 872 net::NetLog::TYPE_ENTRY_READ_DATA); |
| 948 } | 873 } |
| 949 | 874 |
| 950 bool completed; | 875 bool completed; |
| 951 if (!file->Read(buf->data(), buf_len, file_offset, io_callback, &completed)) { | 876 if (!file->Read(buf->data(), buf_len, file_offset, io_callback, &completed)) { |
| 952 if (io_callback) | 877 if (io_callback) |
| 953 io_callback->Discard(); | 878 io_callback->Discard(); |
| 954 return net::ERR_FAILED; | 879 return net::ERR_FAILED; |
| 955 } | 880 } |
| 956 | 881 |
| 957 if (io_callback && completed) | 882 if (io_callback && completed) |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 if (!file->SetLength(offset + buf_len)) | 956 if (!file->SetLength(offset + buf_len)) |
| 1032 return net::ERR_FAILED; | 957 return net::ERR_FAILED; |
| 1033 } | 958 } |
| 1034 | 959 |
| 1035 if (!buf_len) | 960 if (!buf_len) |
| 1036 return 0; | 961 return 0; |
| 1037 | 962 |
| 1038 SyncCallback* io_callback = NULL; | 963 SyncCallback* io_callback = NULL; |
| 1039 if (callback) { | 964 if (callback) { |
| 1040 io_callback = new SyncCallback(this, buf, callback, | 965 io_callback = new SyncCallback(this, buf, callback, |
| 1041 net::NetLog::TYPE_DISK_CACHE_WRITE_DATA); | 966 net::NetLog::TYPE_ENTRY_WRITE_DATA); |
| 1042 } | 967 } |
| 1043 | 968 |
| 1044 bool completed; | 969 bool completed; |
| 1045 if (!file->Write(buf->data(), buf_len, file_offset, io_callback, | 970 if (!file->Write(buf->data(), buf_len, file_offset, io_callback, |
| 1046 &completed)) { | 971 &completed)) { |
| 1047 if (io_callback) | 972 if (io_callback) |
| 1048 io_callback->Discard(); | 973 io_callback->Discard(); |
| 1049 return net::ERR_FAILED; | 974 return net::ERR_FAILED; |
| 1050 } | 975 } |
| 1051 | 976 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1432 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), | 1357 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), |
| 1433 entry_.address().value(), node_.address().value()); | 1358 entry_.address().value(), node_.address().value()); |
| 1434 | 1359 |
| 1435 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], | 1360 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], |
| 1436 entry_.Data()->data_addr[1], entry_.Data()->long_key); | 1361 entry_.Data()->data_addr[1], entry_.Data()->long_key); |
| 1437 | 1362 |
| 1438 Trace(" doomed: %d 0x%x", doomed_, dirty); | 1363 Trace(" doomed: %d 0x%x", doomed_, dirty); |
| 1439 } | 1364 } |
| 1440 | 1365 |
| 1441 } // namespace disk_cache | 1366 } // namespace disk_cache |
| OLD | NEW |