| Index: components/sync/engine_impl/syncer_util.cc
|
| diff --git a/sync/engine/syncer_util.cc b/components/sync/engine_impl/syncer_util.cc
|
| similarity index 90%
|
| rename from sync/engine/syncer_util.cc
|
| rename to components/sync/engine_impl/syncer_util.cc
|
| index bb0588505f39d2ad4cbbff37bb7ac386d312a50a..d19249091d0c836431fde27084da0e2848660468 100644
|
| --- a/sync/engine/syncer_util.cc
|
| +++ b/components/sync/engine_impl/syncer_util.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "sync/engine/syncer_util.h"
|
| +#include "components/sync/engine_impl/syncer_util.h"
|
|
|
| #include <stdint.h>
|
|
|
| @@ -16,27 +16,27 @@
|
| #include "base/metrics/histogram.h"
|
| #include "base/rand_util.h"
|
| #include "base/strings/string_number_conversions.h"
|
| -#include "sync/engine/conflict_resolver.h"
|
| -#include "sync/engine/syncer_proto_util.h"
|
| -#include "sync/engine/syncer_types.h"
|
| -#include "sync/internal_api/public/base/attachment_id_proto.h"
|
| -#include "sync/internal_api/public/base/model_type.h"
|
| -#include "sync/internal_api/public/base/unique_position.h"
|
| -#include "sync/protocol/bookmark_specifics.pb.h"
|
| -#include "sync/protocol/password_specifics.pb.h"
|
| -#include "sync/protocol/sync.pb.h"
|
| -#include "sync/syncable/directory.h"
|
| -#include "sync/syncable/entry.h"
|
| -#include "sync/syncable/model_neutral_mutable_entry.h"
|
| -#include "sync/syncable/mutable_entry.h"
|
| -#include "sync/syncable/syncable_changes_version.h"
|
| -#include "sync/syncable/syncable_model_neutral_write_transaction.h"
|
| -#include "sync/syncable/syncable_proto_util.h"
|
| -#include "sync/syncable/syncable_read_transaction.h"
|
| -#include "sync/syncable/syncable_util.h"
|
| -#include "sync/syncable/syncable_write_transaction.h"
|
| -#include "sync/util/cryptographer.h"
|
| -#include "sync/util/time.h"
|
| +#include "components/sync/base/attachment_id_proto.h"
|
| +#include "components/sync/base/cryptographer.h"
|
| +#include "components/sync/base/model_type.h"
|
| +#include "components/sync/base/time.h"
|
| +#include "components/sync/base/unique_position.h"
|
| +#include "components/sync/engine_impl/conflict_resolver.h"
|
| +#include "components/sync/engine_impl/syncer_proto_util.h"
|
| +#include "components/sync/engine_impl/syncer_types.h"
|
| +#include "components/sync/protocol/bookmark_specifics.pb.h"
|
| +#include "components/sync/protocol/password_specifics.pb.h"
|
| +#include "components/sync/protocol/sync.pb.h"
|
| +#include "components/sync/syncable/directory.h"
|
| +#include "components/sync/syncable/entry.h"
|
| +#include "components/sync/syncable/model_neutral_mutable_entry.h"
|
| +#include "components/sync/syncable/mutable_entry.h"
|
| +#include "components/sync/syncable/syncable_changes_version.h"
|
| +#include "components/sync/syncable/syncable_model_neutral_write_transaction.h"
|
| +#include "components/sync/syncable/syncable_proto_util.h"
|
| +#include "components/sync/syncable/syncable_read_transaction.h"
|
| +#include "components/sync/syncable/syncable_util.h"
|
| +#include "components/sync/syncable/syncable_write_transaction.h"
|
|
|
| namespace syncer {
|
|
|
| @@ -48,9 +48,8 @@ using syncable::GET_BY_ID;
|
| using syncable::ID;
|
| using syncable::Id;
|
|
|
| -syncable::Id FindLocalIdToUpdate(
|
| - syncable::BaseTransaction* trans,
|
| - const sync_pb::SyncEntity& update) {
|
| +syncable::Id FindLocalIdToUpdate(syncable::BaseTransaction* trans,
|
| + const sync_pb::SyncEntity& update) {
|
| // Expected entry points of this function:
|
| // SyncEntity has NOT been applied to SERVER fields.
|
| // SyncEntity has NOT been applied to LOCAL fields.
|
| @@ -113,7 +112,7 @@ syncable::Id FindLocalIdToUpdate(
|
| }
|
| }
|
| } else if (update.has_originator_cache_guid() &&
|
| - update.originator_cache_guid() == client_id) {
|
| + update.originator_cache_guid() == client_id) {
|
| // If a commit succeeds, but the response does not come back fast enough
|
| // then the syncer might assume that it was never committed.
|
| // The server will track the client that sent up the original commit and
|
| @@ -151,8 +150,8 @@ syncable::Id FindLocalIdToUpdate(
|
| // Just a quick sanity check.
|
| DCHECK(!local_entry.GetId().ServerKnows());
|
|
|
| - DVLOG(1) << "Reuniting lost commit response IDs. server id: "
|
| - << update_id << " local id: " << local_entry.GetId()
|
| + DVLOG(1) << "Reuniting lost commit response IDs. server id: " << update_id
|
| + << " local id: " << local_entry.GetId()
|
| << " new version: " << new_version;
|
|
|
| return local_entry.GetId();
|
| @@ -204,8 +203,7 @@ UpdateAttemptResponse AttemptToUpdateEntry(
|
| << ModelTypeToString(entry->GetServerModelType())
|
| << " update, returning conflict_encryption.";
|
| return CONFLICT_ENCRYPTION;
|
| - } else if (specifics.has_password() &&
|
| - entry->GetUniqueServerTag().empty()) {
|
| + } else if (specifics.has_password() && entry->GetUniqueServerTag().empty()) {
|
| // Passwords use their own legacy encryption scheme.
|
| const sync_pb::PasswordSpecifics& password = specifics.password();
|
| if (!cryptographer->CanDecrypt(password.encrypted())) {
|
| @@ -358,10 +356,9 @@ void UpdateBookmarkPositioning(
|
|
|
| } // namespace
|
|
|
| -void UpdateServerFieldsFromUpdate(
|
| - syncable::ModelNeutralMutableEntry* target,
|
| - const sync_pb::SyncEntity& update,
|
| - const std::string& name) {
|
| +void UpdateServerFieldsFromUpdate(syncable::ModelNeutralMutableEntry* target,
|
| + const sync_pb::SyncEntity& update,
|
| + const std::string& name) {
|
| if (update.deleted()) {
|
| if (target->GetServerIsDel()) {
|
| // If we already think the item is server-deleted, we're done.
|
| @@ -417,8 +414,7 @@ void UpdateServerFieldsFromUpdate(
|
| const sync_pb::SyncEntity::BookmarkData& bookmark = update.bookmarkdata();
|
| UpdateBookmarkSpecifics(update.server_defined_unique_tag(),
|
| bookmark.bookmark_url(),
|
| - bookmark.bookmark_favicon(),
|
| - target);
|
| + bookmark.bookmark_favicon(), target);
|
| }
|
| target->PutServerAttachmentMetadata(
|
| CreateAttachmentMetadata(update.attachment_id()));
|
| @@ -437,22 +433,19 @@ void UpdateServerFieldsFromUpdate(
|
| }
|
|
|
| // Creates a new Entry iff no Entry exists with the given id.
|
| -void CreateNewEntry(syncable::ModelNeutralWriteTransaction *trans,
|
| +void CreateNewEntry(syncable::ModelNeutralWriteTransaction* trans,
|
| const syncable::Id& id) {
|
| syncable::Entry entry(trans, GET_BY_ID, id);
|
| if (!entry.good()) {
|
| syncable::ModelNeutralMutableEntry new_entry(
|
| - trans,
|
| - syncable::CREATE_NEW_UPDATE_ITEM,
|
| - id);
|
| + trans, syncable::CREATE_NEW_UPDATE_ITEM, id);
|
| }
|
| }
|
|
|
| // This function is called on an entry when we can update the user-facing data
|
| // from the server data.
|
| -void UpdateLocalDataFromServerData(
|
| - syncable::WriteTransaction* trans,
|
| - syncable::MutableEntry* entry) {
|
| +void UpdateLocalDataFromServerData(syncable::WriteTransaction* trans,
|
| + syncable::MutableEntry* entry) {
|
| DCHECK(!entry->GetIsUnsynced());
|
| DCHECK(entry->GetIsUnappliedUpdate());
|
|
|
| @@ -501,10 +494,9 @@ VerifyCommitResult ValidateCommitEntry(syncable::Entry* entry) {
|
| return VERIFY_OK;
|
| }
|
|
|
| -void MarkDeletedChildrenSynced(
|
| - syncable::Directory* dir,
|
| - syncable::BaseWriteTransaction* trans,
|
| - std::set<syncable::Id>* deleted_folders) {
|
| +void MarkDeletedChildrenSynced(syncable::Directory* dir,
|
| + syncable::BaseWriteTransaction* trans,
|
| + std::set<syncable::Id>* deleted_folders) {
|
| // There's two options here.
|
| // 1. Scan deleted unsynced entries looking up their pre-delete tree for any
|
| // of the deleted folders.
|
| @@ -519,7 +511,7 @@ void MarkDeletedChildrenSynced(
|
| if (handles.empty())
|
| return;
|
| Directory::Metahandles::iterator it;
|
| - for (it = handles.begin() ; it != handles.end() ; ++it) {
|
| + for (it = handles.begin(); it != handles.end(); ++it) {
|
| syncable::ModelNeutralMutableEntry entry(trans, GET_BY_HANDLE, *it);
|
| if (!entry.GetIsUnsynced() || !entry.GetIsDel())
|
| continue;
|
| @@ -538,10 +530,9 @@ void MarkDeletedChildrenSynced(
|
| }
|
| }
|
|
|
| -VerifyResult VerifyNewEntry(
|
| - const sync_pb::SyncEntity& update,
|
| - syncable::Entry* target,
|
| - const bool deleted) {
|
| +VerifyResult VerifyNewEntry(const sync_pb::SyncEntity& update,
|
| + syncable::Entry* target,
|
| + const bool deleted) {
|
| if (target->good()) {
|
| // Not a new update.
|
| return VERIFY_UNDECIDED;
|
| @@ -563,7 +554,6 @@ VerifyResult VerifyUpdateConsistency(
|
| const bool is_directory,
|
| ModelType model_type,
|
| syncable::ModelNeutralMutableEntry* target) {
|
| -
|
| CHECK(target->good());
|
| const syncable::Id& update_id = SyncableIdFromProto(update.id_string());
|
|
|
| @@ -656,8 +646,8 @@ VerifyResult VerifyUndelete(syncable::ModelNeutralWriteTransaction* trans,
|
| return VERIFY_SUCCESS;
|
| }
|
| if (update.version() < target->GetServerVersion()) {
|
| - LOG(WARNING) << "Update older than current server version for "
|
| - << *target << " Update:"
|
| + LOG(WARNING) << "Update older than current server version for " << *target
|
| + << " Update:"
|
| << SyncerProtoUtil::SyncEntityDebugString(update);
|
| return VERIFY_SUCCESS; // Expected in new sync protocol.
|
| }
|
|
|