| 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> |
| 11 #include <map> | 11 #include <map> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/time/time.h" |
| 15 #include "sync/base/sync_export.h" | 16 #include "sync/base/sync_export.h" |
| 16 #include "sync/internal_api/public/base/invalidation_interface.h" | 17 #include "sync/internal_api/public/base/invalidation_interface.h" |
| 17 #include "sync/internal_api/public/base/model_type.h" | 18 #include "sync/internal_api/public/base/model_type.h" |
| 18 #include "sync/protocol/sync.pb.h" | 19 #include "sync/protocol/sync.pb.h" |
| 19 #include "sync/sessions/data_type_tracker.h" | 20 #include "sync/sessions/data_type_tracker.h" |
| 20 | 21 |
| 21 namespace syncer { | 22 namespace syncer { |
| 22 | 23 |
| 23 class ObjectIdInvalidationMap; | 24 class ObjectIdInvalidationMap; |
| 24 | 25 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 46 // by SetSyncCycleStartTime(), SetNextRetryTime(), and | 47 // by SetSyncCycleStartTime(), SetNextRetryTime(), and |
| 47 // RecordSuccessfulSyncCycle(). Please refer to those functions for more | 48 // RecordSuccessfulSyncCycle(). Please refer to those functions for more |
| 48 // information on how this flag is maintained. | 49 // information on how this flag is maintained. |
| 49 bool IsRetryRequired() const; | 50 bool IsRetryRequired() const; |
| 50 | 51 |
| 51 // Tells this class that all required update fetching or committing has | 52 // Tells this class that all required update fetching or committing has |
| 52 // completed successfully. | 53 // completed successfully. |
| 53 void RecordSuccessfulSyncCycle(); | 54 void RecordSuccessfulSyncCycle(); |
| 54 | 55 |
| 55 // Takes note of a local change. | 56 // Takes note of a local change. |
| 56 void RecordLocalChange(ModelTypeSet types); | 57 // Returns the shortest nudge delay from the tracker of each type in |types|. |
| 58 base::TimeDelta RecordLocalChange(ModelTypeSet types); |
| 57 | 59 |
| 58 // Takes note of a locally issued request to refresh a data type. | 60 // Takes note of a locally issued request to refresh a data type. |
| 59 void RecordLocalRefreshRequest(ModelTypeSet types); | 61 // Returns the current nudge delay for a local refresh. |
| 62 base::TimeDelta RecordLocalRefreshRequest(ModelTypeSet types); |
| 60 | 63 |
| 61 // Takes note of the receipt of an invalidation notice from the server. | 64 // Takes note of the receipt of an invalidation notice from the server. |
| 62 void RecordRemoteInvalidation(syncer::ModelType type, | 65 // Returns the current nudge delay for a remote invalidation. |
| 63 scoped_ptr<InvalidationInterface> invalidation); | 66 base::TimeDelta RecordRemoteInvalidation( |
| 67 syncer::ModelType type, |
| 68 scoped_ptr<InvalidationInterface> invalidation); |
| 64 | 69 |
| 65 // Take note that an initial sync is pending for this type. | 70 // Take note that an initial sync is pending for this type. |
| 66 void RecordInitialSyncRequired(syncer::ModelType type); | 71 void RecordInitialSyncRequired(syncer::ModelType type); |
| 67 | 72 |
| 68 // These functions should be called to keep this class informed of the status | 73 // These functions should be called to keep this class informed of the status |
| 69 // of the connection to the invalidations server. | 74 // of the connection to the invalidations server. |
| 70 void OnInvalidationsEnabled(); | 75 void OnInvalidationsEnabled(); |
| 71 void OnInvalidationsDisabled(); | 76 void OnInvalidationsDisabled(); |
| 72 | 77 |
| 73 // Marks |types| as being throttled from |now| until |now| + |length|. | 78 // Marks |types| as being throttled from |now| until |now| + |length|. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // | 139 // |
| 135 // This is a request sent to us as part of a server response requesting | 140 // This is a request sent to us as part of a server response requesting |
| 136 // that the client perform a GetUpdate request at |next_retry_time| to | 141 // that the client perform a GetUpdate request at |next_retry_time| to |
| 137 // fetch any updates it may have missed in the first attempt. | 142 // fetch any updates it may have missed in the first attempt. |
| 138 // | 143 // |
| 139 // To avoid strange results from IsRetryRequired() during a sync cycle, the | 144 // To avoid strange results from IsRetryRequired() during a sync cycle, the |
| 140 // effects of this change are not guaranteed to take effect until | 145 // effects of this change are not guaranteed to take effect until |
| 141 // SetSyncCycleStartTime() is called at the start of the *next* sync cycle. | 146 // SetSyncCycleStartTime() is called at the start of the *next* sync cycle. |
| 142 void SetNextRetryTime(base::TimeTicks next_retry_time); | 147 void SetNextRetryTime(base::TimeTicks next_retry_time); |
| 143 | 148 |
| 149 // Update the per-datatype local change nudge delays. |
| 150 void OnReceivedCustomNudgeDelays( |
| 151 const std::map<ModelType, base::TimeDelta>& delay_map); |
| 152 |
| 153 // Update the default nudge delay. |
| 154 void SetDefaultNudgeDelay(base::TimeDelta nudge_delay); |
| 155 |
| 144 private: | 156 private: |
| 145 typedef std::map<ModelType, DataTypeTracker*> TypeTrackerMap; | 157 typedef std::map<ModelType, DataTypeTracker*> TypeTrackerMap; |
| 146 | 158 |
| 147 TypeTrackerMap type_trackers_; | 159 TypeTrackerMap type_trackers_; |
| 148 STLValueDeleter<TypeTrackerMap> type_tracker_deleter_; | 160 STLValueDeleter<TypeTrackerMap> type_tracker_deleter_; |
| 149 | 161 |
| 150 // Merged updates source. This should be obsolete, but the server still | 162 // Merged updates source. This should be obsolete, but the server still |
| 151 // relies on it for some heuristics. | 163 // relies on it for some heuristics. |
| 152 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source_; | 164 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source_; |
| 153 | 165 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 179 | 191 |
| 180 // The currently active retry GU time. Will be null if there is no retry GU | 192 // The currently active retry GU time. Will be null if there is no retry GU |
| 181 // pending at this time. | 193 // pending at this time. |
| 182 base::TimeTicks current_retry_time_; | 194 base::TimeTicks current_retry_time_; |
| 183 | 195 |
| 184 // The time when the sync cycle started. This value is maintained by | 196 // The time when the sync cycle started. This value is maintained by |
| 185 // SetSyncCycleStartTime(). This may contain a stale value if we're not | 197 // SetSyncCycleStartTime(). This may contain a stale value if we're not |
| 186 // currently in a sync cycle. | 198 // currently in a sync cycle. |
| 187 base::TimeTicks sync_cycle_start_time_; | 199 base::TimeTicks sync_cycle_start_time_; |
| 188 | 200 |
| 201 // Nudge delays for various events. |
| 202 base::TimeDelta minimum_local_nudge_delay_; |
| 203 base::TimeDelta local_refresh_nudge_delay_; |
| 204 base::TimeDelta remote_invalidation_nudge_delay_; |
| 205 |
| 189 DISALLOW_COPY_AND_ASSIGN(NudgeTracker); | 206 DISALLOW_COPY_AND_ASSIGN(NudgeTracker); |
| 190 }; | 207 }; |
| 191 | 208 |
| 192 } // namespace sessions | 209 } // namespace sessions |
| 193 } // namespace syncer | 210 } // namespace syncer |
| 194 | 211 |
| 195 #endif // SYNC_SESSIONS_NUDGE_TRACKER_H_ | 212 #endif // SYNC_SESSIONS_NUDGE_TRACKER_H_ |
| OLD | NEW |