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

Unified Diff: components/sync/engine_impl/commit_util.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/sync/engine_impl/commit_util.h ('k') | components/sync/engine_impl/conflict_resolver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/engine_impl/commit_util.cc
diff --git a/sync/engine/commit_util.cc b/components/sync/engine_impl/commit_util.cc
similarity index 87%
rename from sync/engine/commit_util.cc
rename to components/sync/engine_impl/commit_util.cc
index 4d0eacc75cc7773d247547f6cb5e56025fda057c..a2c2a4a8a971461923c592a10e360e17d9c485fb 100644
--- a/sync/engine/commit_util.cc
+++ b/components/sync/engine_impl/commit_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/commit_util.h"
+#include "components/sync/engine_impl/commit_util.h"
#include <stdint.h>
@@ -13,21 +13,21 @@
#include "base/debug/dump_without_crashing.h"
#include "base/strings/string_util.h"
-#include "sync/engine/syncer_proto_util.h"
-#include "sync/internal_api/public/base/attachment_id_proto.h"
-#include "sync/internal_api/public/base/unique_position.h"
-#include "sync/protocol/bookmark_specifics.pb.h"
-#include "sync/protocol/sync.pb.h"
-#include "sync/sessions/sync_session.h"
-#include "sync/syncable/directory.h"
-#include "sync/syncable/entry.h"
-#include "sync/syncable/model_neutral_mutable_entry.h"
-#include "sync/syncable/syncable_base_transaction.h"
-#include "sync/syncable/syncable_base_write_transaction.h"
-#include "sync/syncable/syncable_changes_version.h"
-#include "sync/syncable/syncable_proto_util.h"
-#include "sync/syncable/syncable_util.h"
-#include "sync/util/time.h"
+#include "components/sync/base/attachment_id_proto.h"
+#include "components/sync/base/time.h"
+#include "components/sync/base/unique_position.h"
+#include "components/sync/engine_impl/syncer_proto_util.h"
+#include "components/sync/protocol/bookmark_specifics.pb.h"
+#include "components/sync/protocol/sync.pb.h"
+#include "components/sync/sessions_impl/sync_session.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/syncable_base_transaction.h"
+#include "components/sync/syncable/syncable_base_write_transaction.h"
+#include "components/sync/syncable/syncable_changes_version.h"
+#include "components/sync/syncable/syncable_proto_util.h"
+#include "components/sync/syncable/syncable_util.h"
using std::set;
using std::string;
@@ -55,8 +55,7 @@ void AddExtensionsActivityToMessage(
activity->GetAndClearRecords(extensions_activity_buffer);
const ExtensionsActivity::Records& records = *extensions_activity_buffer;
- for (ExtensionsActivity::Records::const_iterator it =
- records.begin();
+ for (ExtensionsActivity::Records::const_iterator it = records.begin();
it != records.end(); ++it) {
sync_pb::ChromiumExtensionsActivity* activity_message =
message->add_extensions_activity();
@@ -66,10 +65,9 @@ void AddExtensionsActivityToMessage(
}
}
-void AddClientConfigParamsToMessage(
- ModelTypeSet enabled_types,
- bool cookie_jar_mismatch,
- sync_pb::CommitMessage* message) {
+void AddClientConfigParamsToMessage(ModelTypeSet enabled_types,
+ bool cookie_jar_mismatch,
+ sync_pb::CommitMessage* message) {
sync_pb::ClientConfigParams* config_params = message->mutable_config_params();
for (ModelTypeSet::Iterator it = enabled_types.First(); it.Good(); it.Inc()) {
if (ProxyTypes().Has(it.Get()))
@@ -105,9 +103,8 @@ void SetAttachmentIds(const Entry& meta_entry,
} // namespace
-void BuildCommitItem(
- const syncable::Entry& meta_entry,
- sync_pb::SyncEntity* sync_entry) {
+void BuildCommitItem(const syncable::Entry& meta_entry,
+ sync_pb::SyncEntity* sync_entry) {
syncable::Id id = meta_entry.GetId();
sync_entry->set_id_string(SyncableIdToProto(id));
@@ -126,15 +123,13 @@ void BuildCommitItem(
sync_entry->set_non_unique_name(name);
if (!meta_entry.GetUniqueClientTag().empty()) {
- sync_entry->set_client_defined_unique_tag(
- meta_entry.GetUniqueClientTag());
+ sync_entry->set_client_defined_unique_tag(meta_entry.GetUniqueClientTag());
}
// Deleted items with server-unknown parent ids can be a problem so we set
// the parent to 0. (TODO(sync): Still true in protocol?).
Id new_parent_id;
- if (meta_entry.GetIsDel() &&
- !meta_entry.GetParentId().ServerKnows()) {
+ if (meta_entry.GetIsDel() && !meta_entry.GetParentId().ServerKnows()) {
new_parent_id = syncable::BaseTransaction::root_id();
} else {
new_parent_id = meta_entry.GetParentId();
@@ -159,8 +154,7 @@ void BuildCommitItem(
int64_t version = meta_entry.GetBaseVersion();
if (syncable::CHANGES_VERSION == version || 0 == version) {
// Undeletions are only supported for items that have a client tag.
- DCHECK(!id.ServerKnows() ||
- !meta_entry.GetUniqueClientTag().empty())
+ DCHECK(!id.ServerKnows() || !meta_entry.GetUniqueClientTag().empty())
<< meta_entry;
// Version 0 means to create or undelete an object.
@@ -239,8 +233,7 @@ bool UpdateVersionAfterCommit(
int64_t old_version = local_entry->GetBaseVersion();
int64_t new_version = entry_response.version();
bool bad_commit_version = false;
- if (committed_entry.deleted() &&
- !local_entry->GetUniqueClientTag().empty()) {
+ if (committed_entry.deleted() && !local_entry->GetUniqueClientTag().empty()) {
// If the item was deleted, and it's undeletable (uses the client tag),
// change the version back to zero. We must set the version to zero so
// that the server knows to re-create the item if it gets committed
@@ -279,13 +272,11 @@ bool ChangeIdAfterCommit(
if (pre_commit_id.ServerKnows()) {
// The server can sometimes generate a new ID on commit; for example,
// when committing an undeletion.
- DVLOG(1) << " ID changed while committing an old entry. "
- << pre_commit_id << " became " << entry_response_id << ".";
+ DVLOG(1) << " ID changed while committing an old entry. " << pre_commit_id
+ << " became " << entry_response_id << ".";
}
- syncable::ModelNeutralMutableEntry same_id(
- trans,
- syncable::GET_BY_ID,
- entry_response_id);
+ syncable::ModelNeutralMutableEntry same_id(trans, syncable::GET_BY_ID,
+ entry_response_id);
// We should trap this before this function.
if (same_id.good()) {
LOG(ERROR) << "ID clash with id " << entry_response_id
@@ -302,7 +293,6 @@ void UpdateServerFieldsAfterCommit(
const sync_pb::SyncEntity& committed_entry,
const sync_pb::CommitResponse_EntryResponse& entry_response,
syncable::ModelNeutralMutableEntry* local_entry) {
-
// We just committed an entry successfully, and now we want to make our view
// of the server state consistent with the server state. We must be careful;
// |entry_response| and |committed_entry| have some identically named
@@ -328,8 +318,7 @@ void UpdateServerFieldsAfterCommit(
local_entry->PutServerCtime(ProtoTimeToTime(committed_entry.ctime()));
if (committed_entry.has_unique_position()) {
local_entry->PutServerUniquePosition(
- UniquePosition::FromProto(
- committed_entry.unique_position()));
+ UniquePosition::FromProto(committed_entry.unique_position()));
}
// TODO(nick): The server doesn't set entry_response.server_parent_id in
@@ -356,7 +345,8 @@ void ProcessSuccessfulCommitResponse(
const sync_pb::CommitResponse_EntryResponse& entry_response,
const syncable::Id& pre_commit_id,
syncable::ModelNeutralMutableEntry* local_entry,
- bool dirty_sync_was_set, set<syncable::Id>* deleted_folders) {
+ bool dirty_sync_was_set,
+ set<syncable::Id>* deleted_folders) {
DCHECK(local_entry->GetIsUnsynced());
// Update SERVER_VERSION and BASE_VERSION.
@@ -401,10 +391,8 @@ sync_pb::CommitResponse::ResponseType ProcessSingleCommitResponse(
const sync_pb::SyncEntity& commit_request_entry,
int64_t metahandle,
set<syncable::Id>* deleted_folders) {
- syncable::ModelNeutralMutableEntry local_entry(
- trans,
- syncable::GET_BY_HANDLE,
- metahandle);
+ syncable::ModelNeutralMutableEntry local_entry(trans, syncable::GET_BY_HANDLE,
+ metahandle);
CHECK(local_entry.good());
bool dirty_sync_was_set = local_entry.GetDirtySync();
local_entry.PutDirtySync(false);
@@ -413,7 +401,7 @@ sync_pb::CommitResponse::ResponseType ProcessSingleCommitResponse(
sync_pb::CommitResponse::ResponseType response = server_entry.response_type();
if (!sync_pb::CommitResponse::ResponseType_IsValid(response)) {
LOG(ERROR) << "Commit response has unknown response type! Possibly out "
- "of date client?";
+ "of date client?";
return sync_pb::CommitResponse::INVALID_MESSAGE;
}
if (sync_pb::CommitResponse::TRANSIENT_ERROR == response) {
@@ -452,10 +440,8 @@ sync_pb::CommitResponse::ResponseType ProcessSingleCommitResponse(
if (local_entry.GetId() != server_entry_id) {
Entry e(trans, syncable::GET_BY_ID, server_entry_id);
if (e.good()) {
- LOG(ERROR)
- << "Got duplicate id when commiting id: "
- << local_entry.GetId()
- << ". Treating as an error return";
+ LOG(ERROR) << "Got duplicate id when commiting id: "
+ << local_entry.GetId() << ". Treating as an error return";
return sync_pb::CommitResponse::INVALID_MESSAGE;
}
}
@@ -465,7 +451,8 @@ sync_pb::CommitResponse::ResponseType ProcessSingleCommitResponse(
}
ProcessSuccessfulCommitResponse(commit_request_entry, server_entry,
- local_entry.GetId(), &local_entry, dirty_sync_was_set, deleted_folders);
+ local_entry.GetId(), &local_entry,
+ dirty_sync_was_set, deleted_folders);
return response;
}
« no previous file with comments | « components/sync/engine_impl/commit_util.h ('k') | components/sync/engine_impl/conflict_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698