[email protected] | ab44ef0e | 2011-03-22 21:52:44 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | // |
| 5 | // Mock ServerConnectionManager class for use in client unit tests. |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 6 | |
[email protected] | d07f0c8 | 2010-06-25 00:10:32 | [diff] [blame] | 7 | #ifndef CHROME_TEST_SYNC_ENGINE_MOCK_CONNECTION_MANAGER_H_ |
| 8 | #define CHROME_TEST_SYNC_ENGINE_MOCK_CONNECTION_MANAGER_H_ |
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 9 | #pragma once |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 10 | |
[email protected] | f753af6 | 2010-02-11 01:05:38 | [diff] [blame] | 11 | #include <bitset> |
[email protected] | a2669193 | 2011-01-13 21:00:08 | [diff] [blame] | 12 | #include <list> |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 13 | #include <string> |
| 14 | #include <vector> |
| 15 | |
[email protected] | a66e33a2 | 2010-07-16 14:06:11 | [diff] [blame] | 16 | #include "base/callback.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame^] | 17 | #include "base/memory/scoped_vector.h" |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 18 | #include "chrome/browser/sync/engine/net/server_connection_manager.h" |
| 19 | #include "chrome/browser/sync/protocol/sync.pb.h" |
| 20 | #include "chrome/browser/sync/syncable/directory_manager.h" |
[email protected] | f753af6 | 2010-02-11 01:05:38 | [diff] [blame] | 21 | #include "chrome/browser/sync/syncable/model_type.h" |
[email protected] | ab44ef0e | 2011-03-22 21:52:44 | [diff] [blame] | 22 | #include "chrome/browser/sync/syncable/model_type_payload_map.h" |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 23 | |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 24 | namespace syncable { |
| 25 | class DirectoryManager; |
| 26 | class ScopedDirLookup; |
| 27 | } |
| 28 | namespace browser_sync { |
| 29 | struct HttpResponse; |
| 30 | } |
| 31 | |
[email protected] | 5af80fa | 2009-09-14 18:34:07 | [diff] [blame] | 32 | class MockConnectionManager : public browser_sync::ServerConnectionManager { |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 33 | public: |
[email protected] | 2186fec4 | 2009-09-25 23:09:36 | [diff] [blame] | 34 | class MidCommitObserver { |
| 35 | public: |
| 36 | virtual void Observe() = 0; |
[email protected] | 8e4f010 | 2010-07-30 23:42:43 | [diff] [blame] | 37 | |
| 38 | protected: |
| 39 | virtual ~MidCommitObserver() {} |
[email protected] | 2186fec4 | 2009-09-25 23:09:36 | [diff] [blame] | 40 | }; |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 41 | |
[email protected] | 6d201be | 2009-11-13 19:40:59 | [diff] [blame] | 42 | MockConnectionManager(syncable::DirectoryManager* dirmgr, |
| 43 | const std::string& name); |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 44 | virtual ~MockConnectionManager(); |
| 45 | |
| 46 | // Overridden ServerConnectionManager functions. |
[email protected] | ca318f9 | 2011-01-25 22:49:02 | [diff] [blame] | 47 | virtual bool PostBufferToPath( |
| 48 | const PostBufferParams*, |
| 49 | const std::string& path, |
| 50 | const std::string& auth_token, |
[email protected] | 18a79705 | 2010-02-09 21:48:04 | [diff] [blame] | 51 | browser_sync::ScopedServerStatusWatcher* watcher); |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 52 | |
| 53 | virtual bool IsServerReachable(); |
| 54 | virtual bool IsUserAuthenticated(); |
| 55 | |
| 56 | // Control of commit response. |
[email protected] | a66e33a2 | 2010-07-16 14:06:11 | [diff] [blame] | 57 | void SetMidCommitCallback(Callback0::Type* callback); |
[email protected] | 2186fec4 | 2009-09-25 23:09:36 | [diff] [blame] | 58 | void SetMidCommitObserver(MidCommitObserver* observer); |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 59 | |
[email protected] | 5af80fa | 2009-09-14 18:34:07 | [diff] [blame] | 60 | // Set this if you want commit to perform commit time rename. Will request |
| 61 | // that the client renames all commited entries, prepending this string. |
[email protected] | ca318f9 | 2011-01-25 22:49:02 | [diff] [blame] | 62 | void SetCommitTimeRename(std::string prepend); |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 63 | |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 64 | // Generic versions of AddUpdate functions. Tests using these function should |
| 65 | // compile for both the int64 and string id based versions of the server. |
| 66 | // The SyncEntity returned is only valid until the Sync is completed |
| 67 | // (e.g. with SyncShare.) It allows to add further entity properties before |
[email protected] | fca8825 | 2010-06-30 03:57:44 | [diff] [blame] | 68 | // sync, using SetLastXXX() methods and/or GetMutableLastUpdate(). |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 69 | sync_pb::SyncEntity* AddUpdateDirectory(syncable::Id id, |
| 70 | syncable::Id parent_id, |
[email protected] | ca318f9 | 2011-01-25 22:49:02 | [diff] [blame] | 71 | std::string name, |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 72 | int64 version, |
| 73 | int64 sync_ts); |
| 74 | sync_pb::SyncEntity* AddUpdateBookmark(syncable::Id id, |
| 75 | syncable::Id parent_id, |
[email protected] | ca318f9 | 2011-01-25 22:49:02 | [diff] [blame] | 76 | std::string name, |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 77 | int64 version, |
| 78 | int64 sync_ts); |
| 79 | // Versions of the AddUpdate functions that accept integer IDs. |
| 80 | sync_pb::SyncEntity* AddUpdateDirectory(int id, |
| 81 | int parent_id, |
[email protected] | ca318f9 | 2011-01-25 22:49:02 | [diff] [blame] | 82 | std::string name, |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 83 | int64 version, |
| 84 | int64 sync_ts); |
| 85 | sync_pb::SyncEntity* AddUpdateBookmark(int id, |
| 86 | int parent_id, |
[email protected] | ca318f9 | 2011-01-25 22:49:02 | [diff] [blame] | 87 | std::string name, |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 88 | int64 version, |
| 89 | int64 sync_ts); |
| 90 | // New protocol versions of the AddUpdate functions. |
[email protected] | ca318f9 | 2011-01-25 22:49:02 | [diff] [blame] | 91 | sync_pb::SyncEntity* AddUpdateDirectory(std::string id, |
| 92 | std::string parent_id, |
| 93 | std::string name, |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 94 | int64 version, |
| 95 | int64 sync_ts); |
[email protected] | ca318f9 | 2011-01-25 22:49:02 | [diff] [blame] | 96 | sync_pb::SyncEntity* AddUpdateBookmark(std::string id, |
| 97 | std::string parent_id, |
| 98 | std::string name, |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 99 | int64 version, |
| 100 | int64 sync_ts); |
[email protected] | 55779e6 | 2010-07-13 20:27:11 | [diff] [blame] | 101 | |
| 102 | // Find the last commit sent by the client, and replay it for the next get |
| 103 | // updates command. This can be used to simulate the GetUpdates that happens |
| 104 | // immediately after a successful commit. |
| 105 | sync_pb::SyncEntity* AddUpdateFromLastCommit(); |
| 106 | |
| 107 | // Add a deleted item. Deletion records typically contain no |
| 108 | // additional information beyond the deletion, and no specifics. |
| 109 | // The server may send the originator fields. |
| 110 | void AddUpdateTombstone(const syncable::Id& id); |
| 111 | |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 112 | void SetLastUpdateDeleted(); |
[email protected] | ca318f9 | 2011-01-25 22:49:02 | [diff] [blame] | 113 | void SetLastUpdateServerTag(const std::string& tag); |
| 114 | void SetLastUpdateClientTag(const std::string& tag); |
| 115 | void SetLastUpdateOriginatorFields(const std::string& client_id, |
| 116 | const std::string& entry_id); |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 117 | void SetLastUpdatePosition(int64 position_in_parent); |
[email protected] | a2669193 | 2011-01-13 21:00:08 | [diff] [blame] | 118 | void SetNewTimestamp(int ts); |
| 119 | void SetChangesRemaining(int64 count); |
| 120 | |
| 121 | // Add a new batch of updates after the current one. Allows multiple |
| 122 | // GetUpdates responses to be buffered up, since the syncer may |
| 123 | // issue multiple requests during a sync cycle. |
| 124 | void NextUpdateBatch(); |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 125 | |
[email protected] | 3c47992 | 2009-10-07 23:57:20 | [diff] [blame] | 126 | // For AUTHENTICATE responses. |
| 127 | void SetAuthenticationResponseInfo(const std::string& valid_auth_token, |
| 128 | const std::string& user_display_name, |
| 129 | const std::string& user_display_email, |
| 130 | const std::string& user_obfuscated_id); |
| 131 | |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 132 | void FailNextPostBufferToPathCall() { fail_next_postbuffer_ = true; } |
| 133 | |
[email protected] | 689a7a7 | 2010-09-29 19:56:41 | [diff] [blame] | 134 | void SetClearUserDataResponseStatus( |
| 135 | sync_pb::ClientToServerResponse::ErrorType errortype); |
[email protected] | 1ce52aa | 2010-09-08 19:07:36 | [diff] [blame] | 136 | |
[email protected] | 1b4ec9a | 2009-10-16 01:31:55 | [diff] [blame] | 137 | // A visitor class to allow a test to change some monitoring state atomically |
[email protected] | 18a79705 | 2010-02-09 21:48:04 | [diff] [blame] | 138 | // with the action of overriding the response codes sent back to the Syncer |
| 139 | // (for example, so you can say "ThrottleNextRequest, and assert no more |
| 140 | // requests are made once throttling is in effect" in one step. |
| 141 | class ResponseCodeOverrideRequestor { |
[email protected] | 1b4ec9a | 2009-10-16 01:31:55 | [diff] [blame] | 142 | public: |
[email protected] | 18a79705 | 2010-02-09 21:48:04 | [diff] [blame] | 143 | // Called with response_code_override_lock_ acquired. |
| 144 | virtual void OnOverrideComplete() = 0; |
[email protected] | 8e4f010 | 2010-07-30 23:42:43 | [diff] [blame] | 145 | |
| 146 | protected: |
| 147 | virtual ~ResponseCodeOverrideRequestor() {} |
[email protected] | 1b4ec9a | 2009-10-16 01:31:55 | [diff] [blame] | 148 | }; |
[email protected] | 18a79705 | 2010-02-09 21:48:04 | [diff] [blame] | 149 | void ThrottleNextRequest(ResponseCodeOverrideRequestor* visitor); |
| 150 | void FailWithAuthInvalid(ResponseCodeOverrideRequestor* visitor); |
| 151 | void StopFailingWithAuthInvalid(ResponseCodeOverrideRequestor* visitor); |
[email protected] | 1b4ec9a | 2009-10-16 01:31:55 | [diff] [blame] | 152 | void FailNonPeriodicGetUpdates() { fail_non_periodic_get_updates_ = true; } |
| 153 | |
[email protected] | 5af80fa | 2009-09-14 18:34:07 | [diff] [blame] | 154 | // Simple inspectors. |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 155 | bool client_stuck() const { return client_stuck_; } |
| 156 | |
| 157 | sync_pb::ClientCommand* GetNextClientCommand(); |
| 158 | |
[email protected] | f753af6 | 2010-02-11 01:05:38 | [diff] [blame] | 159 | const std::vector<syncable::Id>& committed_ids() const { |
| 160 | return committed_ids_; |
| 161 | } |
| 162 | const std::vector<sync_pb::CommitMessage*>& commit_messages() const { |
[email protected] | 55779e6 | 2010-07-13 20:27:11 | [diff] [blame] | 163 | return commit_messages_.get(); |
| 164 | } |
| 165 | const std::vector<sync_pb::CommitResponse*>& commit_responses() const { |
| 166 | return commit_responses_.get(); |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 167 | } |
| 168 | // Retrieve the last sent commit message. |
| 169 | const sync_pb::CommitMessage& last_sent_commit() const; |
| 170 | |
[email protected] | 55779e6 | 2010-07-13 20:27:11 | [diff] [blame] | 171 | // Retrieve the last returned commit response. |
| 172 | const sync_pb::CommitResponse& last_commit_response() const; |
| 173 | |
[email protected] | 29574e6 | 2010-04-01 22:39:59 | [diff] [blame] | 174 | // Retrieve the last request submitted to the server (regardless of type). |
| 175 | const sync_pb::ClientToServerMessage& last_request() const { |
| 176 | return last_request_; |
| 177 | } |
| 178 | |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 179 | void set_conflict_all_commits(bool value) { |
| 180 | conflict_all_commits_ = value; |
| 181 | } |
| 182 | void set_next_new_id(int value) { |
| 183 | next_new_id_ = value; |
| 184 | } |
| 185 | void set_conflict_n_commits(int value) { |
| 186 | conflict_n_commits_ = value; |
| 187 | } |
| 188 | |
[email protected] | 3273dce | 2010-01-27 16:08:08 | [diff] [blame] | 189 | void set_use_legacy_bookmarks_protocol(bool value) { |
| 190 | use_legacy_bookmarks_protocol_ = value; |
| 191 | } |
| 192 | |
[email protected] | ca318f9 | 2011-01-25 22:49:02 | [diff] [blame] | 193 | void set_store_birthday(std::string new_birthday) { |
[email protected] | ca2fcc2 | 2010-09-07 23:52:04 | [diff] [blame] | 194 | // Multiple threads can set store_birthday_ in our tests, need to lock it to |
| 195 | // ensure atomic read/writes and avoid race conditions. |
[email protected] | 20305ec | 2011-01-21 04:55:52 | [diff] [blame] | 196 | base::AutoLock lock(store_birthday_lock_); |
[email protected] | 7f8abea | 2010-07-14 01:31:36 | [diff] [blame] | 197 | store_birthday_ = new_birthday; |
| 198 | } |
| 199 | |
[email protected] | f753af6 | 2010-02-11 01:05:38 | [diff] [blame] | 200 | // Retrieve the number of GetUpdates requests that the mock server has |
| 201 | // seen since the last time this function was called. Can be used to |
| 202 | // verify that a GetUpdates actually did or did not happen after running |
| 203 | // the syncer. |
| 204 | int GetAndClearNumGetUpdatesRequests() { |
| 205 | int result = num_get_updates_requests_; |
| 206 | num_get_updates_requests_ = 0; |
| 207 | return result; |
| 208 | } |
| 209 | |
| 210 | // Expect that GetUpdates will request exactly the types indicated in |
| 211 | // the bitset. |
| 212 | void ExpectGetUpdatesRequestTypes( |
| 213 | std::bitset<syncable::MODEL_TYPE_COUNT> expected_filter) { |
| 214 | expected_filter_ = expected_filter; |
| 215 | } |
| 216 | |
[email protected] | 0a9c906 | 2011-02-28 23:54:58 | [diff] [blame] | 217 | void ExpectGetUpdatesRequestPayloads( |
[email protected] | ab44ef0e | 2011-03-22 21:52:44 | [diff] [blame] | 218 | const syncable::ModelTypePayloadMap& payloads) { |
[email protected] | 0a9c906 | 2011-02-28 23:54:58 | [diff] [blame] | 219 | expected_payloads_ = payloads; |
| 220 | } |
| 221 | |
[email protected] | 894f4a0 | 2010-06-29 20:37:06 | [diff] [blame] | 222 | void SetServerReachable(); |
| 223 | |
| 224 | void SetServerNotReachable(); |
| 225 | |
[email protected] | ca2fcc2 | 2010-09-07 23:52:04 | [diff] [blame] | 226 | // Const necessary to avoid any hidden copy-on-write issues that would break |
| 227 | // in multithreaded scenarios (see |set_store_birthday|). |
| 228 | const std::string& store_birthday() { |
[email protected] | 20305ec | 2011-01-21 04:55:52 | [diff] [blame] | 229 | base::AutoLock lock(store_birthday_lock_); |
[email protected] | ca2fcc2 | 2010-09-07 23:52:04 | [diff] [blame] | 230 | return store_birthday_; |
| 231 | } |
[email protected] | 55779e6 | 2010-07-13 20:27:11 | [diff] [blame] | 232 | |
| 233 | // Locate the most recent update message for purpose of alteration. |
| 234 | sync_pb::SyncEntity* GetMutableLastUpdate(); |
| 235 | |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 236 | private: |
| 237 | sync_pb::SyncEntity* AddUpdateFull(syncable::Id id, syncable::Id parentid, |
[email protected] | ca318f9 | 2011-01-25 22:49:02 | [diff] [blame] | 238 | std::string name, int64 version, |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 239 | int64 sync_ts, |
| 240 | bool is_dir); |
[email protected] | ca318f9 | 2011-01-25 22:49:02 | [diff] [blame] | 241 | sync_pb::SyncEntity* AddUpdateFull(std::string id, |
| 242 | std::string parentid, std::string name, |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 243 | int64 version, int64 sync_ts, |
| 244 | bool is_dir); |
| 245 | // Functions to handle the various types of server request. |
| 246 | void ProcessGetUpdates(sync_pb::ClientToServerMessage* csm, |
| 247 | sync_pb::ClientToServerResponse* response); |
[email protected] | 3c47992 | 2009-10-07 23:57:20 | [diff] [blame] | 248 | void ProcessAuthenticate(sync_pb::ClientToServerMessage* csm, |
| 249 | sync_pb::ClientToServerResponse* response, |
| 250 | const std::string& auth_token); |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 251 | void ProcessCommit(sync_pb::ClientToServerMessage* csm, |
| 252 | sync_pb::ClientToServerResponse* response_buffer); |
[email protected] | 1ce52aa | 2010-09-08 19:07:36 | [diff] [blame] | 253 | void ProcessClearData(sync_pb::ClientToServerMessage* csm, |
| 254 | sync_pb::ClientToServerResponse* response); |
[email protected] | 3273dce | 2010-01-27 16:08:08 | [diff] [blame] | 255 | void AddDefaultBookmarkData(sync_pb::SyncEntity* entity, bool is_folder); |
| 256 | |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 257 | // Determine if one entry in a commit should be rejected with a conflict. |
| 258 | bool ShouldConflictThisCommit(); |
| 259 | |
[email protected] | 5af80fa | 2009-09-14 18:34:07 | [diff] [blame] | 260 | // Generate a numeric position_in_parent value. We use a global counter |
| 261 | // that only decreases; this simulates new objects always being added to the |
| 262 | // front of the ordering. |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 263 | int64 GeneratePositionInParent() { |
| 264 | return next_position_in_parent_--; |
| 265 | } |
| 266 | |
[email protected] | a2669193 | 2011-01-13 21:00:08 | [diff] [blame] | 267 | // Get a mutable update response which will eventually be returned to the |
| 268 | // client. |
| 269 | sync_pb::GetUpdatesResponse* GetUpdateResponse(); |
| 270 | void ApplyToken(); |
| 271 | |
| 272 | // Determine whether an progress marker array (like that sent in |
| 273 | // GetUpdates.from_progress_marker) indicates that a particular ModelType |
[email protected] | f753af6 | 2010-02-11 01:05:38 | [diff] [blame] | 274 | // should be included. |
[email protected] | a2669193 | 2011-01-13 21:00:08 | [diff] [blame] | 275 | bool IsModelTypePresentInSpecifics( |
| 276 | const google::protobuf::RepeatedPtrField< |
| 277 | sync_pb::DataTypeProgressMarker>& filter, |
[email protected] | f753af6 | 2010-02-11 01:05:38 | [diff] [blame] | 278 | syncable::ModelType value); |
| 279 | |
[email protected] | 0a9c906 | 2011-02-28 23:54:58 | [diff] [blame] | 280 | sync_pb::DataTypeProgressMarker const* GetProgressMarkerForType( |
| 281 | const google::protobuf::RepeatedPtrField< |
| 282 | sync_pb::DataTypeProgressMarker>& filter, |
| 283 | syncable::ModelType value); |
| 284 | |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 285 | // All IDs that have been committed. |
[email protected] | f753af6 | 2010-02-11 01:05:38 | [diff] [blame] | 286 | std::vector<syncable::Id> committed_ids_; |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 287 | |
| 288 | // Control of when/if we return conflicts. |
| 289 | bool conflict_all_commits_; |
| 290 | int conflict_n_commits_; |
| 291 | |
[email protected] | 55779e6 | 2010-07-13 20:27:11 | [diff] [blame] | 292 | // Commit messages we've sent, and responses we've returned. |
| 293 | ScopedVector<sync_pb::CommitMessage> commit_messages_; |
| 294 | ScopedVector<sync_pb::CommitResponse> commit_responses_; |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 295 | |
| 296 | // The next id the mock will return to a commit. |
| 297 | int next_new_id_; |
| 298 | |
| 299 | // The store birthday we send to the client. |
[email protected] | ca318f9 | 2011-01-25 22:49:02 | [diff] [blame] | 300 | std::string store_birthday_; |
[email protected] | 20305ec | 2011-01-21 04:55:52 | [diff] [blame] | 301 | base::Lock store_birthday_lock_; |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 302 | bool store_birthday_sent_; |
| 303 | bool client_stuck_; |
[email protected] | ca318f9 | 2011-01-25 22:49:02 | [diff] [blame] | 304 | std::string commit_time_rename_prepended_string_; |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 305 | |
[email protected] | 5af80fa | 2009-09-14 18:34:07 | [diff] [blame] | 306 | // Fail on the next call to PostBufferToPath(). |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 307 | bool fail_next_postbuffer_; |
| 308 | |
| 309 | // Our directory. |
[email protected] | 2186fec4 | 2009-09-25 23:09:36 | [diff] [blame] | 310 | syncable::DirectoryManager* directory_manager_; |
[email protected] | 6d201be | 2009-11-13 19:40:59 | [diff] [blame] | 311 | std::string directory_name_; |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 312 | |
| 313 | // The updates we'll return to the next request. |
[email protected] | a2669193 | 2011-01-13 21:00:08 | [diff] [blame] | 314 | std::list<sync_pb::GetUpdatesResponse> update_queue_; |
[email protected] | a66e33a2 | 2010-07-16 14:06:11 | [diff] [blame] | 315 | scoped_ptr<Callback0::Type> mid_commit_callback_; |
[email protected] | 2186fec4 | 2009-09-25 23:09:36 | [diff] [blame] | 316 | MidCommitObserver* mid_commit_observer_; |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 317 | |
[email protected] | 1ce52aa | 2010-09-08 19:07:36 | [diff] [blame] | 318 | // The clear data response we'll return in the next response |
[email protected] | 689a7a7 | 2010-09-29 19:56:41 | [diff] [blame] | 319 | sync_pb::ClientToServerResponse::ErrorType |
| 320 | clear_user_data_response_errortype_; |
[email protected] | 1ce52aa | 2010-09-08 19:07:36 | [diff] [blame] | 321 | |
[email protected] | 3c47992 | 2009-10-07 23:57:20 | [diff] [blame] | 322 | // The AUTHENTICATE response we'll return for auth requests. |
| 323 | sync_pb::AuthenticateResponse auth_response_; |
| 324 | // What we use to determine if we should return SUCCESS or BAD_AUTH_TOKEN. |
| 325 | std::string valid_auth_token_; |
| 326 | |
[email protected] | 1b4ec9a | 2009-10-16 01:31:55 | [diff] [blame] | 327 | // Whether we are faking a server mandating clients to throttle requests. |
[email protected] | 18a79705 | 2010-02-09 21:48:04 | [diff] [blame] | 328 | // Protected by |response_code_override_lock_|. |
[email protected] | 1b4ec9a | 2009-10-16 01:31:55 | [diff] [blame] | 329 | bool throttling_; |
[email protected] | 18a79705 | 2010-02-09 21:48:04 | [diff] [blame] | 330 | |
| 331 | // Whether we are failing all requests by returning |
| 332 | // ClientToServerResponse::AUTH_INVALID. |
| 333 | // Protected by |response_code_override_lock_|. |
| 334 | bool fail_with_auth_invalid_; |
| 335 | |
[email protected] | 20305ec | 2011-01-21 04:55:52 | [diff] [blame] | 336 | base::Lock response_code_override_lock_; |
[email protected] | 1b4ec9a | 2009-10-16 01:31:55 | [diff] [blame] | 337 | |
| 338 | // True if we are only accepting GetUpdatesCallerInfo::PERIODIC requests. |
| 339 | bool fail_non_periodic_get_updates_; |
| 340 | |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 341 | scoped_ptr<sync_pb::ClientCommand> client_command_; |
| 342 | |
| 343 | // The next value to use for the position_in_parent property. |
| 344 | int64 next_position_in_parent_; |
| 345 | |
[email protected] | 3273dce | 2010-01-27 16:08:08 | [diff] [blame] | 346 | // The default is to use the newer sync_pb::BookmarkSpecifics-style protocol. |
| 347 | // If this option is set to true, then the MockConnectionManager will |
| 348 | // use the older sync_pb::SyncEntity_BookmarkData-style protocol. |
| 349 | bool use_legacy_bookmarks_protocol_; |
| 350 | |
[email protected] | f753af6 | 2010-02-11 01:05:38 | [diff] [blame] | 351 | std::bitset<syncable::MODEL_TYPE_COUNT> expected_filter_; |
| 352 | |
[email protected] | ab44ef0e | 2011-03-22 21:52:44 | [diff] [blame] | 353 | syncable::ModelTypePayloadMap expected_payloads_; |
[email protected] | 0a9c906 | 2011-02-28 23:54:58 | [diff] [blame] | 354 | |
[email protected] | f753af6 | 2010-02-11 01:05:38 | [diff] [blame] | 355 | int num_get_updates_requests_; |
| 356 | |
[email protected] | a2669193 | 2011-01-13 21:00:08 | [diff] [blame] | 357 | std::string next_token_; |
| 358 | |
[email protected] | 29574e6 | 2010-04-01 22:39:59 | [diff] [blame] | 359 | sync_pb::ClientToServerMessage last_request_; |
| 360 | |
[email protected] | 5852edc1b | 2009-09-10 06:05:27 | [diff] [blame] | 361 | DISALLOW_COPY_AND_ASSIGN(MockConnectionManager); |
| 362 | }; |
| 363 | |
[email protected] | d07f0c8 | 2010-06-25 00:10:32 | [diff] [blame] | 364 | #endif // CHROME_TEST_SYNC_ENGINE_MOCK_CONNECTION_MANAGER_H_ |