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 "components/sync_driver/generic_change_processor.h" | 5 #include "components/sync_driver/generic_change_processor.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 |
7 #include <algorithm> | 9 #include <algorithm> |
8 #include <string> | 10 #include <string> |
9 | 11 |
10 #include "base/location.h" | 12 #include "base/location.h" |
11 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
13 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
14 #include "components/sync_driver/sync_api_component_factory.h" | 16 #include "components/sync_driver/sync_api_component_factory.h" |
15 #include "components/sync_driver/sync_client.h" | 17 #include "components/sync_driver/sync_client.h" |
16 #include "sync/api/sync_change.h" | 18 #include "sync/api/sync_change.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 sync_pb::AttachmentMetadata attachment_metadata; | 59 sync_pb::AttachmentMetadata attachment_metadata; |
58 std::transform( | 60 std::transform( |
59 attachment_ids.begin(), | 61 attachment_ids.begin(), |
60 attachment_ids.end(), | 62 attachment_ids.end(), |
61 RepeatedFieldBackInserter(attachment_metadata.mutable_record()), | 63 RepeatedFieldBackInserter(attachment_metadata.mutable_record()), |
62 AttachmentIdToRecord); | 64 AttachmentIdToRecord); |
63 write_node->SetAttachmentMetadata(attachment_metadata); | 65 write_node->SetAttachmentMetadata(attachment_metadata); |
64 } | 66 } |
65 | 67 |
66 syncer::SyncData BuildRemoteSyncData( | 68 syncer::SyncData BuildRemoteSyncData( |
67 int64 sync_id, | 69 int64_t sync_id, |
68 const syncer::BaseNode& read_node, | 70 const syncer::BaseNode& read_node, |
69 const syncer::AttachmentServiceProxy& attachment_service_proxy) { | 71 const syncer::AttachmentServiceProxy& attachment_service_proxy) { |
70 const syncer::AttachmentIdList& attachment_ids = read_node.GetAttachmentIds(); | 72 const syncer::AttachmentIdList& attachment_ids = read_node.GetAttachmentIds(); |
71 // Use the specifics of non-password datatypes directly (encryption has | 73 // Use the specifics of non-password datatypes directly (encryption has |
72 // already been handled). | 74 // already been handled). |
73 if (read_node.GetModelType() != syncer::PASSWORDS) { | 75 if (read_node.GetModelType() != syncer::PASSWORDS) { |
74 return syncer::SyncData::CreateRemoteData(sync_id, | 76 return syncer::SyncData::CreateRemoteData(sync_id, |
75 read_node.GetEntitySpecifics(), | 77 read_node.GetEntitySpecifics(), |
76 read_node.GetModificationTime(), | 78 read_node.GetModificationTime(), |
77 attachment_ids, | 79 attachment_ids, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 base::WeakPtr<syncer::AttachmentService>()); | 132 base::WeakPtr<syncer::AttachmentService>()); |
131 } | 133 } |
132 } | 134 } |
133 | 135 |
134 GenericChangeProcessor::~GenericChangeProcessor() { | 136 GenericChangeProcessor::~GenericChangeProcessor() { |
135 DCHECK(CalledOnValidThread()); | 137 DCHECK(CalledOnValidThread()); |
136 } | 138 } |
137 | 139 |
138 void GenericChangeProcessor::ApplyChangesFromSyncModel( | 140 void GenericChangeProcessor::ApplyChangesFromSyncModel( |
139 const syncer::BaseTransaction* trans, | 141 const syncer::BaseTransaction* trans, |
140 int64 model_version, | 142 int64_t model_version, |
141 const syncer::ImmutableChangeRecordList& changes) { | 143 const syncer::ImmutableChangeRecordList& changes) { |
142 DCHECK(CalledOnValidThread()); | 144 DCHECK(CalledOnValidThread()); |
143 DCHECK(syncer_changes_.empty()); | 145 DCHECK(syncer_changes_.empty()); |
144 for (syncer::ChangeRecordList::const_iterator it = | 146 for (syncer::ChangeRecordList::const_iterator it = |
145 changes.Get().begin(); it != changes.Get().end(); ++it) { | 147 changes.Get().begin(); it != changes.Get().end(); ++it) { |
146 if (it->action == syncer::ChangeRecord::ACTION_DELETE) { | 148 if (it->action == syncer::ChangeRecord::ACTION_DELETE) { |
147 scoped_ptr<sync_pb::EntitySpecifics> specifics; | 149 scoped_ptr<sync_pb::EntitySpecifics> specifics; |
148 if (it->specifics.has_password()) { | 150 if (it->specifics.has_password()) { |
149 DCHECK(it->extra.get()); | 151 DCHECK(it->extra.get()); |
150 specifics.reset(new sync_pb::EntitySpecifics(it->specifics)); | 152 specifics.reset(new sync_pb::EntitySpecifics(it->specifics)); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 "Server did not create the top-level " + type_name + | 252 "Server did not create the top-level " + type_name + |
251 " node. We might be running against an out-of-" | 253 " node. We might be running against an out-of-" |
252 "date server.", | 254 "date server.", |
253 type_); | 255 type_); |
254 return error; | 256 return error; |
255 } | 257 } |
256 | 258 |
257 // TODO(akalin): We'll have to do a tree traversal for bookmarks. | 259 // TODO(akalin): We'll have to do a tree traversal for bookmarks. |
258 DCHECK_NE(type_, syncer::BOOKMARKS); | 260 DCHECK_NE(type_, syncer::BOOKMARKS); |
259 | 261 |
260 std::vector<int64> child_ids; | 262 std::vector<int64_t> child_ids; |
261 root.GetChildIds(&child_ids); | 263 root.GetChildIds(&child_ids); |
262 | 264 |
263 for (std::vector<int64>::iterator it = child_ids.begin(); | 265 for (std::vector<int64_t>::iterator it = child_ids.begin(); |
264 it != child_ids.end(); ++it) { | 266 it != child_ids.end(); ++it) { |
265 syncer::ReadNode sync_child_node(&trans); | 267 syncer::ReadNode sync_child_node(&trans); |
266 if (sync_child_node.InitByIdLookup(*it) != | 268 if (sync_child_node.InitByIdLookup(*it) != |
267 syncer::BaseNode::INIT_OK) { | 269 syncer::BaseNode::INIT_OK) { |
268 syncer::SyncError error( | 270 syncer::SyncError error( |
269 FROM_HERE, | 271 FROM_HERE, |
270 syncer::SyncError::DATATYPE_ERROR, | 272 syncer::SyncError::DATATYPE_ERROR, |
271 "Failed to fetch child node for type " + type_name + ".", | 273 "Failed to fetch child node for type " + type_name + ".", |
272 type_); | 274 type_); |
273 return error; | 275 return error; |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 } | 711 } |
710 } | 712 } |
711 | 713 |
712 scoped_ptr<syncer::AttachmentService> | 714 scoped_ptr<syncer::AttachmentService> |
713 GenericChangeProcessor::GetAttachmentService() const { | 715 GenericChangeProcessor::GetAttachmentService() const { |
714 return scoped_ptr<syncer::AttachmentService>( | 716 return scoped_ptr<syncer::AttachmentService>( |
715 new syncer::AttachmentServiceProxy(attachment_service_proxy_)); | 717 new syncer::AttachmentServiceProxy(attachment_service_proxy_)); |
716 } | 718 } |
717 | 719 |
718 } // namespace sync_driver | 720 } // namespace sync_driver |
OLD | NEW |