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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_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: 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/browsing_data_counter.h" 5 #include "chrome/browser/browsing_data/browsing_data_counter.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/common/pref_names.h" 9 #include "chrome/common/pref_names.h"
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 static_cast<BrowsingDataRemover::TimePeriod>(*period_)); 46 static_cast<BrowsingDataRemover::TimePeriod>(*period_));
47 } 47 }
48 48
49 void BrowsingDataCounter::Restart() { 49 void BrowsingDataCounter::Restart() {
50 DCHECK(initialized_); 50 DCHECK(initialized_);
51 51
52 // If this data type was unchecked for deletion, we do not need to count it. 52 // If this data type was unchecked for deletion, we do not need to count it.
53 if (!profile_->GetPrefs()->GetBoolean(GetPrefName())) 53 if (!profile_->GetPrefs()->GetBoolean(GetPrefName()))
54 return; 54 return;
55 55
56 callback_.Run(false, 0u); 56 callback_.Run(make_scoped_ptr(new PendingResult(this)));
57 57
58 Count(); 58 Count();
59 } 59 }
60 60
61 void BrowsingDataCounter::ReportResult(ResultInt value) { 61 void BrowsingDataCounter::ReportResult(ResultInt value) {
62 DCHECK(initialized_); 62 DCHECK(initialized_);
63 callback_.Run(true, value); 63 callback_.Run(make_scoped_ptr(new FinishedResult(this, value)));
64 } 64 }
65
66 void BrowsingDataCounter::ReportResult(scoped_ptr<Result> result) {
67 DCHECK(initialized_);
68 callback_.Run(result.Pass());
69 }
70
71 // BrowsingDataCounter::Result -------------------------------------------------
72
73 BrowsingDataCounter::Result::Result(
74 const BrowsingDataCounter* source,
75 bool finished,
76 ResultInt value)
77 : source_(source),
78 finished_(finished),
79 value_(value) {
80 }
81
82 BrowsingDataCounter::Result::~Result() {
83 }
84
85 // BrowsingDataCounter::FinishedResult -----------------------------------------
86
87 BrowsingDataCounter::FinishedResult::FinishedResult(
88 const BrowsingDataCounter* source, ResultInt value)
89 : Result(source, true, value) {
90 }
91
92 BrowsingDataCounter::FinishedResult::~FinishedResult() {
93 }
94
95 // BrowsingDataCounter::PendingResult ------------------------------------------
96
97 BrowsingDataCounter::PendingResult::PendingResult(
98 const BrowsingDataCounter* source)
99 : Result(source, false, 0) {
100 }
101
102 BrowsingDataCounter::PendingResult::~PendingResult() {
103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698