| 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 <limits> | 7 #include <limits> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/files/file.h" | 12 #include "base/files/file.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 15 #include "base/hash.h" | 15 #include "base/hash.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/metrics/field_trial.h" | 17 #include "base/metrics/field_trial.h" |
| 18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
| 19 #include "base/rand_util.h" | 19 #include "base/rand_util.h" |
| 20 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 24 #include "base/sys_info.h" | 24 #include "base/sys_info.h" |
| 25 #include "base/threading/thread_restrictions.h" | 25 #include "base/threading/thread_restrictions.h" |
| 26 #include "base/threading/thread_task_runner_handle.h" | 26 #include "base/threading/thread_task_runner_handle.h" |
| 27 #include "base/time/time.h" | 27 #include "base/time/time.h" |
| 28 #include "base/timer/timer.h" | 28 #include "base/timer/timer.h" |
| 29 #include "base/trace_event/process_memory_dump.h" |
| 29 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
| 30 #include "net/disk_cache/blockfile/disk_format.h" | 31 #include "net/disk_cache/blockfile/disk_format.h" |
| 31 #include "net/disk_cache/blockfile/entry_impl.h" | 32 #include "net/disk_cache/blockfile/entry_impl.h" |
| 32 #include "net/disk_cache/blockfile/errors.h" | 33 #include "net/disk_cache/blockfile/errors.h" |
| 33 #include "net/disk_cache/blockfile/experiments.h" | 34 #include "net/disk_cache/blockfile/experiments.h" |
| 34 #include "net/disk_cache/blockfile/file.h" | 35 #include "net/disk_cache/blockfile/file.h" |
| 35 #include "net/disk_cache/blockfile/histogram_macros.h" | 36 #include "net/disk_cache/blockfile/histogram_macros.h" |
| 36 #include "net/disk_cache/blockfile/webfonts_histogram.h" | 37 #include "net/disk_cache/blockfile/webfonts_histogram.h" |
| 37 #include "net/disk_cache/cache_util.h" | 38 #include "net/disk_cache/cache_util.h" |
| 38 | 39 |
| (...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 item.second = "Blockfile Cache"; | 1314 item.second = "Blockfile Cache"; |
| 1314 stats->push_back(item); | 1315 stats->push_back(item); |
| 1315 | 1316 |
| 1316 stats_.GetItems(stats); | 1317 stats_.GetItems(stats); |
| 1317 } | 1318 } |
| 1318 | 1319 |
| 1319 void BackendImpl::OnExternalCacheHit(const std::string& key) { | 1320 void BackendImpl::OnExternalCacheHit(const std::string& key) { |
| 1320 background_queue_.OnExternalCacheHit(key); | 1321 background_queue_.OnExternalCacheHit(key); |
| 1321 } | 1322 } |
| 1322 | 1323 |
| 1323 size_t BackendImpl::EstimateMemoryUsage() const { | 1324 size_t BackendImpl::DumpMemoryStats( |
| 1325 base::trace_event::ProcessMemoryDump* pmd, |
| 1326 const std::string& parent_absolute_name) const { |
| 1324 // TODO(xunjieli): Implement this. crbug.com/669108. | 1327 // TODO(xunjieli): Implement this. crbug.com/669108. |
| 1325 return 0; | 1328 return 0u; |
| 1326 } | 1329 } |
| 1327 | 1330 |
| 1328 // ------------------------------------------------------------------------ | 1331 // ------------------------------------------------------------------------ |
| 1329 | 1332 |
| 1330 // We just created a new file so we're going to write the header and set the | 1333 // We just created a new file so we're going to write the header and set the |
| 1331 // file length to include the hash table (zero filled). | 1334 // file length to include the hash table (zero filled). |
| 1332 bool BackendImpl::CreateBackingStore(disk_cache::File* file) { | 1335 bool BackendImpl::CreateBackingStore(disk_cache::File* file) { |
| 1333 AdjustMaxCacheSize(0); | 1336 AdjustMaxCacheSize(0); |
| 1334 | 1337 |
| 1335 IndexHeader header; | 1338 IndexHeader header; |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2091 if (total_memory > kMaxBuffersSize || total_memory <= 0) | 2094 if (total_memory > kMaxBuffersSize || total_memory <= 0) |
| 2092 total_memory = kMaxBuffersSize; | 2095 total_memory = kMaxBuffersSize; |
| 2093 | 2096 |
| 2094 done = true; | 2097 done = true; |
| 2095 } | 2098 } |
| 2096 | 2099 |
| 2097 return static_cast<int>(total_memory); | 2100 return static_cast<int>(total_memory); |
| 2098 } | 2101 } |
| 2099 | 2102 |
| 2100 } // namespace disk_cache | 2103 } // namespace disk_cache |
| OLD | NEW |