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

Unified Diff: chrome/browser/browsing_data/browsing_data_counter.h

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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/browsing_data/browsing_data_counter.h
diff --git a/chrome/browser/browsing_data/browsing_data_counter.h b/chrome/browser/browsing_data/browsing_data_counter.h
index ba3afbd741fad06ec58a9a4c408f941766f2d176..d860e1f9d54906b0d04b860e28494d8ebd044470 100644
--- a/chrome/browser/browsing_data/browsing_data_counter.h
+++ b/chrome/browser/browsing_data/browsing_data_counter.h
@@ -16,7 +16,29 @@
class BrowsingDataCounter {
public:
typedef uint64_t ResultInt;
- typedef base::Callback<void(bool, ResultInt)> Callback;
+
+ class Result {
+ public:
+ Result(const BrowsingDataCounter* source, bool finished, ResultInt value);
Bernhard Bauer 2015/11/02 16:15:27 Do you want someone to construct object of this cl
msramek 2015/11/02 20:54:05 That is what I also did originally, I just didn't
+ ~Result();
+
+ const BrowsingDataCounter* source() const { return source_; }
+ bool finished() const { return finished_; }
+ const ResultInt& value() const { return value_; }
+
+ private:
+ const BrowsingDataCounter* source_;
+ bool finished_;
Bernhard Bauer 2015/11/02 16:15:27 Hm... seeing as we have this class structure now,
msramek 2015/11/02 20:54:06 Yes! Done.
+ ResultInt value_;
+ };
+
+ class FinishedResult : public Result {
+ public:
+ FinishedResult(const BrowsingDataCounter* source, ResultInt value);
+ ~FinishedResult();
+ };
+
+ typedef base::Callback<void(scoped_ptr<Result>)> Callback;
BrowsingDataCounter();
virtual ~BrowsingDataCounter();
@@ -38,13 +60,23 @@ class BrowsingDataCounter {
protected:
// Should be called from |Count| by any overriding class to indicate that
- // counting is finished and report the |result|.
- void ReportResult(ResultInt result);
+ // counting is finished and report |value| as the result.
+ void ReportResult(ResultInt value);
+
+ // A convenience overload of the previous method that allows subclasses to
+ // provide a custom |result|.
+ void ReportResult(scoped_ptr<Result> result);
// Calculates the beginning of the counting period as |period_| before now.
base::Time GetPeriodStart();
private:
+ class PendingResult : public Result {
+ public:
+ explicit PendingResult(const BrowsingDataCounter* source);
+ ~PendingResult();
+ };
+
// Called after the class is initialized by calling |Init|.
virtual void OnInitialized();

Powered by Google App Engine
This is Rietveld 408576698