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

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

Issue 2084903002: Moved BrowsingDataCounter and part of BrowsingDataCounterUtils to components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 months 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
deleted file mode 100644
index 3bd1e4b97448825bd09b979d3074632802f1f14a..0000000000000000000000000000000000000000
--- a/chrome/browser/browsing_data/browsing_data_counter.h
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright (c) 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_H_
-#define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_H_
-
-#include <stdint.h>
-#include <string>
-
-#include "base/callback.h"
-#include "base/macros.h"
-#include "chrome/browser/browsing_data/browsing_data_remover.h"
-#include "chrome/browser/profiles/profile.h"
-#include "components/prefs/pref_member.h"
-
-class BrowsingDataCounter {
- public:
- 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.
- 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;
-
- ResultInt Value() const;
-
- private:
- ResultInt value_;
-
- DISALLOW_COPY_AND_ASSIGN(FinishedResult);
- };
-
- typedef base::Callback<void(std::unique_ptr<Result>)> Callback;
-
- BrowsingDataCounter();
- virtual ~BrowsingDataCounter();
-
- // Should be called once to initialize this class.
- void Init(Profile* profile,
- const Callback& callback);
-
- // Name of the preference associated with this counter.
- virtual const std::string& GetPrefName() const = 0;
-
- // The profile associated with this counter.
- Profile* GetProfile() const;
-
- // Restarts the counter. Will be called automatically if the counting needs
- // to be restarted, e.g. when the deletion preference changes state or when
- // we are notified of data changes.
- void Restart();
-
- protected:
- // Should be called from |Count| by any overriding class to indicate that
- // 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(std::unique_ptr<Result> result);
-
- // Calculates the beginning of the counting period as |period_| before now.
- base::Time GetPeriodStart();
-
- private:
- // Called after the class is initialized by calling |Init|.
- virtual void OnInitialized();
-
- // Count the data.
- virtual void Count() = 0;
-
- // The profile for which we will count the data volume.
- Profile* profile_;
-
- // The callback that will be called when the UI should be updated with a new
- // counter value.
- Callback callback_;
-
- // The boolean preference indicating whether this data type is to be deleted.
- // If false, we will not count it.
- BooleanPrefMember pref_;
-
- // The integer preference describing the time period for which this data type
- // is to be deleted.
- IntegerPrefMember period_;
-
- // Whether this class was properly initialized by calling |Init|.
- bool initialized_ = false;
-};
-
-#endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_H_
« no previous file with comments | « chrome/browser/browsing_data/autofill_counter_browsertest.cc ('k') | chrome/browser/browsing_data/browsing_data_counter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698