| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |