| OLD | NEW |
| 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 "components/sync/engine_impl/syncer_util.h" | 5 #include "components/sync/engine_impl/syncer_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "components/sync/base/attachment_id_proto.h" | 14 #include "components/sync/base/attachment_id_proto.h" |
| 15 #include "components/sync/base/cryptographer.h" | 15 #include "components/sync/base/cryptographer.h" |
| 16 #include "components/sync/base/hash_util.h" |
| 16 #include "components/sync/base/model_type.h" | 17 #include "components/sync/base/model_type.h" |
| 17 #include "components/sync/base/time.h" | 18 #include "components/sync/base/time.h" |
| 18 #include "components/sync/base/unique_position.h" | 19 #include "components/sync/base/unique_position.h" |
| 19 #include "components/sync/engine_impl/conflict_resolver.h" | 20 #include "components/sync/engine_impl/conflict_resolver.h" |
| 20 #include "components/sync/engine_impl/syncer_proto_util.h" | 21 #include "components/sync/engine_impl/syncer_proto_util.h" |
| 21 #include "components/sync/protocol/bookmark_specifics.pb.h" | 22 #include "components/sync/protocol/bookmark_specifics.pb.h" |
| 22 #include "components/sync/protocol/password_specifics.pb.h" | 23 #include "components/sync/protocol/password_specifics.pb.h" |
| 23 #include "components/sync/protocol/sync.pb.h" | 24 #include "components/sync/protocol/sync.pb.h" |
| 24 #include "components/sync/syncable/directory.h" | 25 #include "components/sync/syncable/directory.h" |
| 25 #include "components/sync/syncable/entry.h" | 26 #include "components/sync/syncable/entry.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 } | 267 } |
| 267 | 268 |
| 268 std::string GetUniqueBookmarkTagFromUpdate(const sync_pb::SyncEntity& update) { | 269 std::string GetUniqueBookmarkTagFromUpdate(const sync_pb::SyncEntity& update) { |
| 269 if (!update.has_originator_cache_guid() || | 270 if (!update.has_originator_cache_guid() || |
| 270 !update.has_originator_client_item_id()) { | 271 !update.has_originator_client_item_id()) { |
| 271 LOG(ERROR) << "Update is missing requirements for bookmark position." | 272 LOG(ERROR) << "Update is missing requirements for bookmark position." |
| 272 << " This is a server bug."; | 273 << " This is a server bug."; |
| 273 return UniquePosition::RandomSuffix(); | 274 return UniquePosition::RandomSuffix(); |
| 274 } | 275 } |
| 275 | 276 |
| 276 return syncable::GenerateSyncableBookmarkHash( | 277 return GenerateSyncableBookmarkHash(update.originator_cache_guid(), |
| 277 update.originator_cache_guid(), update.originator_client_item_id()); | 278 update.originator_client_item_id()); |
| 278 } | 279 } |
| 279 | 280 |
| 280 UniquePosition GetUpdatePosition(const sync_pb::SyncEntity& update, | 281 UniquePosition GetUpdatePosition(const sync_pb::SyncEntity& update, |
| 281 const std::string& suffix) { | 282 const std::string& suffix) { |
| 282 DCHECK(UniquePosition::IsValidSuffix(suffix)); | 283 DCHECK(UniquePosition::IsValidSuffix(suffix)); |
| 283 if (!(SyncerProtoUtil::ShouldMaintainPosition(update))) { | 284 if (!(SyncerProtoUtil::ShouldMaintainPosition(update))) { |
| 284 return UniquePosition::CreateInvalid(); | 285 return UniquePosition::CreateInvalid(); |
| 285 } else if (update.has_unique_position()) { | 286 } else if (update.has_unique_position()) { |
| 286 UniquePosition proto_position = | 287 UniquePosition proto_position = |
| 287 UniquePosition::FromProto(update.unique_position()); | 288 UniquePosition::FromProto(update.unique_position()); |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 if (update.version() < target->GetServerVersion()) { | 642 if (update.version() < target->GetServerVersion()) { |
| 642 LOG(WARNING) << "Update older than current server version for " << *target | 643 LOG(WARNING) << "Update older than current server version for " << *target |
| 643 << " Update:" | 644 << " Update:" |
| 644 << SyncerProtoUtil::SyncEntityDebugString(update); | 645 << SyncerProtoUtil::SyncEntityDebugString(update); |
| 645 return VERIFY_SUCCESS; // Expected in new sync protocol. | 646 return VERIFY_SUCCESS; // Expected in new sync protocol. |
| 646 } | 647 } |
| 647 return VERIFY_UNDECIDED; | 648 return VERIFY_UNDECIDED; |
| 648 } | 649 } |
| 649 | 650 |
| 650 } // namespace syncer | 651 } // namespace syncer |
| OLD | NEW |