Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: net/disk_cache/backend_impl.cc

Issue 7461106: Inform disk cache of WebKit memory cache hits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implement in backend Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 UpdateRank(cache_entry, false);
691 }
rvargas (doing something else) 2011/07/28 22:27:01 Leaking the entry. We should also check that this
692 }
693
685 EntryImpl* BackendImpl::OpenEntryImpl(const std::string& key) { 694 EntryImpl* BackendImpl::OpenEntryImpl(const std::string& key) {
686 if (disabled_) 695 if (disabled_)
687 return NULL; 696 return NULL;
688 697
689 TimeTicks start = TimeTicks::Now(); 698 TimeTicks start = TimeTicks::Now();
690 uint32 hash = Hash(key); 699 uint32 hash = Hash(key);
691 Trace("Open hash 0x%x", hash); 700 Trace("Open hash 0x%x", hash);
692 701
693 bool error; 702 bool error;
694 EntryImpl* cache_entry = MatchEntry(key, hash, false, Addr(), &error); 703 EntryImpl* cache_entry = MatchEntry(key, hash, false, Addr(), &error);
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 item.second = base::StringPrintf("%d", max_size_); 1358 item.second = base::StringPrintf("%d", max_size_);
1350 stats->push_back(item); 1359 stats->push_back(item);
1351 1360
1352 item.first = "Current size"; 1361 item.first = "Current size";
1353 item.second = base::StringPrintf("%d", data_->header.num_bytes); 1362 item.second = base::StringPrintf("%d", data_->header.num_bytes);
1354 stats->push_back(item); 1363 stats->push_back(item);
1355 1364
1356 stats_.GetItems(stats); 1365 stats_.GetItems(stats);
1357 } 1366 }
1358 1367
1368 void BackendImpl::OnExternalCacheHit(const std::string& key) {
1369 background_queue_.OnExternalCacheHit(key);
1370 }
1371
1359 // ------------------------------------------------------------------------ 1372 // ------------------------------------------------------------------------
1360 1373
1361 // We just created a new file so we're going to write the header and set the 1374 // 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). 1375 // file length to include the hash table (zero filled).
1363 bool BackendImpl::CreateBackingStore(disk_cache::File* file) { 1376 bool BackendImpl::CreateBackingStore(disk_cache::File* file) {
1364 AdjustMaxCacheSize(0); 1377 AdjustMaxCacheSize(0);
1365 1378
1366 IndexHeader header; 1379 IndexHeader header;
1367 header.table_len = DesiredIndexTableLen(max_size_); 1380 header.table_len = DesiredIndexTableLen(max_size_);
1368 1381
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
2096 if (total_memory > kMaxBuffersSize || total_memory <= 0) 2109 if (total_memory > kMaxBuffersSize || total_memory <= 0)
2097 total_memory = kMaxBuffersSize; 2110 total_memory = kMaxBuffersSize;
2098 2111
2099 done = true; 2112 done = true;
2100 } 2113 }
2101 2114
2102 return static_cast<int>(total_memory); 2115 return static_cast<int>(total_memory);
2103 } 2116 }
2104 2117
2105 } // namespace disk_cache 2118 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698