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

Unified Diff: chrome/browser/sync/engine/verify_updates_command.cc

Issue 9699057: [Sync] Move 'sync' target to sync/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Tim's comments Created 8 years, 9 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
Index: chrome/browser/sync/engine/verify_updates_command.cc
diff --git a/chrome/browser/sync/engine/verify_updates_command.cc b/chrome/browser/sync/engine/verify_updates_command.cc
deleted file mode 100644
index 58a3c8ddf3778ee47109a154a0ab940d08795063..0000000000000000000000000000000000000000
--- a/chrome/browser/sync/engine/verify_updates_command.cc
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/sync/engine/verify_updates_command.h"
-
-#include <string>
-
-#include "base/location.h"
-#include "chrome/browser/sync/engine/syncer.h"
-#include "chrome/browser/sync/engine/syncer_proto_util.h"
-#include "chrome/browser/sync/engine/syncer_types.h"
-#include "chrome/browser/sync/engine/syncer_util.h"
-#include "chrome/browser/sync/engine/syncproto.h"
-#include "chrome/browser/sync/syncable/syncable.h"
-#include "sync/protocol/bookmark_specifics.pb.h"
-
-namespace browser_sync {
-
-using syncable::WriteTransaction;
-
-using syncable::GET_BY_ID;
-using syncable::SYNCER;
-
-VerifyUpdatesCommand::VerifyUpdatesCommand() {}
-VerifyUpdatesCommand::~VerifyUpdatesCommand() {}
-
-std::set<ModelSafeGroup> VerifyUpdatesCommand::GetGroupsToChange(
- const sessions::SyncSession& session) const {
- std::set<ModelSafeGroup> groups_with_updates;
-
- const GetUpdatesResponse& updates =
- session.status_controller().updates_response().get_updates();
- for (int i = 0; i < updates.entries().size(); i++) {
- groups_with_updates.insert(
- GetGroupForModelType(syncable::GetModelType(updates.entries(i)),
- session.routing_info()));
- }
-
- return groups_with_updates;
-}
-
-SyncerError VerifyUpdatesCommand::ModelChangingExecuteImpl(
- sessions::SyncSession* session) {
- DVLOG(1) << "Beginning Update Verification";
- syncable::Directory* dir = session->context()->directory();
- WriteTransaction trans(FROM_HERE, SYNCER, dir);
- sessions::StatusController* status = session->mutable_status_controller();
- const GetUpdatesResponse& updates = status->updates_response().get_updates();
- int update_count = updates.entries().size();
-
- DVLOG(1) << update_count << " entries to verify";
- for (int i = 0; i < update_count; i++) {
- const SyncEntity& update =
- *reinterpret_cast<const SyncEntity *>(&(updates.entries(i)));
- ModelSafeGroup g = GetGroupForModelType(update.GetModelType(),
- session->routing_info());
- if (g != status->group_restriction())
- continue;
-
- VerifyUpdateResult result = VerifyUpdate(&trans, update,
- session->routing_info());
- status->mutable_update_progress()->AddVerifyResult(result.value, update);
- status->increment_num_updates_downloaded_by(1);
- if (update.deleted())
- status->increment_num_tombstone_updates_downloaded_by(1);
- }
-
- return SYNCER_OK;
-}
-
-namespace {
-// In the event that IDs match, but tags differ AttemptReuniteClient tag
-// will have refused to unify the update.
-// We should not attempt to apply it at all since it violates consistency
-// rules.
-VerifyResult VerifyTagConsistency(const SyncEntity& entry,
- const syncable::MutableEntry& same_id) {
- if (entry.has_client_defined_unique_tag() &&
- entry.client_defined_unique_tag() !=
- same_id.Get(syncable::UNIQUE_CLIENT_TAG)) {
- return VERIFY_FAIL;
- }
- return VERIFY_UNDECIDED;
-}
-} // namespace
-
-VerifyUpdatesCommand::VerifyUpdateResult VerifyUpdatesCommand::VerifyUpdate(
- syncable::WriteTransaction* trans, const SyncEntity& entry,
- const ModelSafeRoutingInfo& routes) {
- syncable::Id id = entry.id();
- VerifyUpdateResult result = {VERIFY_FAIL, GROUP_PASSIVE};
-
- const bool deleted = entry.has_deleted() && entry.deleted();
- const bool is_directory = entry.IsFolder();
- const syncable::ModelType model_type = entry.GetModelType();
-
- if (!id.ServerKnows()) {
- LOG(ERROR) << "Illegal negative id in received updates";
- return result;
- }
- {
- const std::string name = SyncerProtoUtil::NameFromSyncEntity(entry);
- if (name.empty() && !deleted) {
- LOG(ERROR) << "Zero length name in non-deleted update";
- return result;
- }
- }
-
- syncable::MutableEntry same_id(trans, GET_BY_ID, id);
- result.value = SyncerUtil::VerifyNewEntry(entry, &same_id, deleted);
-
- syncable::ModelType placement_type = !deleted ? entry.GetModelType()
- : same_id.good() ? same_id.GetModelType() : syncable::UNSPECIFIED;
- result.placement = GetGroupForModelType(placement_type, routes);
-
- if (VERIFY_UNDECIDED == result.value) {
- result.value = VerifyTagConsistency(entry, same_id);
- }
-
- if (VERIFY_UNDECIDED == result.value) {
- if (deleted)
- result.value = VERIFY_SUCCESS;
- }
-
- // If we have an existing entry, we check here for updates that break
- // consistency rules.
- if (VERIFY_UNDECIDED == result.value) {
- result.value = SyncerUtil::VerifyUpdateConsistency(trans, entry, &same_id,
- deleted, is_directory, model_type);
- }
-
- if (VERIFY_UNDECIDED == result.value)
- result.value = VERIFY_SUCCESS; // No news is good news.
-
- return result; // This might be VERIFY_SUCCESS as well
-}
-
-} // namespace browser_sync
« no previous file with comments | « chrome/browser/sync/engine/verify_updates_command.h ('k') | chrome/browser/sync/engine/verify_updates_command_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698