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

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

Issue 1355063004: Template methods on Timer classes instead of the classes themselves. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: timer: fixcaller Created 5 years, 2 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
« no previous file with comments | « net/disk_cache/blockfile/backend_impl.h ('k') | net/disk_cache/blockfile/backend_impl_v3.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/blockfile/backend_impl.h" 5 #include "net/disk_cache/blockfile/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/files/file.h" 9 #include "base/files/file.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 ReportError(ERR_PREVIOUS_CRASH); 287 ReportError(ERR_PREVIOUS_CRASH);
288 } else if (!restarted_) { 288 } else if (!restarted_) {
289 ReportError(ERR_NO_ERROR); 289 ReportError(ERR_NO_ERROR);
290 } 290 }
291 291
292 FlushIndex(); 292 FlushIndex();
293 293
294 if (!disabled_ && should_create_timer) { 294 if (!disabled_ && should_create_timer) {
295 // Create a recurrent timer of 30 secs. 295 // Create a recurrent timer of 30 secs.
296 int timer_delay = unit_test_ ? 1000 : 30000; 296 int timer_delay = unit_test_ ? 1000 : 30000;
297 timer_.reset(new base::RepeatingTimer<BackendImpl>()); 297 timer_.reset(new base::RepeatingTimer());
298 timer_->Start(FROM_HERE, TimeDelta::FromMilliseconds(timer_delay), this, 298 timer_->Start(FROM_HERE, TimeDelta::FromMilliseconds(timer_delay), this,
299 &BackendImpl::OnStatsTimer); 299 &BackendImpl::OnStatsTimer);
300 } 300 }
301 301
302 return disabled_ ? net::ERR_FAILED : net::OK; 302 return disabled_ ? net::ERR_FAILED : net::OK;
303 } 303 }
304 304
305 void BackendImpl::CleanupCache() { 305 void BackendImpl::CleanupCache() {
306 Trace("Backend Cleanup"); 306 Trace("Backend Cleanup");
307 eviction_.Stop(); 307 eviction_.Stop();
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 void BackendImpl::TrimForTest(bool empty) { 1151 void BackendImpl::TrimForTest(bool empty) {
1152 eviction_.SetTestMode(); 1152 eviction_.SetTestMode();
1153 eviction_.TrimCache(empty); 1153 eviction_.TrimCache(empty);
1154 } 1154 }
1155 1155
1156 void BackendImpl::TrimDeletedListForTest(bool empty) { 1156 void BackendImpl::TrimDeletedListForTest(bool empty) {
1157 eviction_.SetTestMode(); 1157 eviction_.SetTestMode();
1158 eviction_.TrimDeletedList(empty); 1158 eviction_.TrimDeletedList(empty);
1159 } 1159 }
1160 1160
1161 base::RepeatingTimer<BackendImpl>* BackendImpl::GetTimerForTest() { 1161 base::RepeatingTimer* BackendImpl::GetTimerForTest() {
1162 return timer_.get(); 1162 return timer_.get();
1163 } 1163 }
1164 1164
1165 int BackendImpl::SelfCheck() { 1165 int BackendImpl::SelfCheck() {
1166 if (!init_) { 1166 if (!init_) {
1167 LOG(ERROR) << "Init failed"; 1167 LOG(ERROR) << "Init failed";
1168 return ERR_INIT_FAILED; 1168 return ERR_INIT_FAILED;
1169 } 1169 }
1170 1170
1171 int num_entries = rankings_.SelfCheck(); 1171 int num_entries = rankings_.SelfCheck();
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 if (total_memory > kMaxBuffersSize || total_memory <= 0) 2091 if (total_memory > kMaxBuffersSize || total_memory <= 0)
2092 total_memory = kMaxBuffersSize; 2092 total_memory = kMaxBuffersSize;
2093 2093
2094 done = true; 2094 done = true;
2095 } 2095 }
2096 2096
2097 return static_cast<int>(total_memory); 2097 return static_cast<int>(total_memory);
2098 } 2098 }
2099 2099
2100 } // namespace disk_cache 2100 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/backend_impl.h ('k') | net/disk_cache/blockfile/backend_impl_v3.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698