OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "chrome/browser/sync/engine/build_commit_command.h" | 5 #include "chrome/browser/sync/engine/build_commit_command.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "chrome/browser/sync/engine/syncer_proto_util.h" | 11 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
12 #include "chrome/browser/sync/engine/syncer_util.h" | 12 #include "chrome/browser/sync/engine/syncer_util.h" |
13 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" | 13 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" |
14 #include "chrome/browser/sync/sessions/sync_session.h" | 14 #include "chrome/browser/sync/sessions/sync_session.h" |
15 #include "chrome/browser/sync/syncable/syncable.h" | 15 #include "chrome/browser/sync/syncable/syncable.h" |
16 #include "chrome/browser/sync/syncable/syncable_changes_version.h" | 16 #include "chrome/browser/sync/syncable/syncable_changes_version.h" |
17 #include "chrome/browser/sync/util/sync_types.h" | 17 #include "chrome/browser/sync/util/sync_types.h" |
18 | 18 |
19 using std::set; | 19 using std::set; |
20 using std::string; | 20 using std::string; |
21 using std::vector; | 21 using std::vector; |
22 using syncable::ExtendedAttribute; | |
23 using syncable::IS_DEL; | 22 using syncable::IS_DEL; |
24 using syncable::Id; | 23 using syncable::Id; |
25 using syncable::MutableEntry; | 24 using syncable::MutableEntry; |
26 using syncable::SPECIFICS; | 25 using syncable::SPECIFICS; |
27 using syncable::UNSPECIFIED; | 26 using syncable::UNSPECIFIED; |
28 | 27 |
29 namespace browser_sync { | 28 namespace browser_sync { |
30 | 29 |
31 using sessions::SyncSession; | 30 using sessions::SyncSession; |
32 | 31 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 sync_entry->set_version(0); | 155 sync_entry->set_version(0); |
157 } else { | 156 } else { |
158 CHECK(id.ServerKnows()) << meta_entry; | 157 CHECK(id.ServerKnows()) << meta_entry; |
159 sync_entry->set_version(meta_entry.Get(syncable::BASE_VERSION)); | 158 sync_entry->set_version(meta_entry.Get(syncable::BASE_VERSION)); |
160 } | 159 } |
161 sync_entry->set_ctime(ClientTimeToServerTime( | 160 sync_entry->set_ctime(ClientTimeToServerTime( |
162 meta_entry.Get(syncable::CTIME))); | 161 meta_entry.Get(syncable::CTIME))); |
163 sync_entry->set_mtime(ClientTimeToServerTime( | 162 sync_entry->set_mtime(ClientTimeToServerTime( |
164 meta_entry.Get(syncable::MTIME))); | 163 meta_entry.Get(syncable::MTIME))); |
165 | 164 |
166 set<ExtendedAttribute> extended_attributes; | |
167 meta_entry.GetAllExtendedAttributes( | |
168 session->write_transaction(), &extended_attributes); | |
169 set<ExtendedAttribute>::iterator iter; | |
170 sync_pb::ExtendedAttributes* mutable_extended_attributes = | |
171 sync_entry->mutable_extended_attributes(); | |
172 for (iter = extended_attributes.begin(); iter != extended_attributes.end(); | |
173 ++iter) { | |
174 sync_pb::ExtendedAttributes_ExtendedAttribute *extended_attribute = | |
175 mutable_extended_attributes->add_extendedattribute(); | |
176 extended_attribute->set_key(iter->key()); | |
177 SyncerProtoUtil::CopyBlobIntoProtoBytes(iter->value(), | |
178 extended_attribute->mutable_value()); | |
179 } | |
180 | |
181 // Deletion is final on the server, let's move things and then delete them. | 165 // Deletion is final on the server, let's move things and then delete them. |
182 if (meta_entry.Get(IS_DEL)) { | 166 if (meta_entry.Get(IS_DEL)) { |
183 sync_entry->set_deleted(true); | 167 sync_entry->set_deleted(true); |
184 } else { | 168 } else { |
185 if (meta_entry.Get(SPECIFICS).HasExtension(sync_pb::bookmark)) { | 169 if (meta_entry.Get(SPECIFICS).HasExtension(sync_pb::bookmark)) { |
186 // Common data in both new and old protocol. | 170 // Common data in both new and old protocol. |
187 const Id& prev_id = meta_entry.Get(syncable::PREV_ID); | 171 const Id& prev_id = meta_entry.Get(syncable::PREV_ID); |
188 string prev_id_string = | 172 string prev_id_string = |
189 prev_id.IsRoot() ? string() : prev_id.GetServerId(); | 173 prev_id.IsRoot() ? string() : prev_id.GetServerId(); |
190 sync_entry->set_insert_after_item_id(prev_id_string); | 174 sync_entry->set_insert_after_item_id(prev_id_string); |
191 | 175 |
192 // TODO(ncarter): In practice we won't want to send this data twice | 176 // TODO(ncarter): In practice we won't want to send this data twice |
193 // over the wire; instead, when deployed servers are able to accept | 177 // over the wire; instead, when deployed servers are able to accept |
194 // the new-style scheme, we should abandon the old way. | 178 // the new-style scheme, we should abandon the old way. |
195 SetOldStyleBookmarkData(&meta_entry, sync_entry); | 179 SetOldStyleBookmarkData(&meta_entry, sync_entry); |
196 } | 180 } |
197 SetEntrySpecifics(&meta_entry, sync_entry); | 181 SetEntrySpecifics(&meta_entry, sync_entry); |
198 } | 182 } |
199 } | 183 } |
200 session->status_controller()->mutable_commit_message()->CopyFrom(message); | 184 session->status_controller()->mutable_commit_message()->CopyFrom(message); |
201 } | 185 } |
202 | 186 |
203 } // namespace browser_sync | 187 } // namespace browser_sync |
OLD | NEW |