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

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

Issue 6142009: Upating the app, ceee, chrome, ipc, media, and net directories to use the correct lock.h file. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Unified patch updating all references to the new base/synchronization/lock.h 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/test/automation/tab_proxy.cc ('k') | chrome/test/sync/engine/mock_connection_manager.cc » ('j') | 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 conflict_n_commits_ = value; 183 conflict_n_commits_ = value;
184 } 184 }
185 185
186 void set_use_legacy_bookmarks_protocol(bool value) { 186 void set_use_legacy_bookmarks_protocol(bool value) {
187 use_legacy_bookmarks_protocol_ = value; 187 use_legacy_bookmarks_protocol_ = value;
188 } 188 }
189 189
190 void set_store_birthday(string new_birthday) { 190 void set_store_birthday(string new_birthday) {
191 // Multiple threads can set store_birthday_ in our tests, need to lock it to 191 // Multiple threads can set store_birthday_ in our tests, need to lock it to
192 // ensure atomic read/writes and avoid race conditions. 192 // ensure atomic read/writes and avoid race conditions.
193 AutoLock lock(store_birthday_lock_); 193 base::AutoLock lock(store_birthday_lock_);
194 store_birthday_ = new_birthday; 194 store_birthday_ = new_birthday;
195 } 195 }
196 196
197 // Retrieve the number of GetUpdates requests that the mock server has 197 // Retrieve the number of GetUpdates requests that the mock server has
198 // seen since the last time this function was called. Can be used to 198 // seen since the last time this function was called. Can be used to
199 // verify that a GetUpdates actually did or did not happen after running 199 // verify that a GetUpdates actually did or did not happen after running
200 // the syncer. 200 // the syncer.
201 int GetAndClearNumGetUpdatesRequests() { 201 int GetAndClearNumGetUpdatesRequests() {
202 int result = num_get_updates_requests_; 202 int result = num_get_updates_requests_;
203 num_get_updates_requests_ = 0; 203 num_get_updates_requests_ = 0;
204 return result; 204 return result;
205 } 205 }
206 206
207 // Expect that GetUpdates will request exactly the types indicated in 207 // Expect that GetUpdates will request exactly the types indicated in
208 // the bitset. 208 // the bitset.
209 void ExpectGetUpdatesRequestTypes( 209 void ExpectGetUpdatesRequestTypes(
210 std::bitset<syncable::MODEL_TYPE_COUNT> expected_filter) { 210 std::bitset<syncable::MODEL_TYPE_COUNT> expected_filter) {
211 expected_filter_ = expected_filter; 211 expected_filter_ = expected_filter;
212 } 212 }
213 213
214 void SetServerReachable(); 214 void SetServerReachable();
215 215
216 void SetServerNotReachable(); 216 void SetServerNotReachable();
217 217
218 // Const necessary to avoid any hidden copy-on-write issues that would break 218 // Const necessary to avoid any hidden copy-on-write issues that would break
219 // in multithreaded scenarios (see |set_store_birthday|). 219 // in multithreaded scenarios (see |set_store_birthday|).
220 const std::string& store_birthday() { 220 const std::string& store_birthday() {
221 AutoLock lock(store_birthday_lock_); 221 base::AutoLock lock(store_birthday_lock_);
222 return store_birthday_; 222 return store_birthday_;
223 } 223 }
224 224
225 // Locate the most recent update message for purpose of alteration. 225 // Locate the most recent update message for purpose of alteration.
226 sync_pb::SyncEntity* GetMutableLastUpdate(); 226 sync_pb::SyncEntity* GetMutableLastUpdate();
227 227
228 private: 228 private:
229 sync_pb::SyncEntity* AddUpdateFull(syncable::Id id, syncable::Id parentid, 229 sync_pb::SyncEntity* AddUpdateFull(syncable::Id id, syncable::Id parentid,
230 string name, int64 version, 230 string name, int64 version,
231 int64 sync_ts, 231 int64 sync_ts,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 270
271 // Commit messages we've sent, and responses we've returned. 271 // Commit messages we've sent, and responses we've returned.
272 ScopedVector<sync_pb::CommitMessage> commit_messages_; 272 ScopedVector<sync_pb::CommitMessage> commit_messages_;
273 ScopedVector<sync_pb::CommitResponse> commit_responses_; 273 ScopedVector<sync_pb::CommitResponse> commit_responses_;
274 274
275 // The next id the mock will return to a commit. 275 // The next id the mock will return to a commit.
276 int next_new_id_; 276 int next_new_id_;
277 277
278 // The store birthday we send to the client. 278 // The store birthday we send to the client.
279 string store_birthday_; 279 string store_birthday_;
280 Lock store_birthday_lock_; 280 base::Lock store_birthday_lock_;
281 bool store_birthday_sent_; 281 bool store_birthday_sent_;
282 bool client_stuck_; 282 bool client_stuck_;
283 string commit_time_rename_prepended_string_; 283 string commit_time_rename_prepended_string_;
284 284
285 // Fail on the next call to PostBufferToPath(). 285 // Fail on the next call to PostBufferToPath().
286 bool fail_next_postbuffer_; 286 bool fail_next_postbuffer_;
287 287
288 // Our directory. 288 // Our directory.
289 syncable::DirectoryManager* directory_manager_; 289 syncable::DirectoryManager* directory_manager_;
290 std::string directory_name_; 290 std::string directory_name_;
(...skipping 14 matching lines...) Expand all
305 305
306 // Whether we are faking a server mandating clients to throttle requests. 306 // Whether we are faking a server mandating clients to throttle requests.
307 // Protected by |response_code_override_lock_|. 307 // Protected by |response_code_override_lock_|.
308 bool throttling_; 308 bool throttling_;
309 309
310 // Whether we are failing all requests by returning 310 // Whether we are failing all requests by returning
311 // ClientToServerResponse::AUTH_INVALID. 311 // ClientToServerResponse::AUTH_INVALID.
312 // Protected by |response_code_override_lock_|. 312 // Protected by |response_code_override_lock_|.
313 bool fail_with_auth_invalid_; 313 bool fail_with_auth_invalid_;
314 314
315 Lock response_code_override_lock_; 315 base::Lock response_code_override_lock_;
316 316
317 // True if we are only accepting GetUpdatesCallerInfo::PERIODIC requests. 317 // True if we are only accepting GetUpdatesCallerInfo::PERIODIC requests.
318 bool fail_non_periodic_get_updates_; 318 bool fail_non_periodic_get_updates_;
319 319
320 scoped_ptr<sync_pb::ClientCommand> client_command_; 320 scoped_ptr<sync_pb::ClientCommand> client_command_;
321 321
322 // The next value to use for the position_in_parent property. 322 // The next value to use for the position_in_parent property.
323 int64 next_position_in_parent_; 323 int64 next_position_in_parent_;
324 324
325 // The default is to use the newer sync_pb::BookmarkSpecifics-style protocol. 325 // The default is to use the newer sync_pb::BookmarkSpecifics-style protocol.
326 // If this option is set to true, then the MockConnectionManager will 326 // If this option is set to true, then the MockConnectionManager will
327 // use the older sync_pb::SyncEntity_BookmarkData-style protocol. 327 // use the older sync_pb::SyncEntity_BookmarkData-style protocol.
328 bool use_legacy_bookmarks_protocol_; 328 bool use_legacy_bookmarks_protocol_;
329 329
330 std::bitset<syncable::MODEL_TYPE_COUNT> expected_filter_; 330 std::bitset<syncable::MODEL_TYPE_COUNT> expected_filter_;
331 331
332 int num_get_updates_requests_; 332 int num_get_updates_requests_;
333 333
334 sync_pb::ClientToServerMessage last_request_; 334 sync_pb::ClientToServerMessage last_request_;
335 335
336 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager); 336 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager);
337 }; 337 };
338 338
339 #endif // CHROME_TEST_SYNC_ENGINE_MOCK_CONNECTION_MANAGER_H_ 339 #endif // CHROME_TEST_SYNC_ENGINE_MOCK_CONNECTION_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/test/automation/tab_proxy.cc ('k') | chrome/test/sync/engine/mock_connection_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698