OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // A class to track the outstanding work required to bring the client back into | 5 // A class to track the outstanding work required to bring the client back into |
6 // sync with the server. | 6 // sync with the server. |
7 #ifndef SYNC_SESSIONS_NUDGE_TRACKER_H_ | 7 #ifndef SYNC_SESSIONS_NUDGE_TRACKER_H_ |
8 #define SYNC_SESSIONS_NUDGE_TRACKER_H_ | 8 #define SYNC_SESSIONS_NUDGE_TRACKER_H_ |
9 | 9 |
10 #include <stddef.h> | 10 #include <stddef.h> |
11 | 11 |
12 #include <list> | 12 #include <list> |
13 #include <map> | 13 #include <map> |
| 14 #include <memory> |
14 | 15 |
15 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
16 #include "base/macros.h" | 17 #include "base/macros.h" |
17 #include "base/memory/scoped_ptr.h" | |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "sync/base/sync_export.h" | 19 #include "sync/base/sync_export.h" |
20 #include "sync/internal_api/public/base/invalidation_interface.h" | 20 #include "sync/internal_api/public/base/invalidation_interface.h" |
21 #include "sync/internal_api/public/base/model_type.h" | 21 #include "sync/internal_api/public/base/model_type.h" |
22 #include "sync/protocol/sync.pb.h" | 22 #include "sync/protocol/sync.pb.h" |
23 #include "sync/sessions/data_type_tracker.h" | 23 #include "sync/sessions/data_type_tracker.h" |
24 | 24 |
25 namespace syncer { | 25 namespace syncer { |
26 | 26 |
27 class ObjectIdInvalidationMap; | 27 class ObjectIdInvalidationMap; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 base::TimeDelta RecordLocalChange(ModelTypeSet types); | 61 base::TimeDelta RecordLocalChange(ModelTypeSet types); |
62 | 62 |
63 // Takes note of a locally issued request to refresh a data type. | 63 // Takes note of a locally issued request to refresh a data type. |
64 // Returns the current nudge delay for a local refresh. | 64 // Returns the current nudge delay for a local refresh. |
65 base::TimeDelta RecordLocalRefreshRequest(ModelTypeSet types); | 65 base::TimeDelta RecordLocalRefreshRequest(ModelTypeSet types); |
66 | 66 |
67 // Takes note of the receipt of an invalidation notice from the server. | 67 // Takes note of the receipt of an invalidation notice from the server. |
68 // Returns the current nudge delay for a remote invalidation. | 68 // Returns the current nudge delay for a remote invalidation. |
69 base::TimeDelta RecordRemoteInvalidation( | 69 base::TimeDelta RecordRemoteInvalidation( |
70 syncer::ModelType type, | 70 syncer::ModelType type, |
71 scoped_ptr<InvalidationInterface> invalidation); | 71 std::unique_ptr<InvalidationInterface> invalidation); |
72 | 72 |
73 // Take note that an initial sync is pending for this type. | 73 // Take note that an initial sync is pending for this type. |
74 void RecordInitialSyncRequired(syncer::ModelType type); | 74 void RecordInitialSyncRequired(syncer::ModelType type); |
75 | 75 |
76 // Takes note that the conflict happended for this type, need to sync to | 76 // Takes note that the conflict happended for this type, need to sync to |
77 // resolve conflict locally. | 77 // resolve conflict locally. |
78 void RecordCommitConflict(syncer::ModelType type); | 78 void RecordCommitConflict(syncer::ModelType type); |
79 | 79 |
80 // These functions should be called to keep this class informed of the status | 80 // These functions should be called to keep this class informed of the status |
81 // of the connection to the invalidations server. | 81 // of the connection to the invalidations server. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 void SetNextRetryTime(base::TimeTicks next_retry_time); | 154 void SetNextRetryTime(base::TimeTicks next_retry_time); |
155 | 155 |
156 // Update the per-datatype local change nudge delays. | 156 // Update the per-datatype local change nudge delays. |
157 void OnReceivedCustomNudgeDelays( | 157 void OnReceivedCustomNudgeDelays( |
158 const std::map<ModelType, base::TimeDelta>& delay_map); | 158 const std::map<ModelType, base::TimeDelta>& delay_map); |
159 | 159 |
160 // Update the default nudge delay. | 160 // Update the default nudge delay. |
161 void SetDefaultNudgeDelay(base::TimeDelta nudge_delay); | 161 void SetDefaultNudgeDelay(base::TimeDelta nudge_delay); |
162 | 162 |
163 private: | 163 private: |
164 using TypeTrackerMap = std::map<ModelType, scoped_ptr<DataTypeTracker>>; | 164 using TypeTrackerMap = std::map<ModelType, std::unique_ptr<DataTypeTracker>>; |
165 | 165 |
166 TypeTrackerMap type_trackers_; | 166 TypeTrackerMap type_trackers_; |
167 | 167 |
168 // Tracks whether or not invalidations are currently enabled. | 168 // Tracks whether or not invalidations are currently enabled. |
169 bool invalidations_enabled_; | 169 bool invalidations_enabled_; |
170 | 170 |
171 // This flag is set if suspect that some technical malfunction or known bug | 171 // This flag is set if suspect that some technical malfunction or known bug |
172 // may have left us with some unserviced invalidations. | 172 // may have left us with some unserviced invalidations. |
173 // | 173 // |
174 // Keeps track of whether or not we're fully in sync with the invalidation | 174 // Keeps track of whether or not we're fully in sync with the invalidation |
(...skipping 28 matching lines...) Expand all Loading... |
203 base::TimeDelta local_refresh_nudge_delay_; | 203 base::TimeDelta local_refresh_nudge_delay_; |
204 base::TimeDelta remote_invalidation_nudge_delay_; | 204 base::TimeDelta remote_invalidation_nudge_delay_; |
205 | 205 |
206 DISALLOW_COPY_AND_ASSIGN(NudgeTracker); | 206 DISALLOW_COPY_AND_ASSIGN(NudgeTracker); |
207 }; | 207 }; |
208 | 208 |
209 } // namespace sessions | 209 } // namespace sessions |
210 } // namespace syncer | 210 } // namespace syncer |
211 | 211 |
212 #endif // SYNC_SESSIONS_NUDGE_TRACKER_H_ | 212 #endif // SYNC_SESSIONS_NUDGE_TRACKER_H_ |
OLD | NEW |