Chromium Code Reviews| Index: components/browsing_data/core/counters/history_counter.h |
| diff --git a/chrome/browser/browsing_data/history_counter.h b/components/browsing_data/core/counters/history_counter.h |
| similarity index 70% |
| rename from chrome/browser/browsing_data/history_counter.h |
| rename to components/browsing_data/core/counters/history_counter.h |
| index 1ce74cdc4824364ee24e13dd2976768be2ce14b3..e094009b1c537d4c876f0f82a4d359bd1e0732ed 100644 |
| --- a/chrome/browser/browsing_data/history_counter.h |
| +++ b/components/browsing_data/core/counters/history_counter.h |
| @@ -2,10 +2,9 @@ |
| // 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_HISTORY_COUNTER_H_ |
| -#define CHROME_BROWSER_BROWSING_DATA_HISTORY_COUNTER_H_ |
| +#ifndef COMPONENTS_BROWSING_DATA_CORE_COUNTERS_HISTORY_COUNTER_H_ |
| +#define COMPONENTS_BROWSING_DATA_CORE_COUNTERS_HISTORY_COUNTER_H_ |
| -#include "base/memory/weak_ptr.h" |
| #include "base/task/cancelable_task_tracker.h" |
| #include "base/timer/timer.h" |
| #include "components/browsing_data/core/counters/browsing_data_counter.h" |
| @@ -13,13 +12,15 @@ |
| #include "components/history/core/browser/web_history_service.h" |
| #include "components/sync_driver/sync_service_observer.h" |
| -class Profile; |
| - |
| class ProfileSyncService; |
| +namespace browsing_data { |
| class HistoryCounter : public browsing_data::BrowsingDataCounter, |
| public sync_driver::SyncServiceObserver { |
| public: |
| + typedef base::Callback<history::WebHistoryService*()> |
| + GetUpdatedWebHistoryServiceCallback; |
| + |
| class HistoryResult : public FinishedResult { |
| public: |
| HistoryResult(const HistoryCounter* source, |
| @@ -33,7 +34,9 @@ class HistoryCounter : public browsing_data::BrowsingDataCounter, |
| bool has_synced_visits_; |
| }; |
| - explicit HistoryCounter(Profile* profile); |
| + explicit HistoryCounter(ProfileSyncService* profile_sync_service, |
| + const GetUpdatedWebHistoryServiceCallback& callback, |
| + history::HistoryService* history_service); |
| ~HistoryCounter() override; |
| void OnInitialized() override; |
| @@ -41,42 +44,47 @@ class HistoryCounter : public browsing_data::BrowsingDataCounter, |
| // Whether there are counting tasks in progress. Only used for testing. |
| bool HasTrackedTasks(); |
| - // Make the history counter use a custom WebHistoryService instance. Only |
| - // used for testing. |
| - void SetWebHistoryServiceForTesting(history::WebHistoryService* service); |
| + const std::string& GetPrefName() const override; |
| private: |
| - Profile* profile_; |
| + void Count() override; |
| + |
| + void OnGetLocalHistoryCount(history::HistoryCountResult result); |
| + void OnGetWebHistoryCount(history::WebHistoryService::Request* request, |
| + const base::DictionaryValue* result); |
| + void OnWebHistoryTimeout(); |
| + void MergeResults(); |
| + |
| + bool IsHistorySyncEnabled(); |
| + |
| + // SyncServiceObserver implementation. |
| + void OnStateChanged() override; |
| + |
| + const std::string pref_name_; |
| + |
| + ProfileSyncService* profile_sync_service_; |
| + |
| + GetUpdatedWebHistoryServiceCallback web_history_service_callback_; |
| + |
| + history::HistoryService* history_service_; |
| - BrowsingDataCounter::ResultInt local_result_; |
| bool has_synced_visits_; |
| bool local_counting_finished_; |
| bool web_counting_finished_; |
| - history::WebHistoryService* testing_web_history_service_; |
| - |
| base::CancelableTaskTracker cancelable_task_tracker_; |
| std::unique_ptr<history::WebHistoryService::Request> web_history_request_; |
| base::OneShotTimer web_history_timeout_; |
| base::ThreadChecker thread_checker_; |
| - ProfileSyncService* sync_service_; |
| + BrowsingDataCounter::ResultInt local_result_; |
| + |
| bool history_sync_enabled_; |
| base::WeakPtrFactory<HistoryCounter> weak_ptr_factory_; |
| - |
| - void Count() override; |
| - |
| - void OnGetLocalHistoryCount(history::HistoryCountResult result); |
| - void OnGetWebHistoryCount(history::WebHistoryService::Request* request, |
| - const base::DictionaryValue* result); |
| - void OnWebHistoryTimeout(); |
| - void MergeResults(); |
| - |
| - // SyncServiceObserver implementation. |
| - void OnStateChanged() override; |
| }; |
| -#endif // CHROME_BROWSER_BROWSING_DATA_HISTORY_COUNTER_H_ |
| +} // namespace browsing_data |
|
msramek
2016/07/20 13:41:16
nit: Empty line.
ioanap
2016/07/20 17:50:37
Done.
|
| +#endif // COMPONENTS_BROWSING_DATA_CORE_COUNTERS_HISTORY_COUNTER_H_ |