| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "sync/engine/model_type_entity.h" | 5 #include "sync/engine/model_type_entity.h" |
| 6 #include "sync/internal_api/public/non_blocking_sync_common.h" | 6 #include "sync/internal_api/public/non_blocking_sync_common.h" |
| 7 #include "sync/syncable/syncable_util.h" | 7 #include "sync/syncable/syncable_util.h" |
| 8 | 8 |
| 9 namespace syncer { | 9 namespace syncer_v2 { |
| 10 | 10 |
| 11 scoped_ptr<ModelTypeEntity> ModelTypeEntity::NewLocalItem( | 11 scoped_ptr<ModelTypeEntity> ModelTypeEntity::NewLocalItem( |
| 12 const std::string& client_tag, | 12 const std::string& client_tag, |
| 13 const sync_pb::EntitySpecifics& specifics, | 13 const sync_pb::EntitySpecifics& specifics, |
| 14 base::Time now) { | 14 base::Time now) { |
| 15 return scoped_ptr<ModelTypeEntity>(new ModelTypeEntity( | 15 return scoped_ptr<ModelTypeEntity>(new ModelTypeEntity( |
| 16 1, 0, 0, syncer_v2::kUncommittedVersion, true, | 16 1, 0, 0, kUncommittedVersion, true, |
| 17 std::string(), // Sync thread will assign the initial ID. | 17 std::string(), // Sync thread will assign the initial ID. |
| 18 syncable::GenerateSyncableHash(GetModelTypeFromSpecifics(specifics), | 18 syncer::syncable::GenerateSyncableHash( |
| 19 client_tag), | 19 syncer::GetModelTypeFromSpecifics(specifics), client_tag), |
| 20 client_tag, // As non-unique name. | 20 client_tag, // As non-unique name. |
| 21 specifics, false, now, now, std::string())); | 21 specifics, false, now, now, std::string())); |
| 22 } | 22 } |
| 23 | 23 |
| 24 scoped_ptr<ModelTypeEntity> ModelTypeEntity::FromServerUpdate( | 24 scoped_ptr<ModelTypeEntity> ModelTypeEntity::FromServerUpdate( |
| 25 const std::string& id, | 25 const std::string& id, |
| 26 const std::string& client_tag_hash, | 26 const std::string& client_tag_hash, |
| 27 const std::string& non_unique_name, | 27 const std::string& non_unique_name, |
| 28 int64 version, | 28 int64 version, |
| 29 const sync_pb::EntitySpecifics& specifics, | 29 const sync_pb::EntitySpecifics& specifics, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 sequence_number_++; | 132 sequence_number_++; |
| 133 } | 133 } |
| 134 | 134 |
| 135 void ModelTypeEntity::Delete() { | 135 void ModelTypeEntity::Delete() { |
| 136 sequence_number_++; | 136 sequence_number_++; |
| 137 specifics_.Clear(); | 137 specifics_.Clear(); |
| 138 deleted_ = true; | 138 deleted_ = true; |
| 139 } | 139 } |
| 140 | 140 |
| 141 void ModelTypeEntity::InitializeCommitRequestData( | 141 void ModelTypeEntity::InitializeCommitRequestData( |
| 142 syncer_v2::CommitRequestData* request) const { | 142 CommitRequestData* request) const { |
| 143 request->id = id_; | 143 request->id = id_; |
| 144 request->client_tag_hash = client_tag_hash_; | 144 request->client_tag_hash = client_tag_hash_; |
| 145 request->sequence_number = sequence_number_; | 145 request->sequence_number = sequence_number_; |
| 146 request->base_version = base_version_; | 146 request->base_version = base_version_; |
| 147 request->ctime = ctime_; | 147 request->ctime = ctime_; |
| 148 request->mtime = mtime_; | 148 request->mtime = mtime_; |
| 149 request->non_unique_name = non_unique_name_; | 149 request->non_unique_name = non_unique_name_; |
| 150 request->deleted = deleted_; | 150 request->deleted = deleted_; |
| 151 request->specifics.CopyFrom(specifics_); | 151 request->specifics.CopyFrom(specifics_); |
| 152 } | 152 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 166 encryption_key_name_ = encryption_key_name; | 166 encryption_key_name_ = encryption_key_name; |
| 167 } | 167 } |
| 168 | 168 |
| 169 void ModelTypeEntity::ClearTransientSyncState() { | 169 void ModelTypeEntity::ClearTransientSyncState() { |
| 170 // If we have any unacknowledged commit requests outstatnding, they've been | 170 // If we have any unacknowledged commit requests outstatnding, they've been |
| 171 // dropped and we should forget about them. | 171 // dropped and we should forget about them. |
| 172 commit_requested_sequence_number_ = acked_sequence_number_; | 172 commit_requested_sequence_number_ = acked_sequence_number_; |
| 173 } | 173 } |
| 174 | 174 |
| 175 void ModelTypeEntity::ClearSyncState() { | 175 void ModelTypeEntity::ClearSyncState() { |
| 176 base_version_ = syncer_v2::kUncommittedVersion; | 176 base_version_ = kUncommittedVersion; |
| 177 is_dirty_ = true; | 177 is_dirty_ = true; |
| 178 sequence_number_ = 1; | 178 sequence_number_ = 1; |
| 179 commit_requested_sequence_number_ = 0; | 179 commit_requested_sequence_number_ = 0; |
| 180 acked_sequence_number_ = 0; | 180 acked_sequence_number_ = 0; |
| 181 id_.clear(); | 181 id_.clear(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace syncer | 184 } // namespace syncer |
| OLD | NEW |