Chromium Code Reviews| 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(); |