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

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

Issue 12224017: Create a new disk_cache type, SHADER_CACHE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 bool previous_crash = (data_->header.crash != 0); 468 bool previous_crash = (data_->header.crash != 0);
469 data_->header.crash = 1; 469 data_->header.crash = 1;
470 470
471 if (!block_files_.Init(create_files)) 471 if (!block_files_.Init(create_files))
472 return net::ERR_FAILED; 472 return net::ERR_FAILED;
473 473
474 // We want to minimize the changes to cache for an AppCache. 474 // We want to minimize the changes to cache for an AppCache.
475 if (cache_type() == net::APP_CACHE) { 475 if (cache_type() == net::APP_CACHE) {
476 DCHECK(!new_eviction_); 476 DCHECK(!new_eviction_);
477 read_only_ = true; 477 read_only_ = true;
478 } else if (cache_type() == net::SHADER_CACHE) {
479 DCHECK(!new_eviction_);
478 } 480 }
479 481
480 eviction_.Init(this); 482 eviction_.Init(this);
481 483
482 // stats_ and rankings_ may end up calling back to us so we better be enabled. 484 // stats_ and rankings_ may end up calling back to us so we better be enabled.
483 disabled_ = false; 485 disabled_ = false;
484 if (!stats_.Init(this, &data_->header.stats)) 486 if (!stats_.Init(this, &data_->header.stats))
485 return net::ERR_FAILED; 487 return net::ERR_FAILED;
486 488
487 disabled_ = !rankings_.Init(this, new_eviction_); 489 disabled_ = !rankings_.Init(this, new_eviction_);
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 914
913 void BackendImpl::DeleteBlock(Addr block_address, bool deep) { 915 void BackendImpl::DeleteBlock(Addr block_address, bool deep) {
914 block_files_.DeleteBlock(block_address, deep); 916 block_files_.DeleteBlock(block_address, deep);
915 } 917 }
916 918
917 LruData* BackendImpl::GetLruData() { 919 LruData* BackendImpl::GetLruData() {
918 return &data_->header.lru; 920 return &data_->header.lru;
919 } 921 }
920 922
921 void BackendImpl::UpdateRank(EntryImpl* entry, bool modified) { 923 void BackendImpl::UpdateRank(EntryImpl* entry, bool modified) {
922 if (!read_only_) { 924 if (read_only_ || (!modified && cache_type() == net::SHADER_CACHE))
923 eviction_.UpdateRank(entry, modified); 925 return;
924 } 926 eviction_.UpdateRank(entry, modified);
925 } 927 }
926 928
927 void BackendImpl::RecoveredEntry(CacheRankingsBlock* rankings) { 929 void BackendImpl::RecoveredEntry(CacheRankingsBlock* rankings) {
928 Addr address(rankings->Data()->contents); 930 Addr address(rankings->Data()->contents);
929 EntryImpl* cache_entry = NULL; 931 EntryImpl* cache_entry = NULL;
930 if (NewEntry(address, &cache_entry)) { 932 if (NewEntry(address, &cache_entry)) {
931 STRESS_NOTREACHED(); 933 STRESS_NOTREACHED();
932 return; 934 return;
933 } 935 }
934 936
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2236 if (total_memory > kMaxBuffersSize || total_memory <= 0) 2238 if (total_memory > kMaxBuffersSize || total_memory <= 0)
2237 total_memory = kMaxBuffersSize; 2239 total_memory = kMaxBuffersSize;
2238 2240
2239 done = true; 2241 done = true;
2240 } 2242 }
2241 2243
2242 return static_cast<int>(total_memory); 2244 return static_cast<int>(total_memory);
2243 } 2245 }
2244 2246
2245 } // namespace disk_cache 2247 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698