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/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_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 return false; | 1387 return false; |
1388 if (cache_type_ == net::DISK_CACHE && ShouldReportAgain()) | 1388 if (cache_type_ == net::DISK_CACHE && ShouldReportAgain()) |
1389 stats_.InitSizeHistogram(); | 1389 stats_.InitSizeHistogram(); |
1390 return true; | 1390 return true; |
1391 } | 1391 } |
1392 | 1392 |
1393 void BackendImpl::StoreStats() { | 1393 void BackendImpl::StoreStats() { |
1394 int size = stats_.StorageSize(); | 1394 int size = stats_.StorageSize(); |
1395 scoped_ptr<char[]> data(new char[size]); | 1395 scoped_ptr<char[]> data(new char[size]); |
1396 Addr address; | 1396 Addr address; |
1397 bool rv = stats_.SerializeStats(data.get(), size, &address); | 1397 size = stats_.SerializeStats(data.get(), size, &address); |
1398 DCHECK(rv); | 1398 DCHECK(size); |
1399 if (!address.is_initialized()) | 1399 if (!address.is_initialized()) |
1400 return; | 1400 return; |
1401 | 1401 |
1402 MappedFile* file = File(address); | 1402 MappedFile* file = File(address); |
1403 if (!file) | 1403 if (!file) |
1404 return; | 1404 return; |
1405 | 1405 |
1406 size_t offset = address.start_block() * address.BlockSize() + | 1406 size_t offset = address.start_block() * address.BlockSize() + |
1407 kBlockHeaderSize; | 1407 kBlockHeaderSize; |
1408 rv = file->Write(data.get(), size, offset); // ignore result. | 1408 file->Write(data.get(), size, offset); // ignore result. |
1409 } | 1409 } |
1410 | 1410 |
1411 void BackendImpl::RestartCache(bool failure) { | 1411 void BackendImpl::RestartCache(bool failure) { |
1412 int64 errors = stats_.GetCounter(Stats::FATAL_ERROR); | 1412 int64 errors = stats_.GetCounter(Stats::FATAL_ERROR); |
1413 int64 full_dooms = stats_.GetCounter(Stats::DOOM_CACHE); | 1413 int64 full_dooms = stats_.GetCounter(Stats::DOOM_CACHE); |
1414 int64 partial_dooms = stats_.GetCounter(Stats::DOOM_RECENT); | 1414 int64 partial_dooms = stats_.GetCounter(Stats::DOOM_RECENT); |
1415 int64 ga_evictions = stats_.GetCounter(Stats::GAJS_EVICTED); | 1415 int64 ga_evictions = stats_.GetCounter(Stats::GAJS_EVICTED); |
1416 int64 last_report = stats_.GetCounter(Stats::LAST_REPORT); | 1416 int64 last_report = stats_.GetCounter(Stats::LAST_REPORT); |
1417 | 1417 |
1418 PrepareForRestart(); | 1418 PrepareForRestart(); |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2110 if (total_memory > kMaxBuffersSize || total_memory <= 0) | 2110 if (total_memory > kMaxBuffersSize || total_memory <= 0) |
2111 total_memory = kMaxBuffersSize; | 2111 total_memory = kMaxBuffersSize; |
2112 | 2112 |
2113 done = true; | 2113 done = true; |
2114 } | 2114 } |
2115 | 2115 |
2116 return static_cast<int>(total_memory); | 2116 return static_cast<int>(total_memory); |
2117 } | 2117 } |
2118 | 2118 |
2119 } // namespace disk_cache | 2119 } // namespace disk_cache |
OLD | NEW |