Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: chrome/browser/sync/engine/syncer_util.cc

Issue 429003: Final part of PathString cleanup. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/syncer_util.h" 5 #include "chrome/browser/sync/engine/syncer_util.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 SyncerUtil::UpdateLocalDataFromServerData(trans, entry); 234 SyncerUtil::UpdateLocalDataFromServerData(trans, entry);
235 235
236 return SUCCESS; 236 return SUCCESS;
237 } 237 }
238 238
239 // Pass in name and checksum because of UTF8 conversion. 239 // Pass in name and checksum because of UTF8 conversion.
240 // static 240 // static
241 void SyncerUtil::UpdateServerFieldsFromUpdate( 241 void SyncerUtil::UpdateServerFieldsFromUpdate(
242 MutableEntry* local_entry, 242 MutableEntry* local_entry,
243 const SyncEntity& server_entry, 243 const SyncEntity& server_entry,
244 const PathString& name) { 244 const string& name) {
245 if (server_entry.deleted()) { 245 if (server_entry.deleted()) {
246 // The server returns very lightweight replies for deletions, so we don't 246 // The server returns very lightweight replies for deletions, so we don't
247 // clobber a bunch of fields on delete. 247 // clobber a bunch of fields on delete.
248 local_entry->Put(SERVER_IS_DEL, true); 248 local_entry->Put(SERVER_IS_DEL, true);
249 local_entry->Put(SERVER_VERSION, 249 local_entry->Put(SERVER_VERSION,
250 std::max(local_entry->Get(SERVER_VERSION), 250 std::max(local_entry->Get(SERVER_VERSION),
251 local_entry->Get(BASE_VERSION)) + 1L); 251 local_entry->Get(BASE_VERSION)) + 1L);
252 local_entry->Put(IS_UNAPPLIED_UPDATE, true); 252 local_entry->Put(IS_UNAPPLIED_UPDATE, true);
253 return; 253 return;
254 } 254 }
255 255
256 CHECK(local_entry->Get(ID) == server_entry.id()) 256 CHECK(local_entry->Get(ID) == server_entry.id())
257 << "ID Changing not supported here"; 257 << "ID Changing not supported here";
258 local_entry->Put(SERVER_PARENT_ID, server_entry.parent_id()); 258 local_entry->Put(SERVER_PARENT_ID, server_entry.parent_id());
259 local_entry->Put(SERVER_NON_UNIQUE_NAME, name); 259 local_entry->Put(SERVER_NON_UNIQUE_NAME, name);
260 local_entry->Put(SERVER_VERSION, server_entry.version()); 260 local_entry->Put(SERVER_VERSION, server_entry.version());
261 local_entry->Put(SERVER_CTIME, 261 local_entry->Put(SERVER_CTIME,
262 ServerTimeToClientTime(server_entry.ctime())); 262 ServerTimeToClientTime(server_entry.ctime()));
263 local_entry->Put(SERVER_MTIME, 263 local_entry->Put(SERVER_MTIME,
264 ServerTimeToClientTime(server_entry.mtime())); 264 ServerTimeToClientTime(server_entry.mtime()));
265 local_entry->Put(SERVER_IS_BOOKMARK_OBJECT, server_entry.has_bookmarkdata()); 265 local_entry->Put(SERVER_IS_BOOKMARK_OBJECT, server_entry.has_bookmarkdata());
266 local_entry->Put(SERVER_IS_DIR, server_entry.IsFolder()); 266 local_entry->Put(SERVER_IS_DIR, server_entry.IsFolder());
267 if (server_entry.has_singleton_tag()) { 267 if (server_entry.has_singleton_tag()) {
268 const PathString& tag = server_entry.singleton_tag(); 268 const string& tag = server_entry.singleton_tag();
269 local_entry->Put(SINGLETON_TAG, tag); 269 local_entry->Put(SINGLETON_TAG, tag);
270 } 270 }
271 if (server_entry.has_bookmarkdata() && !server_entry.deleted()) { 271 if (server_entry.has_bookmarkdata() && !server_entry.deleted()) {
272 const SyncEntity::BookmarkData& bookmark = server_entry.bookmarkdata(); 272 const SyncEntity::BookmarkData& bookmark = server_entry.bookmarkdata();
273 if (bookmark.has_bookmark_url()) { 273 if (bookmark.has_bookmark_url()) {
274 const PathString& url = bookmark.bookmark_url(); 274 const string& url = bookmark.bookmark_url();
275 local_entry->Put(SERVER_BOOKMARK_URL, url); 275 local_entry->Put(SERVER_BOOKMARK_URL, url);
276 } 276 }
277 if (bookmark.has_bookmark_favicon()) { 277 if (bookmark.has_bookmark_favicon()) {
278 Blob favicon_blob; 278 Blob favicon_blob;
279 SyncerProtoUtil::CopyProtoBytesIntoBlob(bookmark.bookmark_favicon(), 279 SyncerProtoUtil::CopyProtoBytesIntoBlob(bookmark.bookmark_favicon(),
280 &favicon_blob); 280 &favicon_blob);
281 local_entry->Put(SERVER_BOOKMARK_FAVICON, favicon_blob); 281 local_entry->Put(SERVER_BOOKMARK_FAVICON, favicon_blob);
282 } 282 }
283 } 283 }
284 if (server_entry.has_position_in_parent()) { 284 if (server_entry.has_position_in_parent()) {
(...skipping 13 matching lines...) Expand all
298 298
299 // static 299 // static
300 void SyncerUtil::ApplyExtendedAttributes( 300 void SyncerUtil::ApplyExtendedAttributes(
301 syncable::MutableEntry* local_entry, 301 syncable::MutableEntry* local_entry,
302 const SyncEntity& server_entry) { 302 const SyncEntity& server_entry) {
303 local_entry->DeleteAllExtendedAttributes(local_entry->write_transaction()); 303 local_entry->DeleteAllExtendedAttributes(local_entry->write_transaction());
304 if (server_entry.has_extended_attributes()) { 304 if (server_entry.has_extended_attributes()) {
305 const sync_pb::ExtendedAttributes & extended_attributes = 305 const sync_pb::ExtendedAttributes & extended_attributes =
306 server_entry.extended_attributes(); 306 server_entry.extended_attributes();
307 for (int i = 0; i < extended_attributes.extendedattribute_size(); i++) { 307 for (int i = 0; i < extended_attributes.extendedattribute_size(); i++) {
308 const PathString& pathstring_key = 308 const string& string_key =
309 extended_attributes.extendedattribute(i).key(); 309 extended_attributes.extendedattribute(i).key();
310 ExtendedAttributeKey key(local_entry->Get(META_HANDLE), pathstring_key); 310 ExtendedAttributeKey key(local_entry->Get(META_HANDLE), string_key);
311 MutableExtendedAttribute local_attribute(local_entry->write_transaction(), 311 MutableExtendedAttribute local_attribute(local_entry->write_transaction(),
312 CREATE, key); 312 CREATE, key);
313 SyncerProtoUtil::CopyProtoBytesIntoBlob( 313 SyncerProtoUtil::CopyProtoBytesIntoBlob(
314 extended_attributes.extendedattribute(i).value(), 314 extended_attributes.extendedattribute(i).value(),
315 local_attribute.mutable_value()); 315 local_attribute.mutable_value());
316 } 316 }
317 } 317 }
318 } 318 }
319 319
320 // Creates a new Entry iff no Entry exists with the given id. 320 // Creates a new Entry iff no Entry exists with the given id.
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 743
744 // |update_entry| is considered to be somewhere after |candidate|, so store 744 // |update_entry| is considered to be somewhere after |candidate|, so store
745 // it as the upper bound. 745 // it as the upper bound.
746 closest_sibling = candidate.Get(ID); 746 closest_sibling = candidate.Get(ID);
747 } 747 }
748 748
749 return closest_sibling; 749 return closest_sibling;
750 } 750 }
751 751
752 } // namespace browser_sync 752 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncer_util.h ('k') | chrome/browser/sync/protocol/service_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698