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

Side by Side Diff: components/browsing_data/core/counters/history_counter.h

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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 COMPONENTS_BROWSING_DATA_CORE_COUNTERS_HISTORY_COUNTER_H_ 5 #ifndef COMPONENTS_BROWSING_DATA_CORE_COUNTERS_HISTORY_COUNTER_H_
6 #define COMPONENTS_BROWSING_DATA_CORE_COUNTERS_HISTORY_COUNTER_H_ 6 #define COMPONENTS_BROWSING_DATA_CORE_COUNTERS_HISTORY_COUNTER_H_
7 7
8 #include <memory>
9
10 #include "base/task/cancelable_task_tracker.h" 8 #include "base/task/cancelable_task_tracker.h"
11 #include "base/timer/timer.h" 9 #include "base/timer/timer.h"
12 #include "components/browsing_data/core/counters/browsing_data_counter.h" 10 #include "components/browsing_data/core/counters/browsing_data_counter.h"
13 #include "components/history/core/browser/history_service.h" 11 #include "components/history/core/browser/history_service.h"
14 #include "components/history/core/browser/web_history_service.h" 12 #include "components/history/core/browser/web_history_service.h"
15 #include "components/sync/driver/sync_service.h" 13 #include "components/sync/driver/sync_service.h"
16 #include "components/sync/driver/sync_service_observer.h" 14 #include "components/sync/driver/sync_service_observer.h"
17 15
18 namespace browsing_data { 16 namespace browsing_data {
19 17
20 class HistoryCounter : public browsing_data::BrowsingDataCounter, 18 class HistoryCounter : public browsing_data::BrowsingDataCounter,
21 public syncer::SyncServiceObserver { 19 public sync_driver::SyncServiceObserver {
22 public: 20 public:
23 typedef base::Callback<history::WebHistoryService*()> 21 typedef base::Callback<history::WebHistoryService*()>
24 GetUpdatedWebHistoryServiceCallback; 22 GetUpdatedWebHistoryServiceCallback;
25 23
26 class HistoryResult : public FinishedResult { 24 class HistoryResult : public FinishedResult {
27 public: 25 public:
28 HistoryResult(const HistoryCounter* source, 26 HistoryResult(const HistoryCounter* source,
29 ResultInt value, 27 ResultInt value,
30 bool has_synced_visits); 28 bool has_synced_visits);
31 ~HistoryResult() override; 29 ~HistoryResult() override;
32 30
33 bool has_synced_visits() const { return has_synced_visits_; } 31 bool has_synced_visits() const { return has_synced_visits_; }
34 32
35 private: 33 private:
36 bool has_synced_visits_; 34 bool has_synced_visits_;
37 }; 35 };
38 36
39 explicit HistoryCounter(history::HistoryService* history_service, 37 explicit HistoryCounter(history::HistoryService* history_service,
40 const GetUpdatedWebHistoryServiceCallback& callback, 38 const GetUpdatedWebHistoryServiceCallback& callback,
41 syncer::SyncService* sync_service); 39 sync_driver::SyncService* sync_service);
42 ~HistoryCounter() override; 40 ~HistoryCounter() override;
43 41
44 void OnInitialized() override; 42 void OnInitialized() override;
45 43
46 // Whether there are counting tasks in progress. Only used for testing. 44 // Whether there are counting tasks in progress. Only used for testing.
47 bool HasTrackedTasks(); 45 bool HasTrackedTasks();
48 46
49 const char* GetPrefName() const override; 47 const char* GetPrefName() const override;
50 48
51 private: 49 private:
52 void Count() override; 50 void Count() override;
53 51
54 void OnGetLocalHistoryCount(history::HistoryCountResult result); 52 void OnGetLocalHistoryCount(history::HistoryCountResult result);
55 void OnGetWebHistoryCount(history::WebHistoryService::Request* request, 53 void OnGetWebHistoryCount(history::WebHistoryService::Request* request,
56 const base::DictionaryValue* result); 54 const base::DictionaryValue* result);
57 void OnWebHistoryTimeout(); 55 void OnWebHistoryTimeout();
58 void MergeResults(); 56 void MergeResults();
59 57
60 // SyncServiceObserver implementation. 58 // SyncServiceObserver implementation.
61 void OnStateChanged() override; 59 void OnStateChanged() override;
62 60
63 history::HistoryService* history_service_; 61 history::HistoryService* history_service_;
64 62
65 GetUpdatedWebHistoryServiceCallback web_history_service_callback_; 63 GetUpdatedWebHistoryServiceCallback web_history_service_callback_;
66 64
67 syncer::SyncService* sync_service_; 65 sync_driver::SyncService* sync_service_;
68 66
69 bool has_synced_visits_; 67 bool has_synced_visits_;
70 68
71 bool local_counting_finished_; 69 bool local_counting_finished_;
72 bool web_counting_finished_; 70 bool web_counting_finished_;
73 71
74 base::CancelableTaskTracker cancelable_task_tracker_; 72 base::CancelableTaskTracker cancelable_task_tracker_;
75 std::unique_ptr<history::WebHistoryService::Request> web_history_request_; 73 std::unique_ptr<history::WebHistoryService::Request> web_history_request_;
76 base::OneShotTimer web_history_timeout_; 74 base::OneShotTimer web_history_timeout_;
77 75
78 base::ThreadChecker thread_checker_; 76 base::ThreadChecker thread_checker_;
79 77
80 BrowsingDataCounter::ResultInt local_result_; 78 BrowsingDataCounter::ResultInt local_result_;
81 79
82 bool history_sync_enabled_; 80 bool history_sync_enabled_;
83 81
84 base::WeakPtrFactory<HistoryCounter> weak_ptr_factory_; 82 base::WeakPtrFactory<HistoryCounter> weak_ptr_factory_;
85 }; 83 };
86 84
87 } // namespace browsing_data 85 } // namespace browsing_data
88 86
89 #endif // COMPONENTS_BROWSING_DATA_CORE_COUNTERS_HISTORY_COUNTER_H_ 87 #endif // COMPONENTS_BROWSING_DATA_CORE_COUNTERS_HISTORY_COUNTER_H_
OLDNEW
« no previous file with comments | « components/browser_sync/test_profile_sync_service.cc ('k') | components/browsing_data/core/counters/history_counter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698