diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-20 00:02:21 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-20 00:02:21 +0000 |
commit | 729c49e105ff2eff40c230aa9bc5def53ed26a37 (patch) | |
tree | 1018cec7ac0b3b0232aa8e84cda9d8b361f940f4 /sync/engine | |
parent | 36cd3ef210d89988628cb58bb967755831d50afe (diff) | |
download | chromium_src-729c49e105ff2eff40c230aa9bc5def53ed26a37.zip chromium_src-729c49e105ff2eff40c230aa9bc5def53ed26a37.tar.gz chromium_src-729c49e105ff2eff40c230aa9bc5def53ed26a37.tar.bz2 |
sync: Remove ClearUserData command.
BUG=131336
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10584019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143088 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/engine')
-rw-r--r-- | sync/engine/all_status.cc | 2 | ||||
-rw-r--r-- | sync/engine/clear_data_command.cc | 77 | ||||
-rw-r--r-- | sync/engine/clear_data_command.h | 31 | ||||
-rw-r--r-- | sync/engine/clear_data_command_unittest.cc | 117 | ||||
-rw-r--r-- | sync/engine/sync_engine_event.h | 5 | ||||
-rw-r--r-- | sync/engine/sync_scheduler.cc | 20 | ||||
-rw-r--r-- | sync/engine/sync_scheduler.h | 8 | ||||
-rw-r--r-- | sync/engine/sync_scheduler_unittest.cc | 11 | ||||
-rw-r--r-- | sync/engine/sync_scheduler_whitebox_unittest.cc | 17 | ||||
-rw-r--r-- | sync/engine/syncer.cc | 8 | ||||
-rw-r--r-- | sync/engine/syncer.h | 1 |
11 files changed, 1 insertions, 296 deletions
diff --git a/sync/engine/all_status.cc b/sync/engine/all_status.cc index 7afd1a4..cf170f0c1 100644 --- a/sync/engine/all_status.cc +++ b/sync/engine/all_status.cc @@ -106,8 +106,6 @@ void AllStatus::OnSyncEngineEvent(const SyncEngineEvent& event) { break; case SyncEngineEvent::STOP_SYNCING_PERMANENTLY: case SyncEngineEvent::UPDATED_TOKEN: - case SyncEngineEvent::CLEAR_SERVER_DATA_FAILED: - case SyncEngineEvent::CLEAR_SERVER_DATA_SUCCEEDED: break; case SyncEngineEvent::ACTIONABLE_ERROR: status_ = CreateBlankStatus(); diff --git a/sync/engine/clear_data_command.cc b/sync/engine/clear_data_command.cc deleted file mode 100644 index e7d7343..0000000 --- a/sync/engine/clear_data_command.cc +++ /dev/null @@ -1,77 +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 "sync/engine/clear_data_command.h" - -#include <string> - -#include "sync/engine/syncer.h" -#include "sync/engine/syncer_proto_util.h" -#include "sync/engine/syncproto.h" -#include "sync/sessions/sync_session.h" - -namespace browser_sync { - -using sessions::StatusController; -using sessions::SyncSession; -using std::string; -using syncable::FIRST_REAL_MODEL_TYPE; -using syncable::MODEL_TYPE_COUNT; - - -ClearDataCommand::ClearDataCommand() {} -ClearDataCommand::~ClearDataCommand() {} - -SyncerError ClearDataCommand::ExecuteImpl(SyncSession* session) { - ClientToServerMessage client_to_server_message; - ClientToServerResponse client_to_server_response; - - client_to_server_message.set_share(session->context()->account_name()); - client_to_server_message.set_message_contents( - ClientToServerMessage::CLEAR_DATA); - - client_to_server_message.mutable_clear_user_data(); - - SyncerProtoUtil::AddRequestBirthday(session->context()->directory(), - &client_to_server_message); - - DVLOG(1) << "Clearing server data"; - - SyncerError result = SyncerProtoUtil::PostClientToServerMessage( - client_to_server_message, - &client_to_server_response, - session); - - DVLOG(1) << SyncerProtoUtil::ClientToServerResponseDebugString( - client_to_server_response); - - // TODO(lipalani): This code is wrong. The response error codes it checks - // have been obsoleted. The only reason it hasn't caused problems is that - // this code is unreachable. We should do something to clean up this mess. - // See also: crbug.com/71616. - // - // Clear pending indicates that the server has received our clear message - if (result != SYNCER_OK || !client_to_server_response.has_error_code() || - client_to_server_response.error_code() != sync_pb::SyncEnums::SUCCESS) { - // On failure, subsequent requests to the server will cause it to attempt - // to resume the clear. The client will handle disabling of sync in - // response to a store birthday error from the server. - SyncEngineEvent event(SyncEngineEvent::CLEAR_SERVER_DATA_FAILED); - session->context()->NotifyListeners(event); - - LOG(ERROR) << "Error posting ClearData."; - - return result; - } - - SyncEngineEvent event(SyncEngineEvent::CLEAR_SERVER_DATA_SUCCEEDED); - session->context()->NotifyListeners(event); - - session->delegate()->OnShouldStopSyncingPermanently(); - - DVLOG(1) << "ClearData succeeded."; - return SYNCER_OK; -} - -} // namespace browser_sync diff --git a/sync/engine/clear_data_command.h b/sync/engine/clear_data_command.h deleted file mode 100644 index 258a99c..0000000 --- a/sync/engine/clear_data_command.h +++ /dev/null @@ -1,31 +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. - -#ifndef SYNC_ENGINE_CLEAR_DATA_COMMAND_H_ -#define SYNC_ENGINE_CLEAR_DATA_COMMAND_H_ -#pragma once - -#include "base/basictypes.h" -#include "sync/engine/syncer_command.h" -#include "sync/internal_api/public/engine/model_safe_worker.h" -#include "sync/internal_api/public/syncable/model_type.h" - -namespace browser_sync { - -// Clears server data associated with this user's account -class ClearDataCommand : public SyncerCommand { - public: - ClearDataCommand(); - virtual ~ClearDataCommand(); - - // SyncerCommand implementation. - virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE; - - private: - DISALLOW_COPY_AND_ASSIGN(ClearDataCommand); -}; - -} // namespace browser_sync - -#endif // SYNC_ENGINE_CLEAR_DATA_COMMAND_H_ diff --git a/sync/engine/clear_data_command_unittest.cc b/sync/engine/clear_data_command_unittest.cc deleted file mode 100644 index b94d08a..0000000 --- a/sync/engine/clear_data_command_unittest.cc +++ /dev/null @@ -1,117 +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 "sync/engine/clear_data_command.h" -#include "sync/protocol/autofill_specifics.pb.h" -#include "sync/protocol/bookmark_specifics.pb.h" -#include "sync/protocol/preference_specifics.pb.h" -#include "sync/protocol/sync.pb.h" -#include "sync/test/engine/syncer_command_test.h" -#include "sync/test/sessions/test_scoped_session_event_listener.h" - -namespace browser_sync { - -using sessions::TestScopedSessionEventListener; -using syncable::FIRST_REAL_MODEL_TYPE; -using syncable::MODEL_TYPE_COUNT; - -// A test fixture for tests exercising ClearDataCommandTest. -class ClearDataCommandTest : public SyncerCommandTest { - protected: - ClearDataCommandTest() {} - ClearDataCommand command_; - - virtual void OnShouldStopSyncingPermanently() { - on_should_stop_syncing_permanently_called_ = true; - } - - protected: - bool on_should_stop_syncing_permanently_called_; - - private: - DISALLOW_COPY_AND_ASSIGN(ClearDataCommandTest); -}; - -class ClearEventHandler : public SyncEngineEventListener { - public: - ClearEventHandler() { - ResetReceivedEvents(); - } - bool ReceievedClearSuccessEvent() { return received_clear_success_event_; } - bool ReceievedClearFailedEvent() { return received_clear_failed_event_; } - void ResetReceivedEvents() { - received_clear_success_event_ = false; - received_clear_failed_event_ = false; - } - - virtual void OnSyncEngineEvent(const SyncEngineEvent& event) { - if (event.what_happened == SyncEngineEvent::CLEAR_SERVER_DATA_FAILED) { - received_clear_failed_event_ = true; - } else if (event.what_happened == - SyncEngineEvent::CLEAR_SERVER_DATA_SUCCEEDED) { - received_clear_success_event_ = true; - } - } - - private: - bool received_clear_success_event_; - bool received_clear_failed_event_; -}; - -TEST_F(ClearDataCommandTest, ClearDataCommandExpectFailed) { - ConfigureMockServerConnection(); - scoped_ptr<ClearEventHandler> handler(new ClearEventHandler()); - TestScopedSessionEventListener reg(context(), handler.get()); - - directory()->set_store_birthday(mock_server()->store_birthday()); - mock_server()->SetServerNotReachable(); - on_should_stop_syncing_permanently_called_ = false; - - command_.Execute(session()); - - // Expect that the client sent a clear request, received failure, - // fired a failure event, but did not disable sync. - // - // A failure event will be bubbled back to the user's UI, and the - // user can press "clear" again. - // - // We do not want to disable sync in the client because the user may - // incorrectly get the impression that their private data has been cleared - // from the server (from the fact that their data is gone on the client). - // - // Any subsequent GetUpdates/Commit requests or attempts to enable sync - // will cause the server to attempt to resume the clearing process (within - // a bounded window of time) - const sync_pb::ClientToServerMessage& r = mock_server()->last_request(); - EXPECT_TRUE(r.has_clear_user_data()); - - EXPECT_TRUE(handler.get()->ReceievedClearFailedEvent()); - - EXPECT_FALSE(handler.get()->ReceievedClearSuccessEvent()); - EXPECT_FALSE(on_should_stop_syncing_permanently_called_); -} - -TEST_F(ClearDataCommandTest, ClearDataCommandExpectSuccess) { - ConfigureMockServerConnection(); - scoped_ptr<ClearEventHandler> handler(new ClearEventHandler()); - TestScopedSessionEventListener reg(context(), handler.get()); - - directory()->set_store_birthday(mock_server()->store_birthday()); - mock_server()->SetClearUserDataResponseStatus(sync_pb::SyncEnums::SUCCESS); - on_should_stop_syncing_permanently_called_ = false; - - command_.Execute(session()); - - // Expect that the client sent a clear request, fired off the success event - // in response, and disabled sync - const sync_pb::ClientToServerMessage& r = mock_server()->last_request(); - EXPECT_TRUE(r.has_clear_user_data()); - - EXPECT_TRUE(handler->ReceievedClearSuccessEvent()); - EXPECT_TRUE(on_should_stop_syncing_permanently_called_); - - EXPECT_FALSE(handler->ReceievedClearFailedEvent()); -} - -} // namespace browser_sync diff --git a/sync/engine/sync_engine_event.h b/sync/engine/sync_engine_event.h index e9c52a7..d47edf3 100644 --- a/sync/engine/sync_engine_event.h +++ b/sync/engine/sync_engine_event.h @@ -41,11 +41,6 @@ struct SyncEngineEvent { // data (i.e. as if the user clicked 'Stop Syncing' in the browser. STOP_SYNCING_PERMANENTLY, - // These events are sent to indicate when we know the clearing of - // server data have failed or succeeded. - CLEAR_SERVER_DATA_SUCCEEDED, - CLEAR_SERVER_DATA_FAILED, - // This event is sent when we receive an actionable error. It is upto // the listeners to figure out the action to take using the snapshot sent. ACTIONABLE_ERROR, diff --git a/sync/engine/sync_scheduler.cc b/sync/engine/sync_scheduler.cc index f798d67..bf9deec 100644 --- a/sync/engine/sync_scheduler.cc +++ b/sync/engine/sync_scheduler.cc @@ -113,7 +113,6 @@ const char* SyncScheduler::SyncSessionJob::GetPurposeString( ENUM_CASE(UNKNOWN); ENUM_CASE(POLL); ENUM_CASE(NUDGE); - ENUM_CASE(CLEAR_USER_DATA); ENUM_CASE(CONFIGURATION); ENUM_CASE(CLEANUP_DISABLED_TYPES); } @@ -288,7 +287,6 @@ SyncScheduler::JobProcessDecision SyncScheduler::DecideWhileInWaitInterval( const SyncSessionJob& job) { DCHECK_EQ(MessageLoop::current(), sync_loop_); DCHECK(wait_interval_.get()); - DCHECK_NE(job.purpose, SyncSessionJob::CLEAR_USER_DATA); DCHECK_NE(job.purpose, SyncSessionJob::CLEANUP_DISABLED_TYPES); SDVLOG(2) << "DecideWhileInWaitInterval with WaitInterval mode " @@ -322,8 +320,7 @@ SyncScheduler::JobProcessDecision SyncScheduler::DecideWhileInWaitInterval( SyncScheduler::JobProcessDecision SyncScheduler::DecideOnJob( const SyncSessionJob& job) { DCHECK_EQ(MessageLoop::current(), sync_loop_); - if (job.purpose == SyncSessionJob::CLEAR_USER_DATA || - job.purpose == SyncSessionJob::CLEANUP_DISABLED_TYPES) + if (job.purpose == SyncSessionJob::CLEANUP_DISABLED_TYPES) return CONTINUE; // See if our type is throttled. @@ -417,7 +414,6 @@ bool SyncScheduler::ShouldRunJob(const SyncSessionJob& job) { void SyncScheduler::SaveJob(const SyncSessionJob& job) { DCHECK_EQ(MessageLoop::current(), sync_loop_); - DCHECK_NE(job.purpose, SyncSessionJob::CLEAR_USER_DATA); // TODO(sync): Should we also check that job.purpose != // CLEANUP_DISABLED_TYPES? (See http://crbug.com/90868.) if (job.purpose == SyncSessionJob::NUDGE) { @@ -449,16 +445,6 @@ struct ModelSafeWorkerGroupIs { ModelSafeGroup group; }; -void SyncScheduler::ClearUserData() { - DCHECK_EQ(MessageLoop::current(), sync_loop_); - SyncSessionJob job(SyncSessionJob::CLEAR_USER_DATA, TimeTicks::Now(), - make_linked_ptr(CreateSyncSession(SyncSourceInfo())), - false, - FROM_HERE); - - DoSyncSessionJob(job); -} - void SyncScheduler::CleanupDisabledTypes() { DCHECK_EQ(MessageLoop::current(), sync_loop_); SyncSessionJob job(SyncSessionJob::CLEANUP_DISABLED_TYPES, TimeTicks::Now(), @@ -655,10 +641,6 @@ void SyncScheduler::SetSyncerStepsForPurpose( *start = DOWNLOAD_UPDATES; *end = APPLY_UPDATES; return; - case SyncSessionJob::CLEAR_USER_DATA: - *start = CLEAR_PRIVATE_DATA; - *end = CLEAR_PRIVATE_DATA; - return; case SyncSessionJob::NUDGE: case SyncSessionJob::POLL: *start = SYNCER_BEGIN; diff --git a/sync/engine/sync_scheduler.h b/sync/engine/sync_scheduler.h index f6a54cc..363b93e 100644 --- a/sync/engine/sync_scheduler.h +++ b/sync/engine/sync_scheduler.h @@ -94,9 +94,6 @@ class SyncScheduler : public sessions::SyncSession::Delegate { syncable::ModelTypeSet types, sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); - // TODO(tim): remove this. crbug.com/131336 - void ClearUserData(); - void CleanupDisabledTypes(); // Change status of notifications in the SyncSessionContext. @@ -150,9 +147,6 @@ class SyncScheduler : public sessions::SyncSession::Delegate { // A nudge task can come from a variety of components needing to force // a sync. The source is inferable from |session.source()|. NUDGE, - // The user invoked a function in the UI to clear their entire account - // and stop syncing (globally). - CLEAR_USER_DATA, // Typically used for fetching updates for a subset of the enabled types // during initial sync or reconfiguration. We don't run all steps of // the sync cycle for these (e.g. CleanupDisabledTypes is skipped). @@ -196,8 +190,6 @@ class SyncScheduler : public sessions::SyncSession::Delegate { FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, SaveNudgeWhileThrottled); FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, - ContinueClearUserDataUnderAllCircumstances); - FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinueCanaryJobConfig); FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinueNudgeWhileExponentialBackOff); diff --git a/sync/engine/sync_scheduler_unittest.cc b/sync/engine/sync_scheduler_unittest.cc index a6d8059..d187d7d 100644 --- a/sync/engine/sync_scheduler_unittest.cc +++ b/sync/engine/sync_scheduler_unittest.cc @@ -1056,17 +1056,6 @@ TEST_F(SyncSchedulerTest, SyncerSteps) { StopSyncScheduler(); Mock::VerifyAndClearExpectations(syncer()); - // ClearUserData. - EXPECT_CALL(*syncer(), SyncShare(_, CLEAR_PRIVATE_DATA, CLEAR_PRIVATE_DATA)) - .WillOnce(Invoke(sessions::test_util::SimulateSuccess)); - StartSyncScheduler(SyncScheduler::NORMAL_MODE); - - scheduler()->ClearUserData(); - - StopSyncScheduler(); - Mock::VerifyAndClearExpectations(syncer()); - - // Configuration. EXPECT_CALL(*syncer(), SyncShare(_, DOWNLOAD_UPDATES, APPLY_UPDATES)) .WillOnce(Invoke(sessions::test_util::SimulateSuccess)); StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE); diff --git a/sync/engine/sync_scheduler_whitebox_unittest.cc b/sync/engine/sync_scheduler_whitebox_unittest.cc index 34ff7d9..dbfdec1 100644 --- a/sync/engine/sync_scheduler_whitebox_unittest.cc +++ b/sync/engine/sync_scheduler_whitebox_unittest.cc @@ -228,23 +228,6 @@ TEST_F(SyncSchedulerWhiteboxTest, SaveNudgeWhileThrottled) { EXPECT_EQ(decision, SyncScheduler::SAVE); } -TEST_F(SyncSchedulerWhiteboxTest, - ContinueClearUserDataUnderAllCircumstances) { - InitializeSyncerOnNormalMode(); - - SetMode(SyncScheduler::CONFIGURATION_MODE); - SetWaitIntervalToThrottled(); - SyncScheduler::JobProcessDecision decision = CreateAndDecideJob( - SyncScheduler::SyncSessionJob::CLEAR_USER_DATA); - EXPECT_EQ(decision, SyncScheduler::CONTINUE); - - SetMode(SyncScheduler::NORMAL_MODE); - SetWaitIntervalToExponentialBackoff(); - decision = CreateAndDecideJob( - SyncScheduler::SyncSessionJob::CLEAR_USER_DATA); - EXPECT_EQ(decision, SyncScheduler::CONTINUE); -} - TEST_F(SyncSchedulerWhiteboxTest, ContinueNudgeWhileExponentialBackOff) { InitializeSyncerOnNormalMode(); SetMode(SyncScheduler::NORMAL_MODE); diff --git a/sync/engine/syncer.cc b/sync/engine/syncer.cc index c17c0f8..01c8ae6 100644 --- a/sync/engine/syncer.cc +++ b/sync/engine/syncer.cc @@ -13,7 +13,6 @@ #include "sync/engine/apply_updates_command.h" #include "sync/engine/build_commit_command.h" #include "sync/engine/cleanup_disabled_types_command.h" -#include "sync/engine/clear_data_command.h" #include "sync/engine/commit.h" #include "sync/engine/conflict_resolver.h" #include "sync/engine/download_updates_command.h" @@ -68,7 +67,6 @@ const char* SyncerStepToString(const SyncerStep step) ENUM_CASE(COMMIT); ENUM_CASE(RESOLVE_CONFLICTS); ENUM_CASE(APPLY_UPDATES_TO_RESOLVE_CONFLICTS); - ENUM_CASE(CLEAR_PRIVATE_DATA); ENUM_CASE(SYNCER_END); } NOTREACHED(); @@ -226,12 +224,6 @@ void Syncer::SyncShare(sessions::SyncSession* session, next_step = SYNCER_END; break; } - case CLEAR_PRIVATE_DATA: { - ClearDataCommand clear_data_command; - clear_data_command.Execute(session); - next_step = SYNCER_END; - break; - } case SYNCER_END: { session->SendEventNotification(SyncEngineEvent::SYNC_CYCLE_ENDED); next_step = SYNCER_END; diff --git a/sync/engine/syncer.h b/sync/engine/syncer.h index 6092f64..9d2c32e 100644 --- a/sync/engine/syncer.h +++ b/sync/engine/syncer.h @@ -38,7 +38,6 @@ enum SyncerStep { COMMIT, RESOLVE_CONFLICTS, APPLY_UPDATES_TO_RESOLVE_CONFLICTS, - CLEAR_PRIVATE_DATA, // TODO(tim): Rename 'private' to 'user'. SYNCER_END }; |