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

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

Issue 340055: String cleanup in sync code (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
11 #include "chrome/browser/sync/engine/conflict_resolver.h" 11 #include "chrome/browser/sync/engine/conflict_resolver.h"
12 #include "chrome/browser/sync/engine/syncer_proto_util.h" 12 #include "chrome/browser/sync/engine/syncer_proto_util.h"
13 #include "chrome/browser/sync/engine/syncer_types.h" 13 #include "chrome/browser/sync/engine/syncer_types.h"
14 #include "chrome/browser/sync/engine/syncproto.h" 14 #include "chrome/browser/sync/engine/syncproto.h"
15 #include "chrome/browser/sync/syncable/directory_manager.h" 15 #include "chrome/browser/sync/syncable/directory_manager.h"
16 #include "chrome/browser/sync/syncable/syncable.h" 16 #include "chrome/browser/sync/syncable/syncable.h"
17 #include "chrome/browser/sync/syncable/syncable_changes_version.h" 17 #include "chrome/browser/sync/syncable/syncable_changes_version.h"
18 #include "chrome/browser/sync/util/character_set_converters.h"
19 #include "chrome/browser/sync/util/path_helpers.h" 18 #include "chrome/browser/sync/util/path_helpers.h"
20 #include "chrome/browser/sync/util/sync_types.h" 19 #include "chrome/browser/sync/util/sync_types.h"
21 20
22 using syncable::BASE_VERSION; 21 using syncable::BASE_VERSION;
23 using syncable::BOOKMARK_FAVICON; 22 using syncable::BOOKMARK_FAVICON;
24 using syncable::BOOKMARK_URL; 23 using syncable::BOOKMARK_URL;
25 using syncable::Blob; 24 using syncable::Blob;
26 using syncable::CHANGES_VERSION; 25 using syncable::CHANGES_VERSION;
27 using syncable::CREATE; 26 using syncable::CREATE;
28 using syncable::CREATE_NEW_UPDATE_ITEM; 27 using syncable::CREATE_NEW_UPDATE_ITEM;
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 local_entry->Put(SERVER_PARENT_ID, server_entry.parent_id()); 321 local_entry->Put(SERVER_PARENT_ID, server_entry.parent_id());
323 local_entry->PutServerName(name); 322 local_entry->PutServerName(name);
324 local_entry->Put(SERVER_VERSION, server_entry.version()); 323 local_entry->Put(SERVER_VERSION, server_entry.version());
325 local_entry->Put(SERVER_CTIME, 324 local_entry->Put(SERVER_CTIME,
326 ServerTimeToClientTime(server_entry.ctime())); 325 ServerTimeToClientTime(server_entry.ctime()));
327 local_entry->Put(SERVER_MTIME, 326 local_entry->Put(SERVER_MTIME,
328 ServerTimeToClientTime(server_entry.mtime())); 327 ServerTimeToClientTime(server_entry.mtime()));
329 local_entry->Put(SERVER_IS_BOOKMARK_OBJECT, server_entry.has_bookmarkdata()); 328 local_entry->Put(SERVER_IS_BOOKMARK_OBJECT, server_entry.has_bookmarkdata());
330 local_entry->Put(SERVER_IS_DIR, server_entry.IsFolder()); 329 local_entry->Put(SERVER_IS_DIR, server_entry.IsFolder());
331 if (server_entry.has_singleton_tag()) { 330 if (server_entry.has_singleton_tag()) {
332 PathString tag; 331 const PathString& tag = server_entry.singleton_tag();
333 AppendUTF8ToPathString(server_entry.singleton_tag(), &tag);
334 local_entry->Put(SINGLETON_TAG, tag); 332 local_entry->Put(SINGLETON_TAG, tag);
335 } 333 }
336 if (server_entry.has_bookmarkdata() && !server_entry.deleted()) { 334 if (server_entry.has_bookmarkdata() && !server_entry.deleted()) {
337 const SyncEntity::BookmarkData& bookmark = server_entry.bookmarkdata(); 335 const SyncEntity::BookmarkData& bookmark = server_entry.bookmarkdata();
338 if (bookmark.has_bookmark_url()) { 336 if (bookmark.has_bookmark_url()) {
339 PathString url; 337 const PathString& url = bookmark.bookmark_url();
340 AppendUTF8ToPathString(bookmark.bookmark_url(), &url);
341 local_entry->Put(SERVER_BOOKMARK_URL, url); 338 local_entry->Put(SERVER_BOOKMARK_URL, url);
342 } 339 }
343 if (bookmark.has_bookmark_favicon()) { 340 if (bookmark.has_bookmark_favicon()) {
344 Blob favicon_blob; 341 Blob favicon_blob;
345 SyncerProtoUtil::CopyProtoBytesIntoBlob(bookmark.bookmark_favicon(), 342 SyncerProtoUtil::CopyProtoBytesIntoBlob(bookmark.bookmark_favicon(),
346 &favicon_blob); 343 &favicon_blob);
347 local_entry->Put(SERVER_BOOKMARK_FAVICON, favicon_blob); 344 local_entry->Put(SERVER_BOOKMARK_FAVICON, favicon_blob);
348 } 345 }
349 } 346 }
350 if (server_entry.has_position_in_parent()) { 347 if (server_entry.has_position_in_parent()) {
(...skipping 13 matching lines...) Expand all
364 361
365 // static 362 // static
366 void SyncerUtil::ApplyExtendedAttributes( 363 void SyncerUtil::ApplyExtendedAttributes(
367 syncable::MutableEntry* local_entry, 364 syncable::MutableEntry* local_entry,
368 const SyncEntity& server_entry) { 365 const SyncEntity& server_entry) {
369 local_entry->DeleteAllExtendedAttributes(local_entry->write_transaction()); 366 local_entry->DeleteAllExtendedAttributes(local_entry->write_transaction());
370 if (server_entry.has_extended_attributes()) { 367 if (server_entry.has_extended_attributes()) {
371 const sync_pb::ExtendedAttributes & extended_attributes = 368 const sync_pb::ExtendedAttributes & extended_attributes =
372 server_entry.extended_attributes(); 369 server_entry.extended_attributes();
373 for (int i = 0; i < extended_attributes.extendedattribute_size(); i++) { 370 for (int i = 0; i < extended_attributes.extendedattribute_size(); i++) {
374 PathString pathstring_key; 371 const PathString& pathstring_key =
375 AppendUTF8ToPathString( 372 extended_attributes.extendedattribute(i).key();
376 extended_attributes.extendedattribute(i).key(), &pathstring_key);
377 ExtendedAttributeKey key(local_entry->Get(META_HANDLE), pathstring_key); 373 ExtendedAttributeKey key(local_entry->Get(META_HANDLE), pathstring_key);
378 MutableExtendedAttribute local_attribute(local_entry->write_transaction(), 374 MutableExtendedAttribute local_attribute(local_entry->write_transaction(),
379 CREATE, key); 375 CREATE, key);
380 SyncerProtoUtil::CopyProtoBytesIntoBlob( 376 SyncerProtoUtil::CopyProtoBytesIntoBlob(
381 extended_attributes.extendedattribute(i).value(), 377 extended_attributes.extendedattribute(i).value(),
382 local_attribute.mutable_value()); 378 local_attribute.mutable_value());
383 } 379 }
384 } 380 }
385 } 381 }
386 382
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 825
830 // |update_entry| is considered to be somewhere after |candidate|, so store 826 // |update_entry| is considered to be somewhere after |candidate|, so store
831 // it as the upper bound. 827 // it as the upper bound.
832 closest_sibling = candidate.Get(ID); 828 closest_sibling = candidate.Get(ID);
833 } 829 }
834 830
835 return closest_sibling; 831 return closest_sibling;
836 } 832 }
837 833
838 } // namespace browser_sync 834 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncer_unittest.cc ('k') | chrome/browser/sync/engine/verify_updates_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698