| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_BROWSING_DATA_HISTORY_COUNTER_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_HISTORY_COUNTER_H_ |
| 6 #define CHROME_BROWSER_BROWSING_DATA_HISTORY_COUNTER_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_HISTORY_COUNTER_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/task/cancelable_task_tracker.h" | 9 #include "base/task/cancelable_task_tracker.h" |
| 10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
| 11 #include "chrome/browser/browsing_data/browsing_data_counter.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "components/browsing_data/counters/browsing_data_counter.h" |
| 12 #include "components/history/core/browser/history_service.h" | 13 #include "components/history/core/browser/history_service.h" |
| 13 #include "components/history/core/browser/web_history_service.h" | 14 #include "components/history/core/browser/web_history_service.h" |
| 14 #include "components/sync_driver/sync_service_observer.h" | 15 #include "components/sync_driver/sync_service_observer.h" |
| 15 | 16 |
| 16 class ProfileSyncService; | 17 class ProfileSyncService; |
| 17 | 18 |
| 18 class HistoryCounter: public BrowsingDataCounter, | 19 class HistoryCounter: public BrowsingDataCounter, |
| 19 public sync_driver::SyncServiceObserver { | 20 public sync_driver::SyncServiceObserver { |
| 20 public: | 21 public: |
| 21 class HistoryResult : public FinishedResult { | 22 class HistoryResult : public FinishedResult { |
| 22 public: | 23 public: |
| 23 HistoryResult(const HistoryCounter* source, | 24 HistoryResult(const HistoryCounter* source, |
| 24 ResultInt value, | 25 ResultInt value, |
| 25 bool has_synced_visits); | 26 bool has_synced_visits); |
| 26 ~HistoryResult() override; | 27 ~HistoryResult() override; |
| 27 | 28 |
| 28 bool has_synced_visits() const { return has_synced_visits_; } | 29 bool has_synced_visits() const { return has_synced_visits_; } |
| 29 | 30 |
| 30 private: | 31 private: |
| 31 bool has_synced_visits_; | 32 bool has_synced_visits_; |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 HistoryCounter(); | 35 explicit HistoryCounter(Profile* profile); |
| 35 ~HistoryCounter() override; | 36 ~HistoryCounter() override; |
| 36 | 37 |
| 37 void OnInitialized() override; | 38 void OnInitialized() override; |
| 38 const std::string& GetPrefName() const override; | |
| 39 | 39 |
| 40 // Whether there are counting tasks in progress. Only used for testing. | 40 // Whether there are counting tasks in progress. Only used for testing. |
| 41 bool HasTrackedTasks(); | 41 bool HasTrackedTasks(); |
| 42 | 42 |
| 43 // Make the history counter use a custom WebHistoryService instance. Only | 43 // Make the history counter use a custom WebHistoryService instance. Only |
| 44 // used for testing. | 44 // used for testing. |
| 45 void SetWebHistoryServiceForTesting(history::WebHistoryService* service); | 45 void SetWebHistoryServiceForTesting(history::WebHistoryService* service); |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 const std::string pref_name_; | 48 Profile* profile_; |
| 49 | 49 |
| 50 BrowsingDataCounter::ResultInt local_result_; | 50 BrowsingDataCounter::ResultInt local_result_; |
| 51 bool has_synced_visits_; | 51 bool has_synced_visits_; |
| 52 | 52 |
| 53 bool local_counting_finished_; | 53 bool local_counting_finished_; |
| 54 bool web_counting_finished_; | 54 bool web_counting_finished_; |
| 55 | 55 |
| 56 history::WebHistoryService* testing_web_history_service_; | 56 history::WebHistoryService* testing_web_history_service_; |
| 57 | 57 |
| 58 base::CancelableTaskTracker cancelable_task_tracker_; | 58 base::CancelableTaskTracker cancelable_task_tracker_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 72 void OnGetWebHistoryCount(history::WebHistoryService::Request* request, | 72 void OnGetWebHistoryCount(history::WebHistoryService::Request* request, |
| 73 const base::DictionaryValue* result); | 73 const base::DictionaryValue* result); |
| 74 void OnWebHistoryTimeout(); | 74 void OnWebHistoryTimeout(); |
| 75 void MergeResults(); | 75 void MergeResults(); |
| 76 | 76 |
| 77 // SyncServiceObserver implementation. | 77 // SyncServiceObserver implementation. |
| 78 void OnStateChanged() override; | 78 void OnStateChanged() override; |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 #endif // CHROME_BROWSER_BROWSING_DATA_HISTORY_COUNTER_H_ | 81 #endif // CHROME_BROWSER_BROWSING_DATA_HISTORY_COUNTER_H_ |
| OLD | NEW |