| 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 per-type scheduling data. | |
| 6 #ifndef SYNC_SESSIONS_DATA_TYPE_TRACKER_H_ | 5 #ifndef SYNC_SESSIONS_DATA_TYPE_TRACKER_H_ |
| 7 #define SYNC_SESSIONS_DATA_TYPE_TRACKER_H_ | 6 #define SYNC_SESSIONS_DATA_TYPE_TRACKER_H_ |
| 8 | 7 |
| 9 #include <deque> | |
| 10 #include <string> | 8 #include <string> |
| 11 | 9 |
| 12 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/scoped_vector.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "sync/notifier/dropped_invalidation_tracker.h" | 14 #include "sync/internal_api/public/base/invalidation_interface.h" |
| 15 #include "sync/notifier/single_object_invalidation_set.h" | 15 #include "sync/internal_api/public/base/model_type.h" |
| 16 #include "sync/protocol/sync.pb.h" | 16 #include "sync/protocol/sync.pb.h" |
| 17 | 17 |
| 18 namespace syncer { | 18 namespace syncer { |
| 19 | 19 |
| 20 class Invalidation; | 20 class InvalidationInterface; |
| 21 class SingleObjectInvalidationSet; | |
| 22 | 21 |
| 23 namespace sessions { | 22 namespace sessions { |
| 24 | 23 |
| 25 typedef std::deque<std::string> PayloadList; | 24 // A class to track the per-type scheduling data. |
| 26 | |
| 27 class DataTypeTracker { | 25 class DataTypeTracker { |
| 28 public: | 26 public: |
| 29 explicit DataTypeTracker(const invalidation::ObjectId& object_id); | 27 explicit DataTypeTracker(); |
| 30 ~DataTypeTracker(); | 28 ~DataTypeTracker(); |
| 31 | 29 |
| 32 // For STL compatibility, we do not forbid the creation of a default copy | 30 // For STL compatibility, we do not forbid the creation of a default copy |
| 33 // constructor and assignment operator. | 31 // constructor and assignment operator. |
| 34 | 32 |
| 35 // Tracks that a local change has been made to this type. | 33 // Tracks that a local change has been made to this type. |
| 36 void RecordLocalChange(); | 34 void RecordLocalChange(); |
| 37 | 35 |
| 38 // Tracks that a local refresh request has been made for this type. | 36 // Tracks that a local refresh request has been made for this type. |
| 39 void RecordLocalRefreshRequest(); | 37 void RecordLocalRefreshRequest(); |
| 40 | 38 |
| 41 // Tracks that we received invalidation notifications for this type. | 39 // Tracks that we received invalidation notifications for this type. |
| 42 void RecordRemoteInvalidations( | 40 void RecordRemoteInvalidation(scoped_ptr<InvalidationInterface> incoming); |
| 43 const SingleObjectInvalidationSet& invalidations); | |
| 44 | 41 |
| 45 // Records that a sync cycle has been performed successfully. | 42 // Records that a sync cycle has been performed successfully. |
| 46 // Generally, this means that all local changes have been committed and all | 43 // Generally, this means that all local changes have been committed and all |
| 47 // remote changes have been downloaded, so we can clear any flags related to | 44 // remote changes have been downloaded, so we can clear any flags related to |
| 48 // pending work. | 45 // pending work. |
| 49 void RecordSuccessfulSyncCycle(); | 46 void RecordSuccessfulSyncCycle(); |
| 50 | 47 |
| 51 // Updates the size of the invalidations payload buffer. | 48 // Updates the size of the invalidations payload buffer. |
| 52 void UpdatePayloadBufferSize(size_t new_size); | 49 void UpdatePayloadBufferSize(size_t new_size); |
| 53 | 50 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // successful sync cycle. | 95 // successful sync cycle. |
| 99 int local_nudge_count_; | 96 int local_nudge_count_; |
| 100 | 97 |
| 101 // Number of local refresh requests received for this type since the last | 98 // Number of local refresh requests received for this type since the last |
| 102 // successful sync cycle. | 99 // successful sync cycle. |
| 103 int local_refresh_request_count_; | 100 int local_refresh_request_count_; |
| 104 | 101 |
| 105 // The list of invalidations received since the last successful sync cycle. | 102 // The list of invalidations received since the last successful sync cycle. |
| 106 // This list may be incomplete. See also: | 103 // This list may be incomplete. See also: |
| 107 // drop_tracker_.IsRecoveringFromDropEvent() and server_payload_overflow_. | 104 // drop_tracker_.IsRecoveringFromDropEvent() and server_payload_overflow_. |
| 108 SingleObjectInvalidationSet pending_invalidations_; | 105 // |
| 106 // This list takes ownership of its contents. |
| 107 ScopedVector<InvalidationInterface> pending_invalidations_; |
| 109 | 108 |
| 110 size_t payload_buffer_size_; | 109 size_t payload_buffer_size_; |
| 111 | 110 |
| 112 // If !unthrottle_time_.is_null(), this type is throttled and may not download | 111 // If !unthrottle_time_.is_null(), this type is throttled and may not download |
| 113 // or commit data until the specified time. | 112 // or commit data until the specified time. |
| 114 base::TimeTicks unthrottle_time_; | 113 base::TimeTicks unthrottle_time_; |
| 115 | 114 |
| 116 // A helper to keep track invalidations we dropped due to overflow. | 115 // A helper to keep track invalidations we dropped due to overflow. |
| 117 DroppedInvalidationTracker drop_tracker_; | 116 scoped_ptr<InvalidationInterface> last_dropped_invalidation_; |
| 117 |
| 118 DISALLOW_COPY_AND_ASSIGN(DataTypeTracker); |
| 118 }; | 119 }; |
| 119 | 120 |
| 121 } // namespace sessions |
| 120 } // namespace syncer | 122 } // namespace syncer |
| 121 } // namespace sessions | |
| 122 | 123 |
| 123 #endif // SYNC_SESSIONS_DATA_TYPE_TRACKER_H_ | 124 #endif // SYNC_SESSIONS_DATA_TYPE_TRACKER_H_ |
| OLD | NEW |