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

Side by Side Diff: chrome/test/sync/engine/mock_connection_manager.h

Issue 6304021: [Sync] Remove now-obsolete FastDump class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/chrome.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Mock ServerConnectionManager class for use in client unit tests. 5 // Mock ServerConnectionManager class for use in client unit tests.
6 6
7 #ifndef CHROME_TEST_SYNC_ENGINE_MOCK_CONNECTION_MANAGER_H_ 7 #ifndef CHROME_TEST_SYNC_ENGINE_MOCK_CONNECTION_MANAGER_H_
8 #define CHROME_TEST_SYNC_ENGINE_MOCK_CONNECTION_MANAGER_H_ 8 #define CHROME_TEST_SYNC_ENGINE_MOCK_CONNECTION_MANAGER_H_
9 #pragma once 9 #pragma once
10 10
(...skipping 25 matching lines...) Expand all
36 36
37 protected: 37 protected:
38 virtual ~MidCommitObserver() {} 38 virtual ~MidCommitObserver() {}
39 }; 39 };
40 40
41 MockConnectionManager(syncable::DirectoryManager* dirmgr, 41 MockConnectionManager(syncable::DirectoryManager* dirmgr,
42 const std::string& name); 42 const std::string& name);
43 virtual ~MockConnectionManager(); 43 virtual ~MockConnectionManager();
44 44
45 // Overridden ServerConnectionManager functions. 45 // Overridden ServerConnectionManager functions.
46 virtual bool PostBufferToPath(const PostBufferParams*, 46 virtual bool PostBufferToPath(
47 const string& path, 47 const PostBufferParams*,
48 const string& auth_token, 48 const std::string& path,
49 const std::string& auth_token,
49 browser_sync::ScopedServerStatusWatcher* watcher); 50 browser_sync::ScopedServerStatusWatcher* watcher);
50 51
51 virtual bool IsServerReachable(); 52 virtual bool IsServerReachable();
52 virtual bool IsUserAuthenticated(); 53 virtual bool IsUserAuthenticated();
53 54
54 // Control of commit response. 55 // Control of commit response.
55 void SetMidCommitCallback(Callback0::Type* callback); 56 void SetMidCommitCallback(Callback0::Type* callback);
56 void SetMidCommitObserver(MidCommitObserver* observer); 57 void SetMidCommitObserver(MidCommitObserver* observer);
57 58
58 // Set this if you want commit to perform commit time rename. Will request 59 // Set this if you want commit to perform commit time rename. Will request
59 // that the client renames all commited entries, prepending this string. 60 // that the client renames all commited entries, prepending this string.
60 void SetCommitTimeRename(string prepend); 61 void SetCommitTimeRename(std::string prepend);
61 62
62 // Generic versions of AddUpdate functions. Tests using these function should 63 // Generic versions of AddUpdate functions. Tests using these function should
63 // compile for both the int64 and string id based versions of the server. 64 // compile for both the int64 and string id based versions of the server.
64 // The SyncEntity returned is only valid until the Sync is completed 65 // The SyncEntity returned is only valid until the Sync is completed
65 // (e.g. with SyncShare.) It allows to add further entity properties before 66 // (e.g. with SyncShare.) It allows to add further entity properties before
66 // sync, using SetLastXXX() methods and/or GetMutableLastUpdate(). 67 // sync, using SetLastXXX() methods and/or GetMutableLastUpdate().
67 sync_pb::SyncEntity* AddUpdateDirectory(syncable::Id id, 68 sync_pb::SyncEntity* AddUpdateDirectory(syncable::Id id,
68 syncable::Id parent_id, 69 syncable::Id parent_id,
69 string name, 70 std::string name,
70 int64 version, 71 int64 version,
71 int64 sync_ts); 72 int64 sync_ts);
72 sync_pb::SyncEntity* AddUpdateBookmark(syncable::Id id, 73 sync_pb::SyncEntity* AddUpdateBookmark(syncable::Id id,
73 syncable::Id parent_id, 74 syncable::Id parent_id,
74 string name, 75 std::string name,
75 int64 version, 76 int64 version,
76 int64 sync_ts); 77 int64 sync_ts);
77 // Versions of the AddUpdate functions that accept integer IDs. 78 // Versions of the AddUpdate functions that accept integer IDs.
78 sync_pb::SyncEntity* AddUpdateDirectory(int id, 79 sync_pb::SyncEntity* AddUpdateDirectory(int id,
79 int parent_id, 80 int parent_id,
80 string name, 81 std::string name,
81 int64 version, 82 int64 version,
82 int64 sync_ts); 83 int64 sync_ts);
83 sync_pb::SyncEntity* AddUpdateBookmark(int id, 84 sync_pb::SyncEntity* AddUpdateBookmark(int id,
84 int parent_id, 85 int parent_id,
85 string name, 86 std::string name,
86 int64 version, 87 int64 version,
87 int64 sync_ts); 88 int64 sync_ts);
88 // New protocol versions of the AddUpdate functions. 89 // New protocol versions of the AddUpdate functions.
89 sync_pb::SyncEntity* AddUpdateDirectory(string id, 90 sync_pb::SyncEntity* AddUpdateDirectory(std::string id,
90 string parent_id, 91 std::string parent_id,
91 string name, 92 std::string name,
92 int64 version, 93 int64 version,
93 int64 sync_ts); 94 int64 sync_ts);
94 sync_pb::SyncEntity* AddUpdateBookmark(string id, 95 sync_pb::SyncEntity* AddUpdateBookmark(std::string id,
95 string parent_id, 96 std::string parent_id,
96 string name, 97 std::string name,
97 int64 version, 98 int64 version,
98 int64 sync_ts); 99 int64 sync_ts);
99 100
100 // Find the last commit sent by the client, and replay it for the next get 101 // Find the last commit sent by the client, and replay it for the next get
101 // updates command. This can be used to simulate the GetUpdates that happens 102 // updates command. This can be used to simulate the GetUpdates that happens
102 // immediately after a successful commit. 103 // immediately after a successful commit.
103 sync_pb::SyncEntity* AddUpdateFromLastCommit(); 104 sync_pb::SyncEntity* AddUpdateFromLastCommit();
104 105
105 // Add a deleted item. Deletion records typically contain no 106 // Add a deleted item. Deletion records typically contain no
106 // additional information beyond the deletion, and no specifics. 107 // additional information beyond the deletion, and no specifics.
107 // The server may send the originator fields. 108 // The server may send the originator fields.
108 void AddUpdateTombstone(const syncable::Id& id); 109 void AddUpdateTombstone(const syncable::Id& id);
109 110
110 void SetLastUpdateDeleted(); 111 void SetLastUpdateDeleted();
111 void SetLastUpdateServerTag(const string& tag); 112 void SetLastUpdateServerTag(const std::string& tag);
112 void SetLastUpdateClientTag(const string& tag); 113 void SetLastUpdateClientTag(const std::string& tag);
113 void SetLastUpdateOriginatorFields(const string& client_id, 114 void SetLastUpdateOriginatorFields(const std::string& client_id,
114 const string& entry_id); 115 const std::string& entry_id);
115 void SetLastUpdatePosition(int64 position_in_parent); 116 void SetLastUpdatePosition(int64 position_in_parent);
116 void SetNewTimestamp(int ts); 117 void SetNewTimestamp(int ts);
117 void SetChangesRemaining(int64 count); 118 void SetChangesRemaining(int64 count);
118 119
119 // Add a new batch of updates after the current one. Allows multiple 120 // Add a new batch of updates after the current one. Allows multiple
120 // GetUpdates responses to be buffered up, since the syncer may 121 // GetUpdates responses to be buffered up, since the syncer may
121 // issue multiple requests during a sync cycle. 122 // issue multiple requests during a sync cycle.
122 void NextUpdateBatch(); 123 void NextUpdateBatch();
123 124
124 // For AUTHENTICATE responses. 125 // For AUTHENTICATE responses.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 next_new_id_ = value; 182 next_new_id_ = value;
182 } 183 }
183 void set_conflict_n_commits(int value) { 184 void set_conflict_n_commits(int value) {
184 conflict_n_commits_ = value; 185 conflict_n_commits_ = value;
185 } 186 }
186 187
187 void set_use_legacy_bookmarks_protocol(bool value) { 188 void set_use_legacy_bookmarks_protocol(bool value) {
188 use_legacy_bookmarks_protocol_ = value; 189 use_legacy_bookmarks_protocol_ = value;
189 } 190 }
190 191
191 void set_store_birthday(string new_birthday) { 192 void set_store_birthday(std::string new_birthday) {
192 // Multiple threads can set store_birthday_ in our tests, need to lock it to 193 // Multiple threads can set store_birthday_ in our tests, need to lock it to
193 // ensure atomic read/writes and avoid race conditions. 194 // ensure atomic read/writes and avoid race conditions.
194 base::AutoLock lock(store_birthday_lock_); 195 base::AutoLock lock(store_birthday_lock_);
195 store_birthday_ = new_birthday; 196 store_birthday_ = new_birthday;
196 } 197 }
197 198
198 // Retrieve the number of GetUpdates requests that the mock server has 199 // Retrieve the number of GetUpdates requests that the mock server has
199 // seen since the last time this function was called. Can be used to 200 // seen since the last time this function was called. Can be used to
200 // verify that a GetUpdates actually did or did not happen after running 201 // verify that a GetUpdates actually did or did not happen after running
201 // the syncer. 202 // the syncer.
(...skipping 19 matching lines...) Expand all
221 const std::string& store_birthday() { 222 const std::string& store_birthday() {
222 base::AutoLock lock(store_birthday_lock_); 223 base::AutoLock lock(store_birthday_lock_);
223 return store_birthday_; 224 return store_birthday_;
224 } 225 }
225 226
226 // Locate the most recent update message for purpose of alteration. 227 // Locate the most recent update message for purpose of alteration.
227 sync_pb::SyncEntity* GetMutableLastUpdate(); 228 sync_pb::SyncEntity* GetMutableLastUpdate();
228 229
229 private: 230 private:
230 sync_pb::SyncEntity* AddUpdateFull(syncable::Id id, syncable::Id parentid, 231 sync_pb::SyncEntity* AddUpdateFull(syncable::Id id, syncable::Id parentid,
231 string name, int64 version, 232 std::string name, int64 version,
232 int64 sync_ts, 233 int64 sync_ts,
233 bool is_dir); 234 bool is_dir);
234 sync_pb::SyncEntity* AddUpdateFull(string id, string parentid, string name, 235 sync_pb::SyncEntity* AddUpdateFull(std::string id,
236 std::string parentid, std::string name,
235 int64 version, int64 sync_ts, 237 int64 version, int64 sync_ts,
236 bool is_dir); 238 bool is_dir);
237 // Functions to handle the various types of server request. 239 // Functions to handle the various types of server request.
238 void ProcessGetUpdates(sync_pb::ClientToServerMessage* csm, 240 void ProcessGetUpdates(sync_pb::ClientToServerMessage* csm,
239 sync_pb::ClientToServerResponse* response); 241 sync_pb::ClientToServerResponse* response);
240 void ProcessAuthenticate(sync_pb::ClientToServerMessage* csm, 242 void ProcessAuthenticate(sync_pb::ClientToServerMessage* csm,
241 sync_pb::ClientToServerResponse* response, 243 sync_pb::ClientToServerResponse* response,
242 const std::string& auth_token); 244 const std::string& auth_token);
243 void ProcessCommit(sync_pb::ClientToServerMessage* csm, 245 void ProcessCommit(sync_pb::ClientToServerMessage* csm,
244 sync_pb::ClientToServerResponse* response_buffer); 246 sync_pb::ClientToServerResponse* response_buffer);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 int conflict_n_commits_; 279 int conflict_n_commits_;
278 280
279 // Commit messages we've sent, and responses we've returned. 281 // Commit messages we've sent, and responses we've returned.
280 ScopedVector<sync_pb::CommitMessage> commit_messages_; 282 ScopedVector<sync_pb::CommitMessage> commit_messages_;
281 ScopedVector<sync_pb::CommitResponse> commit_responses_; 283 ScopedVector<sync_pb::CommitResponse> commit_responses_;
282 284
283 // The next id the mock will return to a commit. 285 // The next id the mock will return to a commit.
284 int next_new_id_; 286 int next_new_id_;
285 287
286 // The store birthday we send to the client. 288 // The store birthday we send to the client.
287 string store_birthday_; 289 std::string store_birthday_;
288 base::Lock store_birthday_lock_; 290 base::Lock store_birthday_lock_;
289 bool store_birthday_sent_; 291 bool store_birthday_sent_;
290 bool client_stuck_; 292 bool client_stuck_;
291 string commit_time_rename_prepended_string_; 293 std::string commit_time_rename_prepended_string_;
292 294
293 // Fail on the next call to PostBufferToPath(). 295 // Fail on the next call to PostBufferToPath().
294 bool fail_next_postbuffer_; 296 bool fail_next_postbuffer_;
295 297
296 // Our directory. 298 // Our directory.
297 syncable::DirectoryManager* directory_manager_; 299 syncable::DirectoryManager* directory_manager_;
298 std::string directory_name_; 300 std::string directory_name_;
299 301
300 // The updates we'll return to the next request. 302 // The updates we'll return to the next request.
301 std::list<sync_pb::GetUpdatesResponse> update_queue_; 303 std::list<sync_pb::GetUpdatesResponse> update_queue_;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 int num_get_updates_requests_; 342 int num_get_updates_requests_;
341 343
342 std::string next_token_; 344 std::string next_token_;
343 345
344 sync_pb::ClientToServerMessage last_request_; 346 sync_pb::ClientToServerMessage last_request_;
345 347
346 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager); 348 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager);
347 }; 349 };
348 350
349 #endif // CHROME_TEST_SYNC_ENGINE_MOCK_CONNECTION_MANAGER_H_ 351 #endif // CHROME_TEST_SYNC_ENGINE_MOCK_CONNECTION_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/chrome.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698