diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-12 23:49:30 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-12 23:49:30 +0000 |
commit | 4c49346d6588d32cb6541056bb4e0397417c5728 (patch) | |
tree | 5b6b9860c6ff11c8fafb2d796b45927acbe83e40 /sync/test | |
parent | bb8dc8c9257e660399fcb56a4c15a240b6d8e2dc (diff) | |
download | chromium_src-4c49346d6588d32cb6541056bb4e0397417c5728.zip chromium_src-4c49346d6588d32cb6541056bb4e0397417c5728.tar.gz chromium_src-4c49346d6588d32cb6541056bb4e0397417c5728.tar.bz2 |
sync: Process client commands on commit response
The server sends down client commands on both commit and get update
responses. Prior to this change, the client would only react to the
commands sent in the get update response. Now it will respond to
commands sent in either message.
BUG=147680
Review URL: https://chromiumcodereview.appspot.com/10909160
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/test')
-rw-r--r-- | sync/test/engine/mock_connection_manager.cc | 27 | ||||
-rw-r--r-- | sync/test/engine/mock_connection_manager.h | 7 |
2 files changed, 24 insertions, 10 deletions
diff --git a/sync/test/engine/mock_connection_manager.cc b/sync/test/engine/mock_connection_manager.cc index 0d4041b..8d03a10 100644 --- a/sync/test/engine/mock_connection_manager.cc +++ b/sync/test/engine/mock_connection_manager.cc @@ -48,7 +48,8 @@ MockConnectionManager::MockConnectionManager(syncable::Directory* directory) throttling_(false), fail_with_auth_invalid_(false), fail_non_periodic_get_updates_(false), - client_command_(NULL), + gu_client_command_(NULL), + commit_client_command_(NULL), next_position_in_parent_(2), use_legacy_bookmarks_protocol_(false), num_get_updates_requests_(0) { @@ -143,9 +144,6 @@ bool MockConnectionManager::PostBufferToPath(PostBufferParams* params, EXPECT_TRUE(false) << "Unknown/unsupported ClientToServerMessage"; return false; } - if (client_command_.get()) { - response.mutable_client_command()->CopyFrom(*client_command_.get()); - } { base::AutoLock lock(response_code_override_lock_); @@ -210,10 +208,14 @@ sync_pb::SyncEntity* MockConnectionManager::AddUpdateDirectory( sync_ts); } -sync_pb::ClientCommand* MockConnectionManager::GetNextClientCommand() { - if (!client_command_.get()) - client_command_.reset(new sync_pb::ClientCommand()); - return client_command_.get(); +void MockConnectionManager::SetGUClientCommand( + sync_pb::ClientCommand* command) { + gu_client_command_.reset(command); +} + +void MockConnectionManager::SetCommitClientCommand( + sync_pb::ClientCommand* command) { + commit_client_command_.reset(command); } sync_pb::SyncEntity* MockConnectionManager::AddUpdateBookmark( @@ -453,6 +455,10 @@ void MockConnectionManager::ProcessGetUpdates( response->mutable_get_updates()->set_encryption_key(keystore_key_); update_queue_.pop_front(); + + if (gu_client_command_.get()) { + response->mutable_client_command()->CopyFrom(*gu_client_command_.get()); + } } void MockConnectionManager::SetKeystoreKey(const std::string& key) { @@ -524,6 +530,11 @@ void MockConnectionManager::ProcessCommit( } } commit_responses_.push_back(new CommitResponse(*commit_response)); + + if (commit_client_command_.get()) { + response_buffer->mutable_client_command()->CopyFrom( + *commit_client_command_.get()); + } } sync_pb::SyncEntity* MockConnectionManager::AddUpdateDirectory( diff --git a/sync/test/engine/mock_connection_manager.h b/sync/test/engine/mock_connection_manager.h index 7c5271c..617e39d 100644 --- a/sync/test/engine/mock_connection_manager.h +++ b/sync/test/engine/mock_connection_manager.h @@ -129,7 +129,9 @@ class MockConnectionManager : public ServerConnectionManager { // Simple inspectors. bool client_stuck() const { return client_stuck_; } - sync_pb::ClientCommand* GetNextClientCommand(); + // warning: These take ownership of their input. + void SetGUClientCommand(sync_pb::ClientCommand* command); + void SetCommitClientCommand(sync_pb::ClientCommand* command); const std::vector<syncable::Id>& committed_ids() const { return committed_ids_; @@ -326,7 +328,8 @@ class MockConnectionManager : public ServerConnectionManager { // True if we are only accepting GetUpdatesCallerInfo::PERIODIC requests. bool fail_non_periodic_get_updates_; - scoped_ptr<sync_pb::ClientCommand> client_command_; + scoped_ptr<sync_pb::ClientCommand> gu_client_command_; + scoped_ptr<sync_pb::ClientCommand> commit_client_command_; // The next value to use for the position_in_parent property. int64 next_position_in_parent_; |