OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/histogram.h" | 7 #include "base/histogram.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 void EntryImpl::DeleteData(Addr address, int index) { | 650 void EntryImpl::DeleteData(Addr address, int index) { |
651 if (!address.is_initialized()) | 651 if (!address.is_initialized()) |
652 return; | 652 return; |
653 if (address.is_separate_file()) { | 653 if (address.is_separate_file()) { |
654 if (files_[index]) | 654 if (files_[index]) |
655 files_[index] = NULL; // Releases the object. | 655 files_[index] = NULL; // Releases the object. |
656 | 656 |
657 int failure = DeleteCacheFile(backend_->GetFileName(address)) ? 0 : 1; | 657 int failure = DeleteCacheFile(backend_->GetFileName(address)) ? 0 : 1; |
658 CACHE_UMA(COUNTS, "DeleteFailed", 0, failure); | 658 CACHE_UMA(COUNTS, "DeleteFailed", 0, failure); |
659 if (failure) | 659 if (failure) |
660 LOG(ERROR) << "Failed to delete " << backend_->GetFileName(address) << | 660 LOG(ERROR) << "Failed to delete " << |
661 " from the cache."; | 661 backend_->GetFileName(address).value() << " from the cache."; |
662 } else { | 662 } else { |
663 backend_->DeleteBlock(address, true); | 663 backend_->DeleteBlock(address, true); |
664 } | 664 } |
665 } | 665 } |
666 | 666 |
667 void EntryImpl::UpdateRank(bool modified) { | 667 void EntryImpl::UpdateRank(bool modified) { |
668 if (!doomed_) { | 668 if (!doomed_) { |
669 // Everything is handled by the backend. | 669 // Everything is handled by the backend. |
670 backend_->UpdateRank(this, true); | 670 backend_->UpdateRank(this, true); |
671 return; | 671 return; |
(...skipping 13 matching lines...) Expand all Loading... |
685 else | 685 else |
686 file = backend_->File(address); | 686 file = backend_->File(address); |
687 return file; | 687 return file; |
688 } | 688 } |
689 | 689 |
690 File* EntryImpl::GetExternalFile(Addr address, int index) { | 690 File* EntryImpl::GetExternalFile(Addr address, int index) { |
691 DCHECK(index >= 0 && index <= kKeyFileIndex); | 691 DCHECK(index >= 0 && index <= kKeyFileIndex); |
692 if (!files_[index].get()) { | 692 if (!files_[index].get()) { |
693 // For a key file, use mixed mode IO. | 693 // For a key file, use mixed mode IO. |
694 scoped_refptr<File> file(new File(kKeyFileIndex == index)); | 694 scoped_refptr<File> file(new File(kKeyFileIndex == index)); |
695 if (file->Init(backend_->GetFileName(address))) | 695 if (file->Init(backend_->GetFileName(address).ToWStringHack())) |
696 files_[index].swap(file); | 696 files_[index].swap(file); |
697 } | 697 } |
698 return files_[index].get(); | 698 return files_[index].get(); |
699 } | 699 } |
700 | 700 |
701 bool EntryImpl::PrepareTarget(int index, int offset, int buf_len, | 701 bool EntryImpl::PrepareTarget(int index, int offset, int buf_len, |
702 bool truncate) { | 702 bool truncate) { |
703 Addr address(entry_.Data()->data_addr[index]); | 703 Addr address(entry_.Data()->data_addr[index]); |
704 | 704 |
705 if (address.is_initialized() || user_buffers_[index].get()) | 705 if (address.is_initialized() || user_buffers_[index].get()) |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), | 918 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), |
919 entry_.address().value(), node_.address().value()); | 919 entry_.address().value(), node_.address().value()); |
920 | 920 |
921 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], | 921 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], |
922 entry_.Data()->data_addr[1], entry_.Data()->long_key); | 922 entry_.Data()->data_addr[1], entry_.Data()->long_key); |
923 | 923 |
924 Trace(" doomed: %d 0x%x", doomed_, dirty); | 924 Trace(" doomed: %d 0x%x", doomed_, dirty); |
925 } | 925 } |
926 | 926 |
927 } // namespace disk_cache | 927 } // namespace disk_cache |
OLD | NEW |