| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 "chrome/browser/browsing_data/cache_counter.h" | 5 #include "chrome/browser/browsing_data/cache_counter.h" |
| 6 #include "chrome/common/pref_names.h" | 6 #include "chrome/common/pref_names.h" |
| 7 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" | 7 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" |
| 8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
| 9 | 9 |
| 10 CacheCounter::CacheCounter() : pref_name_(prefs::kDeleteCache), | 10 CacheCounter::CacheCounter() : pref_name_(prefs::kDeleteCache), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 pending_ = true; | 33 pending_ = true; |
| 34 } | 34 } |
| 35 | 35 |
| 36 void CacheCounter::OnCacheSizeCalculated(int64 result_bytes) { | 36 void CacheCounter::OnCacheSizeCalculated(int64 result_bytes) { |
| 37 pending_ = false; | 37 pending_ = false; |
| 38 | 38 |
| 39 // A value less than 0 means a net error code. | 39 // A value less than 0 means a net error code. |
| 40 if (result_bytes < 0) | 40 if (result_bytes < 0) |
| 41 return; | 41 return; |
| 42 | 42 |
| 43 // The cache size on all three backends (blockfile, simple and memory) is | 43 ReportResult(result_bytes); |
| 44 // limited to int32. We are adding together results from several cache | |
| 45 // backends, so the result should fit into 32+epsilon bits. Thus, | |
| 46 // |result_bytes| / 1024^2 should fit into an int. | |
| 47 static const int kBToMb = 1024 * 1024; | |
| 48 int result_mb = result_bytes / kBToMb; | |
| 49 if (result_bytes % kBToMb) | |
| 50 ++result_mb; | |
| 51 ReportResult(result_mb); | |
| 52 } | 44 } |
| 53 | 45 |
| 54 bool CacheCounter::Pending() { | 46 bool CacheCounter::Pending() { |
| 55 return pending_; | 47 return pending_; |
| 56 } | 48 } |
| OLD | NEW |