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..dc9c543e6f2e75f644c6e5ce72c763a33574617d 100644 |
| --- a/chrome/browser/browsing_data/browsing_data_counter.h |
| +++ b/chrome/browser/browsing_data/browsing_data_counter.h |
| @@ -9,14 +9,53 @@ |
| #include <string> |
| #include "base/callback.h" |
| +#include "base/macros.h" |
| #include "base/prefs/pref_member.h" |
| #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| #include "chrome/browser/profiles/profile.h" |
| class BrowsingDataCounter { |
| public: |
| - typedef uint64_t ResultInt; |
| - typedef base::Callback<void(bool, ResultInt)> Callback; |
| + typedef int64_t ResultInt; |
| + |
| + // Base class of results returned by BrowsingDataCounter. When the computation |
| + // has started, an instance is returned to represent a pending result. The |
| + // |Value()| is not valid until the counting has |Finished()|. |
|
Bernhard Bauer
2015/11/03 14:13:46
This is a bit confusing on its own, as there is no
msramek
2015/11/03 14:54:09
Done. Weird, I thought I removed the comment alrea
|
| + class Result { |
| + public: |
| + explicit Result(const BrowsingDataCounter* source); |
| + virtual ~Result(); |
| + |
| + const BrowsingDataCounter* source() const { return source_; } |
| + virtual bool Finished() const; |
| + |
| + private: |
| + const BrowsingDataCounter* source_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(Result); |
| + }; |
| + |
| + // A subclass of Result returned when the computation has finished. The result |
| + // value can be retrieved by calling |Value()|. Some BrowsingDataCounter |
| + // subclasses might use a subclass of FinishedResult to provide more complex |
| + // results. |
| + class FinishedResult : public Result { |
| + public: |
| + FinishedResult(const BrowsingDataCounter* source, ResultInt value); |
| + ~FinishedResult() override; |
| + |
| + // Result: |
| + bool Finished() const override; |
| + |
| + virtual ResultInt Value() const; |
|
Bernhard Bauer
2015/11/03 14:13:46
This doesn't need to be virtual now.
msramek
2015/11/03 14:54:09
Done.
|
| + |
| + private: |
| + ResultInt value_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FinishedResult); |
| + }; |
| + |
| + typedef base::Callback<void(scoped_ptr<Result>)> Callback; |
| BrowsingDataCounter(); |
| virtual ~BrowsingDataCounter(); |
| @@ -38,8 +77,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(); |