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 <list> | 10 #include <list> |
(...skipping 14 matching lines...) Expand all Loading... |
25 class SYNC_EXPORT_PRIVATE NudgeTracker { | 25 class SYNC_EXPORT_PRIVATE NudgeTracker { |
26 public: | 26 public: |
27 static size_t kDefaultMaxPayloadsPerType; | 27 static size_t kDefaultMaxPayloadsPerType; |
28 | 28 |
29 NudgeTracker(); | 29 NudgeTracker(); |
30 ~NudgeTracker(); | 30 ~NudgeTracker(); |
31 | 31 |
32 // Returns true if there is a good reason for performing a sync cycle. | 32 // Returns true if there is a good reason for performing a sync cycle. |
33 // This does not take into account whether or not this is a good *time* to | 33 // This does not take into account whether or not this is a good *time* to |
34 // perform a sync cycle; that's the scheduler's job. | 34 // perform a sync cycle; that's the scheduler's job. |
35 bool IsSyncRequired(); | 35 bool IsSyncRequired() const; |
36 | 36 |
37 // Tells this class that all required update fetching and committing has | 37 // Tells this class that all required update fetching and committing has |
38 // completed successfully. | 38 // completed successfully. |
39 void RecordSuccessfulSyncCycle(); | 39 void RecordSuccessfulSyncCycle(); |
40 | 40 |
41 // Takes note of a local change. | 41 // Takes note of a local change. |
42 void RecordLocalChange(ModelTypeSet types); | 42 void RecordLocalChange(ModelTypeSet types); |
43 | 43 |
44 // Takes note of a locally issued request to refresh a data type. | 44 // Takes note of a locally issued request to refresh a data type. |
45 void RecordLocalRefreshRequest(ModelTypeSet types); | 45 void RecordLocalRefreshRequest(ModelTypeSet types); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // Returns the 'source' of the GetUpdate request. | 81 // Returns the 'source' of the GetUpdate request. |
82 // | 82 // |
83 // This flag is deprecated, but still used by the server. There can be more | 83 // This flag is deprecated, but still used by the server. There can be more |
84 // than one reason to perform a particular sync cycle. The GetUpdatesTrigger | 84 // than one reason to perform a particular sync cycle. The GetUpdatesTrigger |
85 // message will contain more reliable information about the reasons for | 85 // message will contain more reliable information about the reasons for |
86 // performing a sync. | 86 // performing a sync. |
87 // | 87 // |
88 // See the implementation for important information about the coalesce logic. | 88 // See the implementation for important information about the coalesce logic. |
89 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source() const; | 89 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source() const; |
90 | 90 |
91 // Fills a ProgressMarker for the next GetUpdates request. This is used by | 91 // Fills a GetUpdatesTrigger message for the next GetUpdates request. This is |
92 // the DownloadUpdatesCommand to dump lots of useful per-type state | 92 // used by the DownloadUpdatesCommand to dump lots of useful per-type state |
93 // information into the GetUpdate request before sending it off to the server. | 93 // information into the GetUpdate request before sending it off to the server. |
94 void FillProtoMessage( | 94 void FillProtoMessage( |
95 ModelType type, | 95 ModelType type, |
96 sync_pb::GetUpdateTriggers* msg) const; | 96 sync_pb::GetUpdateTriggers* msg) const; |
97 | 97 |
| 98 // Fills a ProgressMarker with single legacy notification hint expected by the |
| 99 // sync server. Newer servers will rely on the data set by FillProtoMessage() |
| 100 // instead of this. |
| 101 void SetLegacyNotificationHint( |
| 102 ModelType type, |
| 103 sync_pb::DataTypeProgressMarker* progress) const; |
| 104 |
98 // Adjusts the number of hints that can be stored locally. | 105 // Adjusts the number of hints that can be stored locally. |
99 void SetHintBufferSize(size_t size); | 106 void SetHintBufferSize(size_t size); |
100 | 107 |
101 private: | 108 private: |
102 typedef std::map<ModelType, DataTypeTracker> TypeTrackerMap; | 109 typedef std::map<ModelType, DataTypeTracker> TypeTrackerMap; |
103 | 110 |
104 TypeTrackerMap type_trackers_; | 111 TypeTrackerMap type_trackers_; |
105 | 112 |
106 // Merged updates source. This should be obsolete, but the server still | 113 // Merged updates source. This should be obsolete, but the server still |
107 // relies on it for some heuristics. | 114 // relies on it for some heuristics. |
(...skipping 15 matching lines...) Expand all Loading... |
123 | 130 |
124 size_t num_payloads_per_type_; | 131 size_t num_payloads_per_type_; |
125 | 132 |
126 DISALLOW_COPY_AND_ASSIGN(NudgeTracker); | 133 DISALLOW_COPY_AND_ASSIGN(NudgeTracker); |
127 }; | 134 }; |
128 | 135 |
129 } // namespace sessions | 136 } // namespace sessions |
130 } // namespace syncer | 137 } // namespace syncer |
131 | 138 |
132 #endif // SYNC_SESSIONS_NUDGE_TRACKER_H_ | 139 #endif // SYNC_SESSIONS_NUDGE_TRACKER_H_ |
OLD | NEW |