| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/api/sync_data.h" | 5 #include "sync/api/sync_data.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include <algorithm> | 9 #include <algorithm> |
| 8 #include <ostream> | 10 #include <ostream> |
| 9 | 11 |
| 10 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 11 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/values.h" | 15 #include "base/values.h" |
| 14 #include "sync/internal_api/public/attachments/attachment_service_proxy.h" | 16 #include "sync/internal_api/public/attachments/attachment_service_proxy.h" |
| 15 #include "sync/internal_api/public/base/model_type.h" | 17 #include "sync/internal_api/public/base/model_type.h" |
| 16 #include "sync/internal_api/public/base_node.h" | 18 #include "sync/internal_api/public/base_node.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 return *wrapper; | 60 return *wrapper; |
| 59 } | 61 } |
| 60 | 62 |
| 61 void SyncData::ImmutableSyncEntityTraits::Swap(sync_pb::SyncEntity* t1, | 63 void SyncData::ImmutableSyncEntityTraits::Swap(sync_pb::SyncEntity* t1, |
| 62 sync_pb::SyncEntity* t2) { | 64 sync_pb::SyncEntity* t2) { |
| 63 t1->Swap(t2); | 65 t1->Swap(t2); |
| 64 } | 66 } |
| 65 | 67 |
| 66 SyncData::SyncData() : id_(kInvalidId), is_valid_(false) {} | 68 SyncData::SyncData() : id_(kInvalidId), is_valid_(false) {} |
| 67 | 69 |
| 68 SyncData::SyncData(int64 id, | 70 SyncData::SyncData(int64_t id, |
| 69 sync_pb::SyncEntity* entity, | 71 sync_pb::SyncEntity* entity, |
| 70 const base::Time& remote_modification_time, | 72 const base::Time& remote_modification_time, |
| 71 const syncer::AttachmentServiceProxy& attachment_service) | 73 const syncer::AttachmentServiceProxy& attachment_service) |
| 72 : id_(id), | 74 : id_(id), |
| 73 remote_modification_time_(remote_modification_time), | 75 remote_modification_time_(remote_modification_time), |
| 74 immutable_entity_(entity), | 76 immutable_entity_(entity), |
| 75 attachment_service_(attachment_service), | 77 attachment_service_(attachment_service), |
| 76 is_valid_(true) {} | 78 is_valid_(true) {} |
| 77 | 79 |
| 78 SyncData::~SyncData() {} | 80 SyncData::~SyncData() {} |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 RepeatedFieldBackInserter(entity.mutable_attachment_id()), | 112 RepeatedFieldBackInserter(entity.mutable_attachment_id()), |
| 111 IdToProto); | 113 IdToProto); |
| 112 return SyncData(kInvalidId, | 114 return SyncData(kInvalidId, |
| 113 &entity, | 115 &entity, |
| 114 base::Time(), | 116 base::Time(), |
| 115 AttachmentServiceProxy()); | 117 AttachmentServiceProxy()); |
| 116 } | 118 } |
| 117 | 119 |
| 118 // Static. | 120 // Static. |
| 119 SyncData SyncData::CreateRemoteData( | 121 SyncData SyncData::CreateRemoteData( |
| 120 int64 id, | 122 int64_t id, |
| 121 const sync_pb::EntitySpecifics& specifics, | 123 const sync_pb::EntitySpecifics& specifics, |
| 122 const base::Time& modification_time, | 124 const base::Time& modification_time, |
| 123 const AttachmentIdList& attachment_ids, | 125 const AttachmentIdList& attachment_ids, |
| 124 const AttachmentServiceProxy& attachment_service) { | 126 const AttachmentServiceProxy& attachment_service) { |
| 125 DCHECK_NE(id, kInvalidId); | 127 DCHECK_NE(id, kInvalidId); |
| 126 sync_pb::SyncEntity entity; | 128 sync_pb::SyncEntity entity; |
| 127 entity.mutable_specifics()->CopyFrom(specifics); | 129 entity.mutable_specifics()->CopyFrom(specifics); |
| 128 std::transform(attachment_ids.begin(), | 130 std::transform(attachment_ids.begin(), |
| 129 attachment_ids.end(), | 131 attachment_ids.end(), |
| 130 RepeatedFieldBackInserter(entity.mutable_attachment_id()), | 132 RepeatedFieldBackInserter(entity.mutable_attachment_id()), |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 : SyncData(sync_data) { | 203 : SyncData(sync_data) { |
| 202 DCHECK(!sync_data.IsLocal()); | 204 DCHECK(!sync_data.IsLocal()); |
| 203 } | 205 } |
| 204 | 206 |
| 205 SyncDataRemote::~SyncDataRemote() {} | 207 SyncDataRemote::~SyncDataRemote() {} |
| 206 | 208 |
| 207 const base::Time& SyncDataRemote::GetModifiedTime() const { | 209 const base::Time& SyncDataRemote::GetModifiedTime() const { |
| 208 return remote_modification_time_; | 210 return remote_modification_time_; |
| 209 } | 211 } |
| 210 | 212 |
| 211 int64 SyncDataRemote::GetId() const { | 213 int64_t SyncDataRemote::GetId() const { |
| 212 return id_; | 214 return id_; |
| 213 } | 215 } |
| 214 | 216 |
| 215 void SyncDataRemote::GetOrDownloadAttachments( | 217 void SyncDataRemote::GetOrDownloadAttachments( |
| 216 const AttachmentIdList& attachment_ids, | 218 const AttachmentIdList& attachment_ids, |
| 217 const AttachmentService::GetOrDownloadCallback& callback) { | 219 const AttachmentService::GetOrDownloadCallback& callback) { |
| 218 attachment_service_.GetOrDownloadAttachments(attachment_ids, callback); | 220 attachment_service_.GetOrDownloadAttachments(attachment_ids, callback); |
| 219 } | 221 } |
| 220 | 222 |
| 221 } // namespace syncer | 223 } // namespace syncer |
| OLD | NEW |