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

Unified Diff: components/sync/engine_impl/process_updates_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/process_updates_util.h ('k') | components/sync/engine_impl/sync_cycle_event.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/engine_impl/process_updates_util.cc
diff --git a/sync/engine/process_updates_util.cc b/components/sync/engine_impl/process_updates_util.cc
similarity index 81%
rename from sync/engine/process_updates_util.cc
rename to components/sync/engine_impl/process_updates_util.cc
index d91d0eb1b4537f1b78c77643cc29aab9f7485e3f..b4a2da6c52bd45483ce43011b2bccdf440990860 100644
--- a/sync/engine/process_updates_util.cc
+++ b/components/sync/engine_impl/process_updates_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/process_updates_util.h"
+#include "components/sync/engine_impl/process_updates_util.h"
#include <stddef.h>
#include <stdint.h>
@@ -11,17 +11,17 @@
#include "base/location.h"
#include "base/metrics/sparse_histogram.h"
-#include "sync/engine/syncer_proto_util.h"
-#include "sync/engine/syncer_types.h"
-#include "sync/engine/syncer_util.h"
-#include "sync/internal_api/public/sessions/update_counters.h"
-#include "sync/syncable/directory.h"
-#include "sync/syncable/model_neutral_mutable_entry.h"
-#include "sync/syncable/syncable_model_neutral_write_transaction.h"
-#include "sync/syncable/syncable_proto_util.h"
-#include "sync/syncable/syncable_util.h"
-#include "sync/util/cryptographer.h"
-#include "sync/util/data_type_histogram.h"
+#include "components/sync/base/cryptographer.h"
+#include "components/sync/base/data_type_histogram.h"
+#include "components/sync/engine_impl/syncer_proto_util.h"
+#include "components/sync/engine_impl/syncer_types.h"
+#include "components/sync/engine_impl/syncer_util.h"
+#include "components/sync/sessions/update_counters.h"
+#include "components/sync/syncable/directory.h"
+#include "components/sync/syncable/model_neutral_mutable_entry.h"
+#include "components/sync/syncable/syncable_model_neutral_write_transaction.h"
+#include "components/sync/syncable/syncable_proto_util.h"
+#include "components/sync/syncable/syncable_util.h"
namespace syncer {
@@ -52,8 +52,8 @@ namespace {
// this case, we're right to assume that the update is not a reflection.
//
// For more information, see FindLocalIdToUpdate().
-bool UpdateContainsNewVersion(syncable::BaseTransaction *trans,
- const sync_pb::SyncEntity &update) {
+bool UpdateContainsNewVersion(syncable::BaseTransaction* trans,
+ const sync_pb::SyncEntity& update) {
int64_t existing_version = -1; // The server always sends positive versions.
syncable::Entry existing_entry(trans, GET_BY_ID,
SyncableIdFromProto(update.id_string()));
@@ -69,10 +69,8 @@ bool UpdateContainsNewVersion(syncable::BaseTransaction *trans,
return false;
}
- if (existing_entry.good() &&
- !existing_entry.GetUniqueClientTag().empty() &&
- existing_entry.GetIsDel() &&
- update.deleted()) {
+ if (existing_entry.good() && !existing_entry.GetUniqueClientTag().empty() &&
+ existing_entry.GetIsDel() && update.deleted()) {
// Unique client tags will have their version set to zero when they're
// deleted. The usual version comparison logic won't be able to detect
// reflections of these items. Instead, we assume any received tombstones
@@ -91,8 +89,7 @@ VerifyResult VerifyTagConsistency(
const sync_pb::SyncEntity& entry,
const syncable::ModelNeutralMutableEntry& same_id) {
if (entry.has_client_defined_unique_tag() &&
- entry.client_defined_unique_tag() !=
- same_id.GetUniqueClientTag()) {
+ entry.client_defined_unique_tag() != same_id.GetUniqueClientTag()) {
return VERIFY_FAIL;
}
return VERIFY_UNDECIDED;
@@ -102,10 +99,9 @@ VerifyResult VerifyTagConsistency(
//
// The answer may be "no" if the update appears invalid, or it's not releveant
// (ie. a delete for an item we've never heard of), or other reasons.
-VerifyResult VerifyUpdate(
- syncable::ModelNeutralWriteTransaction* trans,
- const sync_pb::SyncEntity& entry,
- ModelType requested_type) {
+VerifyResult VerifyUpdate(syncable::ModelNeutralWriteTransaction* trans,
+ const sync_pb::SyncEntity& entry,
+ ModelType requested_type) {
syncable::Id id = SyncableIdFromProto(entry.id_string());
VerifyResult result = VERIFY_FAIL;
@@ -128,8 +124,9 @@ VerifyResult VerifyUpdate(
syncable::ModelNeutralMutableEntry same_id(trans, GET_BY_ID, id);
result = VerifyNewEntry(entry, &same_id, deleted);
- ModelType placement_type = !deleted ? GetModelType(entry)
- : same_id.good() ? same_id.GetModelType() : UNSPECIFIED;
+ ModelType placement_type =
+ !deleted ? GetModelType(entry) : same_id.good() ? same_id.GetModelType()
+ : UNSPECIFIED;
if (VERIFY_UNDECIDED == result) {
result = VerifyTagConsistency(entry, same_id);
@@ -150,8 +147,8 @@ VerifyResult VerifyUpdate(
// If we have an existing entry, we check here for updates that break
// consistency rules.
if (VERIFY_UNDECIDED == result) {
- result = VerifyUpdateConsistency(trans, entry, deleted,
- is_directory, model_type, &same_id);
+ result = VerifyUpdateConsistency(trans, entry, deleted, is_directory,
+ model_type, &same_id);
}
if (VERIFY_UNDECIDED == result)
@@ -168,11 +165,8 @@ bool ReverifyEntry(syncable::ModelNeutralWriteTransaction* trans,
const bool is_directory = IsFolder(entry);
const ModelType model_type = GetModelType(entry);
- return VERIFY_SUCCESS == VerifyUpdateConsistency(trans,
- entry,
- deleted,
- is_directory,
- model_type,
+ return VERIFY_SUCCESS == VerifyUpdateConsistency(trans, entry, deleted,
+ is_directory, model_type,
same_id);
}
@@ -180,10 +174,9 @@ bool ReverifyEntry(syncable::ModelNeutralWriteTransaction* trans,
//
// If the update passes a series of checks, this function will copy
// the SyncEntity's data into the SERVER side of the syncable::Directory.
-void ProcessUpdate(
- const sync_pb::SyncEntity& update,
- const Cryptographer* cryptographer,
- syncable::ModelNeutralWriteTransaction* const trans) {
+void ProcessUpdate(const sync_pb::SyncEntity& update,
+ const Cryptographer* cryptographer,
+ syncable::ModelNeutralWriteTransaction* const trans) {
const syncable::Id& server_id = SyncableIdFromProto(update.id_string());
const std::string name = SyncerProtoUtil::NameFromSyncEntity(update);
@@ -242,8 +235,8 @@ void ProcessUpdate(
if (target_entry.ShouldMaintainPosition() && !update.deleted()) {
std::string update_tag = GetUniqueBookmarkTagFromUpdate(update);
if (UniquePosition::IsValidSuffix(update_tag)) {
- position_matches = GetUpdatePosition(update, update_tag).Equals(
- target_entry.GetServerUniquePosition());
+ position_matches = GetUpdatePosition(update, update_tag)
+ .Equals(target_entry.GetServerUniquePosition());
} else {
NOTREACHED();
}
@@ -254,17 +247,16 @@ void ProcessUpdate(
if (!update.deleted() && !target_entry.GetServerIsDel() &&
(SyncableIdFromProto(update.parent_id_string()) ==
- target_entry.GetServerParentId()) &&
- position_matches &&
- update.has_specifics() && update.specifics().has_encrypted() &&
+ target_entry.GetServerParentId()) &&
+ position_matches && update.has_specifics() &&
+ update.specifics().has_encrypted() &&
!cryptographer->CanDecrypt(update.specifics().encrypted())) {
- sync_pb::EntitySpecifics prev_specifics =
- target_entry.GetServerSpecifics();
+ sync_pb::EntitySpecifics prev_specifics = target_entry.GetServerSpecifics();
// We only store the old specifics if they were decryptable and applied and
// there is no BASE_SERVER_SPECIFICS already. Else do nothing.
if (!target_entry.GetIsUnappliedUpdate() &&
- !IsRealDataType(GetModelTypeFromSpecifics(
- target_entry.GetBaseServerSpecifics())) &&
+ !IsRealDataType(
+ GetModelTypeFromSpecifics(target_entry.GetBaseServerSpecifics())) &&
(!prev_specifics.has_encrypted() ||
cryptographer->CanDecrypt(prev_specifics.encrypted()))) {
DVLOG(2) << "Storing previous server specifcs: "
@@ -276,8 +268,7 @@ void ProcessUpdate(
// We have a BASE_SERVER_SPECIFICS, but a subsequent non-specifics-only
// change arrived. As a result, we can't use the specifics alone to detect
// changes, so we clear BASE_SERVER_SPECIFICS.
- target_entry.PutBaseServerSpecifics(
- sync_pb::EntitySpecifics());
+ target_entry.PutBaseServerSpecifics(sync_pb::EntitySpecifics());
}
UpdateServerFieldsFromUpdate(&target_entry, update, name);
@@ -287,13 +278,12 @@ void ProcessUpdate(
} // namespace
-void ProcessDownloadedUpdates(
- syncable::Directory* dir,
- syncable::ModelNeutralWriteTransaction* trans,
- ModelType type,
- const SyncEntityList& applicable_updates,
- sessions::StatusController* status,
- UpdateCounters* counters) {
+void ProcessDownloadedUpdates(syncable::Directory* dir,
+ syncable::ModelNeutralWriteTransaction* trans,
+ ModelType type,
+ const SyncEntityList& applicable_updates,
+ sessions::StatusController* status,
+ UpdateCounters* counters) {
for (SyncEntityList::const_iterator update_it = applicable_updates.begin();
update_it != applicable_updates.end(); ++update_it) {
DCHECK_EQ(type, GetModelType(**update_it));
« no previous file with comments | « components/sync/engine_impl/process_updates_util.h ('k') | components/sync/engine_impl/sync_cycle_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698