| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/backend_impl.h" | 5 #include "net/disk_cache/backend_impl.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 int BackendImpl::SyncOpenPrevEntry(void** iter, Entry** prev_entry) { | 675 int BackendImpl::SyncOpenPrevEntry(void** iter, Entry** prev_entry) { |
| 676 *prev_entry = OpenPrevEntryImpl(iter); | 676 *prev_entry = OpenPrevEntryImpl(iter); |
| 677 return (*prev_entry) ? net::OK : net::ERR_FAILED; | 677 return (*prev_entry) ? net::OK : net::ERR_FAILED; |
| 678 } | 678 } |
| 679 | 679 |
| 680 void BackendImpl::SyncEndEnumeration(void* iter) { | 680 void BackendImpl::SyncEndEnumeration(void* iter) { |
| 681 scoped_ptr<Rankings::Iterator> iterator( | 681 scoped_ptr<Rankings::Iterator> iterator( |
| 682 reinterpret_cast<Rankings::Iterator*>(iter)); | 682 reinterpret_cast<Rankings::Iterator*>(iter)); |
| 683 } | 683 } |
| 684 | 684 |
| 685 void BackendImpl::SyncOnExternalCacheHit(const std::string& key) { |
| 686 uint32 hash = Hash(key); |
| 687 bool error; |
| 688 EntryImpl* cache_entry = MatchEntry(key, hash, false, Addr(), &error); |
| 689 if (cache_entry) { |
| 690 if (ENTRY_NORMAL == cache_entry->entry()->Data()->state) { |
| 691 UpdateRank(cache_entry, false); |
| 692 } |
| 693 cache_entry->Release(); |
| 694 } |
| 695 } |
| 696 |
| 685 EntryImpl* BackendImpl::OpenEntryImpl(const std::string& key) { | 697 EntryImpl* BackendImpl::OpenEntryImpl(const std::string& key) { |
| 686 if (disabled_) | 698 if (disabled_) |
| 687 return NULL; | 699 return NULL; |
| 688 | 700 |
| 689 TimeTicks start = TimeTicks::Now(); | 701 TimeTicks start = TimeTicks::Now(); |
| 690 uint32 hash = Hash(key); | 702 uint32 hash = Hash(key); |
| 691 Trace("Open hash 0x%x", hash); | 703 Trace("Open hash 0x%x", hash); |
| 692 | 704 |
| 693 bool error; | 705 bool error; |
| 694 EntryImpl* cache_entry = MatchEntry(key, hash, false, Addr(), &error); | 706 EntryImpl* cache_entry = MatchEntry(key, hash, false, Addr(), &error); |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 item.second = base::StringPrintf("%d", max_size_); | 1361 item.second = base::StringPrintf("%d", max_size_); |
| 1350 stats->push_back(item); | 1362 stats->push_back(item); |
| 1351 | 1363 |
| 1352 item.first = "Current size"; | 1364 item.first = "Current size"; |
| 1353 item.second = base::StringPrintf("%d", data_->header.num_bytes); | 1365 item.second = base::StringPrintf("%d", data_->header.num_bytes); |
| 1354 stats->push_back(item); | 1366 stats->push_back(item); |
| 1355 | 1367 |
| 1356 stats_.GetItems(stats); | 1368 stats_.GetItems(stats); |
| 1357 } | 1369 } |
| 1358 | 1370 |
| 1371 void BackendImpl::OnExternalCacheHit(const std::string& key) { |
| 1372 background_queue_.OnExternalCacheHit(key); |
| 1373 } |
| 1374 |
| 1359 // ------------------------------------------------------------------------ | 1375 // ------------------------------------------------------------------------ |
| 1360 | 1376 |
| 1361 // We just created a new file so we're going to write the header and set the | 1377 // We just created a new file so we're going to write the header and set the |
| 1362 // file length to include the hash table (zero filled). | 1378 // file length to include the hash table (zero filled). |
| 1363 bool BackendImpl::CreateBackingStore(disk_cache::File* file) { | 1379 bool BackendImpl::CreateBackingStore(disk_cache::File* file) { |
| 1364 AdjustMaxCacheSize(0); | 1380 AdjustMaxCacheSize(0); |
| 1365 | 1381 |
| 1366 IndexHeader header; | 1382 IndexHeader header; |
| 1367 header.table_len = DesiredIndexTableLen(max_size_); | 1383 header.table_len = DesiredIndexTableLen(max_size_); |
| 1368 | 1384 |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2096 if (total_memory > kMaxBuffersSize || total_memory <= 0) | 2112 if (total_memory > kMaxBuffersSize || total_memory <= 0) |
| 2097 total_memory = kMaxBuffersSize; | 2113 total_memory = kMaxBuffersSize; |
| 2098 | 2114 |
| 2099 done = true; | 2115 done = true; |
| 2100 } | 2116 } |
| 2101 | 2117 |
| 2102 return static_cast<int>(total_memory); | 2118 return static_cast<int>(total_memory); |
| 2103 } | 2119 } |
| 2104 | 2120 |
| 2105 } // namespace disk_cache | 2121 } // namespace disk_cache |
| OLD | NEW |