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

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

Issue 393083004: Update Commit and GetUpdatesResponse messages to include attachment ids. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update SyncManagerImpl to detect attachment metadata changes. Created 6 years, 5 months 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
« no previous file with comments | « sync/engine/get_commit_ids.cc ('k') | sync/internal_api/public/base/attachment_id_proto.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/engine/syncer_util.h" 5 #include "sync/engine/syncer_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/base64.h" 12 #include "base/base64.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/rand_util.h" 15 #include "base/rand_util.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "sync/engine/conflict_resolver.h" 17 #include "sync/engine/conflict_resolver.h"
18 #include "sync/engine/syncer_proto_util.h" 18 #include "sync/engine/syncer_proto_util.h"
19 #include "sync/engine/syncer_types.h" 19 #include "sync/engine/syncer_types.h"
20 #include "sync/internal_api/public/base/attachment_id_proto.h"
20 #include "sync/internal_api/public/base/model_type.h" 21 #include "sync/internal_api/public/base/model_type.h"
21 #include "sync/internal_api/public/base/unique_position.h" 22 #include "sync/internal_api/public/base/unique_position.h"
22 #include "sync/protocol/bookmark_specifics.pb.h" 23 #include "sync/protocol/bookmark_specifics.pb.h"
23 #include "sync/protocol/password_specifics.pb.h" 24 #include "sync/protocol/password_specifics.pb.h"
24 #include "sync/protocol/sync.pb.h" 25 #include "sync/protocol/sync.pb.h"
25 #include "sync/syncable/directory.h" 26 #include "sync/syncable/directory.h"
26 #include "sync/syncable/entry.h" 27 #include "sync/syncable/entry.h"
27 #include "sync/syncable/model_neutral_mutable_entry.h" 28 #include "sync/syncable/model_neutral_mutable_entry.h"
28 #include "sync/syncable/mutable_entry.h" 29 #include "sync/syncable/mutable_entry.h"
29 #include "sync/syncable/syncable_changes_version.h" 30 #include "sync/syncable/syncable_changes_version.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 << "Storing unrecognized datatype in sync database."; 401 << "Storing unrecognized datatype in sync database.";
401 target->PutServerSpecifics(update.specifics()); 402 target->PutServerSpecifics(update.specifics());
402 } else if (update.has_bookmarkdata()) { 403 } else if (update.has_bookmarkdata()) {
403 // Legacy protocol response for bookmark data. 404 // Legacy protocol response for bookmark data.
404 const sync_pb::SyncEntity::BookmarkData& bookmark = update.bookmarkdata(); 405 const sync_pb::SyncEntity::BookmarkData& bookmark = update.bookmarkdata();
405 UpdateBookmarkSpecifics(update.server_defined_unique_tag(), 406 UpdateBookmarkSpecifics(update.server_defined_unique_tag(),
406 bookmark.bookmark_url(), 407 bookmark.bookmark_url(),
407 bookmark.bookmark_favicon(), 408 bookmark.bookmark_favicon(),
408 target); 409 target);
409 } 410 }
411 target->PutServerAttachmentMetadata(
412 CreateAttachmentMetadata(update.attachment_id()));
410 if (SyncerProtoUtil::ShouldMaintainPosition(update)) { 413 if (SyncerProtoUtil::ShouldMaintainPosition(update)) {
411 UpdateBookmarkPositioning(update, target); 414 UpdateBookmarkPositioning(update, target);
412 } 415 }
413 416
414 target->PutServerIsDel(update.deleted()); 417 target->PutServerIsDel(update.deleted());
415 // We only mark the entry as unapplied if its version is greater than the 418 // We only mark the entry as unapplied if its version is greater than the
416 // local data. If we're processing the update that corresponds to one of our 419 // local data. If we're processing the update that corresponds to one of our
417 // commit we don't apply it as time differences may occur. 420 // commit we don't apply it as time differences may occur.
418 if (update.version() > target->GetBaseVersion()) { 421 if (update.version() > target->GetBaseVersion()) {
419 target->PutIsUnappliedUpdate(true); 422 target->PutIsUnappliedUpdate(true);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 entry->PutParentId(entry->GetServerParentId()); 459 entry->PutParentId(entry->GetServerParentId());
457 entry->PutUniquePosition(entry->GetServerUniquePosition()); 460 entry->PutUniquePosition(entry->GetServerUniquePosition());
458 entry->PutIsDel(false); 461 entry->PutIsDel(false);
459 } 462 }
460 463
461 entry->PutCtime(entry->GetServerCtime()); 464 entry->PutCtime(entry->GetServerCtime());
462 entry->PutMtime(entry->GetServerMtime()); 465 entry->PutMtime(entry->GetServerMtime());
463 entry->PutBaseVersion(entry->GetServerVersion()); 466 entry->PutBaseVersion(entry->GetServerVersion());
464 entry->PutIsDel(entry->GetServerIsDel()); 467 entry->PutIsDel(entry->GetServerIsDel());
465 entry->PutIsUnappliedUpdate(false); 468 entry->PutIsUnappliedUpdate(false);
469 entry->PutAttachmentMetadata(entry->GetServerAttachmentMetadata());
466 } 470 }
467 471
468 VerifyCommitResult ValidateCommitEntry(syncable::Entry* entry) { 472 VerifyCommitResult ValidateCommitEntry(syncable::Entry* entry) {
469 syncable::Id id = entry->GetId(); 473 syncable::Id id = entry->GetId();
470 if (id == entry->GetParentId()) { 474 if (id == entry->GetParentId()) {
471 CHECK(id.IsRoot()) << "Non-root item is self parenting." << *entry; 475 CHECK(id.IsRoot()) << "Non-root item is self parenting." << *entry;
472 // If the root becomes unsynced it can cause us problems. 476 // If the root becomes unsynced it can cause us problems.
473 LOG(ERROR) << "Root item became unsynced " << *entry; 477 LOG(ERROR) << "Root item became unsynced " << *entry;
474 return VERIFY_UNSYNCABLE; 478 return VERIFY_UNSYNCABLE;
475 } 479 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 if (update.version() < target->GetServerVersion()) { 645 if (update.version() < target->GetServerVersion()) {
642 LOG(WARNING) << "Update older than current server version for " 646 LOG(WARNING) << "Update older than current server version for "
643 << *target << " Update:" 647 << *target << " Update:"
644 << SyncerProtoUtil::SyncEntityDebugString(update); 648 << SyncerProtoUtil::SyncEntityDebugString(update);
645 return VERIFY_SUCCESS; // Expected in new sync protocol. 649 return VERIFY_SUCCESS; // Expected in new sync protocol.
646 } 650 }
647 return VERIFY_UNDECIDED; 651 return VERIFY_UNDECIDED;
648 } 652 }
649 653
650 } // namespace syncer 654 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/get_commit_ids.cc ('k') | sync/internal_api/public/base/attachment_id_proto.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698