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

Unified 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: Addressed comments. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/browsing_data/browsing_data_counter.cc
diff --git a/chrome/browser/browsing_data/browsing_data_counter.cc b/chrome/browser/browsing_data/browsing_data_counter.cc
index a716c32c90fc4eb61d0e0a2462538f7beedcb2a7..ac1fa11d0fe94ef812974a49d60f0e33a16d37f6 100644
--- a/chrome/browser/browsing_data/browsing_data_counter.cc
+++ b/chrome/browser/browsing_data/browsing_data_counter.cc
@@ -53,12 +53,55 @@ void BrowsingDataCounter::Restart() {
if (!profile_->GetPrefs()->GetBoolean(GetPrefName()))
return;
- callback_.Run(false, 0u);
+ callback_.Run(make_scoped_ptr(new Result(this)));
Count();
}
void BrowsingDataCounter::ReportResult(ResultInt value) {
DCHECK(initialized_);
- callback_.Run(true, value);
+ callback_.Run(make_scoped_ptr(new FinishedResult(this, value)));
+}
+
+void BrowsingDataCounter::ReportResult(scoped_ptr<Result> result) {
+ DCHECK(initialized_);
+ callback_.Run(result.Pass());
+}
+
+// BrowsingDataCounter::Result -------------------------------------------------
+
+BrowsingDataCounter::Result::Result(const BrowsingDataCounter* source)
+ : source_(source) {
+}
+
+BrowsingDataCounter::Result::~Result() {
+}
+
+bool BrowsingDataCounter::Result::finished() const {
+ return false;
+}
+
+const BrowsingDataCounter::ResultInt
+ BrowsingDataCounter::Result::value() const {
+ return 0;
Bernhard Bauer 2015/11/03 10:11:19 You could add a NOTREACHED(), or -- depending on h
msramek 2015/11/03 10:55:45 Yes, I wanted to move it to the subclass (if you l
+}
+
+// BrowsingDataCounter::FinishedResult -----------------------------------------
+
+BrowsingDataCounter::FinishedResult::FinishedResult(
+ const BrowsingDataCounter* source, ResultInt value)
+ : Result(source),
+ value_(value) {
+}
+
+BrowsingDataCounter::FinishedResult::~FinishedResult() {
+}
+
+bool BrowsingDataCounter::FinishedResult::finished() const {
+ return true;
+}
+
+const BrowsingDataCounter::ResultInt
+ BrowsingDataCounter::FinishedResult::value() const {
+ return value_;
}

Powered by Google App Engine
This is Rietveld 408576698