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

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: 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.h
diff --git a/chrome/browser/browsing_data/browsing_data_counter.h b/chrome/browser/browsing_data/browsing_data_counter.h
index ba3afbd741fad06ec58a9a4c408f941766f2d176..1686c4fbb196b52fcd9f9e955ee1813eee1b4a32 100644
--- a/chrome/browser/browsing_data/browsing_data_counter.h
+++ b/chrome/browser/browsing_data/browsing_data_counter.h
@@ -16,7 +16,33 @@
class BrowsingDataCounter {
public:
typedef uint64_t ResultInt;
Bernhard Bauer 2015/11/03 10:11:19 Hm... I guess you need 64 bits? But unless you act
msramek 2015/11/03 10:55:46 I definitely need more than 32 bits, as I'm summin
- typedef base::Callback<void(bool, ResultInt)> Callback;
+
+ class Result {
Bernhard Bauer 2015/11/03 10:11:20 Add a couple of comments what these classes are fo
msramek 2015/11/03 10:55:45 Done.
+ public:
+ explicit Result(const BrowsingDataCounter* source);
+ virtual ~Result();
+
+ const BrowsingDataCounter* source() const { return source_; }
+ virtual bool finished() const;
Bernhard Bauer 2015/11/03 10:11:20 Use CamelCase for non-trivial methods (which inclu
msramek 2015/11/03 10:55:45 Done.
+ virtual const ResultInt value() const;
Bernhard Bauer 2015/11/03 10:11:20 The const isn't really necessary if you return a s
msramek 2015/11/03 10:55:45 Done. It was originally a reference, I had to remo
+
+ private:
+ const BrowsingDataCounter* source_;
Bernhard Bauer 2015/11/03 10:11:19 DISALLOW_COPY_AND_ASSIGN (you don't want this assi
msramek 2015/11/03 10:55:45 Done. I need to get used to this.
+ };
+
+ class FinishedResult : public Result {
+ public:
+ FinishedResult(const BrowsingDataCounter* source, ResultInt value);
+ ~FinishedResult() override;
+
+ bool finished() const override;
+ const ResultInt value() const override;
+
+ private:
+ ResultInt value_;
+ };
+
+ typedef base::Callback<void(scoped_ptr<Result>)> Callback;
BrowsingDataCounter();
virtual ~BrowsingDataCounter();
@@ -38,8 +64,12 @@ 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();

Powered by Google App Engine
This is Rietveld 408576698