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

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

Issue 2855623005: Move browsing_data counter sync tests to separate file (Closed)
Patch Set: remove HistoryResult and PasswordResult Created 3 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 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_BROWSING_DATA_COUNTER_H_ 5 #ifndef COMPONENTS_BROWSING_DATA_CORE_COUNTERS_BROWSING_DATA_COUNTER_H_
6 #define COMPONENTS_BROWSING_DATA_CORE_COUNTERS_BROWSING_DATA_COUNTER_H_ 6 #define COMPONENTS_BROWSING_DATA_CORE_COUNTERS_BROWSING_DATA_COUNTER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 bool Finished() const override; 53 bool Finished() const override;
54 54
55 ResultInt Value() const; 55 ResultInt Value() const;
56 56
57 private: 57 private:
58 ResultInt value_; 58 ResultInt value_;
59 59
60 DISALLOW_COPY_AND_ASSIGN(FinishedResult); 60 DISALLOW_COPY_AND_ASSIGN(FinishedResult);
61 }; 61 };
62 62
63 // A subclass of FinishedResult that besides |Value()| also stores whether
64 // the datatype is synced.
65 class SyncResult : public FinishedResult {
66 public:
67 SyncResult(const BrowsingDataCounter* source,
68 ResultInt value,
69 bool sync_enabled);
70 ~SyncResult() override;
71
72 bool IsSyncEnabled() const;
73
74 private:
75 bool sync_enabled_;
76
77 DISALLOW_COPY_AND_ASSIGN(SyncResult);
78 };
79
63 typedef base::Callback<void(std::unique_ptr<Result>)> Callback; 80 typedef base::Callback<void(std::unique_ptr<Result>)> Callback;
64 81
65 // Every calculation progresses through a state machine. At initialization, 82 // Every calculation progresses through a state machine. At initialization,
66 // the counter is IDLE. If a result is calculated within a given time 83 // the counter is IDLE. If a result is calculated within a given time
67 // interval, it is immediately reported and the counter is again IDLE. 84 // interval, it is immediately reported and the counter is again IDLE.
68 // Otherwise, the counter instructs the UI to show a "Calculating..." 85 // Otherwise, the counter instructs the UI to show a "Calculating..."
69 // message and transitions to the SHOW_CALCULATING state. The counter stays 86 // message and transitions to the SHOW_CALCULATING state. The counter stays
70 // in this state for a given amount of time. If a result is calculated at 87 // in this state for a given amount of time. If a result is calculated at
71 // this time, it is stored, but not immediately reported. After the timer 88 // this time, it is stored, but not immediately reported. After the timer
72 // elapses, we check if a result has been reported in the meantime. If yes, 89 // elapses, we check if a result has been reported in the meantime. If yes,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 std::unique_ptr<Result> staged_result_; 180 std::unique_ptr<Result> staged_result_;
164 181
165 // A timer to time the RESTARTED->SHOW_CALCULATION and 182 // A timer to time the RESTARTED->SHOW_CALCULATION and
166 // SHOW_CALCULATION->READY_TO_REPORT_RESULT state transitions. 183 // SHOW_CALCULATION->READY_TO_REPORT_RESULT state transitions.
167 base::OneShotTimer timer_; 184 base::OneShotTimer timer_;
168 }; 185 };
169 186
170 } // namespace browsing_data 187 } // namespace browsing_data
171 188
172 #endif // COMPONENTS_BROWSING_DATA_CORE_COUNTERS_BROWSING_DATA_COUNTER_H_ 189 #endif // COMPONENTS_BROWSING_DATA_CORE_COUNTERS_BROWSING_DATA_COUNTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698