sync: Remove ModelNeutralExecuteImpl()

ProcessUpdatesCommand was the only child of ModelChangingSyncerCommand
to override this function.  Since it is special, let's just treat it
specially in syncer.cc rather than modifying ModelChangingSyncerCommand
to suit its needs.

BUG=36594
TEST=


Review URL: http://codereview.chromium.org/8510079

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110555 0039d316-1c4b-4281-b951-d872f2087c98
parent 12465ec0
...@@ -15,9 +15,6 @@ namespace browser_sync { ...@@ -15,9 +15,6 @@ namespace browser_sync {
void ModelChangingSyncerCommand::ExecuteImpl(sessions::SyncSession* session) { void ModelChangingSyncerCommand::ExecuteImpl(sessions::SyncSession* session) {
work_session_ = session; work_session_ = session;
if (!ModelNeutralExecuteImpl(work_session_)) {
return;
}
// Project the list of active types (i.e., types in the routing // Project the list of active types (i.e., types in the routing
// info) to a list of groups. // info) to a list of groups.
...@@ -59,9 +56,4 @@ void ModelChangingSyncerCommand::ExecuteImpl(sessions::SyncSession* session) { ...@@ -59,9 +56,4 @@ void ModelChangingSyncerCommand::ExecuteImpl(sessions::SyncSession* session) {
} }
} }
bool ModelChangingSyncerCommand::ModelNeutralExecuteImpl(
sessions::SyncSession* session) {
return true;
}
} // namespace browser_sync } // namespace browser_sync
...@@ -40,14 +40,6 @@ class ModelChangingSyncerCommand : public SyncerCommand { ...@@ -40,14 +40,6 @@ class ModelChangingSyncerCommand : public SyncerCommand {
return UnrecoverableErrorInfo(); return UnrecoverableErrorInfo();
} }
// Sometimes, a command has work to do that needs to touch global state
// belonging to multiple ModelSafeGroups, but in a way that is known to be
// safe. This will be called once, prior to ModelChangingExecuteImpl,
// *without* a ModelSafeGroup restriction in place on the SyncSession.
// Returns true on success, false on failure.
// TODO(tim): Remove this (bug 36594).
virtual bool ModelNeutralExecuteImpl(sessions::SyncSession* session);
// Abstract method to be implemented by subclasses to handle logic that // Abstract method to be implemented by subclasses to handle logic that
// operates on the model. This is invoked with a SyncSession ModelSafeGroup // operates on the model. This is invoked with a SyncSession ModelSafeGroup
// restriction in place so that bits of state belonging to data types // restriction in place so that bits of state belonging to data types
......
...@@ -26,15 +26,6 @@ using sessions::StatusController; ...@@ -26,15 +26,6 @@ using sessions::StatusController;
ProcessUpdatesCommand::ProcessUpdatesCommand() {} ProcessUpdatesCommand::ProcessUpdatesCommand() {}
ProcessUpdatesCommand::~ProcessUpdatesCommand() {} ProcessUpdatesCommand::~ProcessUpdatesCommand() {}
bool ProcessUpdatesCommand::ModelNeutralExecuteImpl(SyncSession* session) {
const GetUpdatesResponse& updates =
session->status_controller()->updates_response().get_updates();
const int update_count = updates.entries_size();
// Don't bother processing updates if there were none.
return update_count != 0;
}
void ProcessUpdatesCommand::ModelChangingExecuteImpl(SyncSession* session) { void ProcessUpdatesCommand::ModelChangingExecuteImpl(SyncSession* session) {
syncable::ScopedDirLookup dir(session->context()->directory_manager(), syncable::ScopedDirLookup dir(session->context()->directory_manager(),
session->context()->account_name()); session->context()->account_name());
......
...@@ -34,7 +34,6 @@ class ProcessUpdatesCommand : public ModelChangingSyncerCommand { ...@@ -34,7 +34,6 @@ class ProcessUpdatesCommand : public ModelChangingSyncerCommand {
virtual ~ProcessUpdatesCommand(); virtual ~ProcessUpdatesCommand();
// ModelChangingSyncerCommand implementation. // ModelChangingSyncerCommand implementation.
virtual bool ModelNeutralExecuteImpl(sessions::SyncSession* session);
virtual void ModelChangingExecuteImpl(sessions::SyncSession* session); virtual void ModelChangingExecuteImpl(sessions::SyncSession* session);
private: private:
......
...@@ -143,8 +143,10 @@ void Syncer::SyncShare(sessions::SyncSession* session, ...@@ -143,8 +143,10 @@ void Syncer::SyncShare(sessions::SyncSession* session,
} }
case PROCESS_UPDATES: { case PROCESS_UPDATES: {
VLOG(1) << "Processing Updates"; VLOG(1) << "Processing Updates";
ProcessUpdatesCommand process_updates; if (session->status_controller()->ResponseContainsUpdates()) {
process_updates.Execute(session); ProcessUpdatesCommand process_updates;
process_updates.Execute(session);
}
next_step = STORE_TIMESTAMPS; next_step = STORE_TIMESTAMPS;
break; break;
} }
......
...@@ -242,6 +242,10 @@ bool StatusController::ServerSaysNothingMoreToDownload() const { ...@@ -242,6 +242,10 @@ bool StatusController::ServerSaysNothingMoreToDownload() const {
return updates_response().get_updates().changes_remaining() == 0; return updates_response().get_updates().changes_remaining() == 0;
} }
bool StatusController::ResponseContainsUpdates() const {
return updates_response().get_updates().entries_size() != 0;
}
void StatusController::set_debug_info_sent() { void StatusController::set_debug_info_sent() {
shared_.control_params.debug_info_sent = true; shared_.control_params.debug_info_sent = true;
} }
......
...@@ -189,6 +189,9 @@ class StatusController { ...@@ -189,6 +189,9 @@ class StatusController {
// download: in that case, this also returns false. // download: in that case, this also returns false.
bool ServerSaysNothingMoreToDownload() const; bool ServerSaysNothingMoreToDownload() const;
// Returns true if there are updates to be processed.
bool ResponseContainsUpdates() const;
ModelSafeGroup group_restriction() const { ModelSafeGroup group_restriction() const {
return group_restriction_; return group_restriction_;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment