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

Side by Side Diff: chrome/browser/browsing_data/cache_counter.cc

Issue 1420013004: Polish the result communication and display of the browsing data counters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits. Created 5 years, 1 month 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
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_counter.cc ('k') | chrome/browser/browsing_data/cache_counter_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698