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

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

Issue 10107004: Revert 132455 - Abort sync cycles when download step fails (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | « sync/sessions/sync_session_unittest.cc ('k') | sync/test/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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ 7 #ifndef SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_
8 #define SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ 8 #define SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_
9 #pragma once 9 #pragma once
10 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 const std::string& entry_id); 110 const std::string& entry_id);
111 void SetLastUpdatePosition(int64 position_in_parent); 111 void SetLastUpdatePosition(int64 position_in_parent);
112 void SetNewTimestamp(int ts); 112 void SetNewTimestamp(int ts);
113 void SetChangesRemaining(int64 count); 113 void SetChangesRemaining(int64 count);
114 114
115 // Add a new batch of updates after the current one. Allows multiple 115 // Add a new batch of updates after the current one. Allows multiple
116 // GetUpdates responses to be buffered up, since the syncer may 116 // GetUpdates responses to be buffered up, since the syncer may
117 // issue multiple requests during a sync cycle. 117 // issue multiple requests during a sync cycle.
118 void NextUpdateBatch(); 118 void NextUpdateBatch();
119 119
120 void FailNextPostBufferToPathCall() { countdown_to_postbuffer_fail_ = 1; } 120 void FailNextPostBufferToPathCall() { fail_next_postbuffer_ = true; }
121 void FailNthPostBufferToPathCall(int n) { countdown_to_postbuffer_fail_ = n; }
122 121
123 void SetClearUserDataResponseStatus(sync_pb::SyncEnums::ErrorType errortype); 122 void SetClearUserDataResponseStatus(sync_pb::SyncEnums::ErrorType errortype);
124 123
125 // A visitor class to allow a test to change some monitoring state atomically 124 // A visitor class to allow a test to change some monitoring state atomically
126 // with the action of overriding the response codes sent back to the Syncer 125 // with the action of overriding the response codes sent back to the Syncer
127 // (for example, so you can say "ThrottleNextRequest, and assert no more 126 // (for example, so you can say "ThrottleNextRequest, and assert no more
128 // requests are made once throttling is in effect" in one step. 127 // requests are made once throttling is in effect" in one step.
129 class ResponseCodeOverrideRequestor { 128 class ResponseCodeOverrideRequestor {
130 public: 129 public:
131 // Called with response_code_override_lock_ acquired. 130 // Called with response_code_override_lock_ acquired.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // cases where we're mocking out most of the code that performs network 215 // cases where we're mocking out most of the code that performs network
217 // requests. 216 // requests.
218 void UpdateConnectionStatus(); 217 void UpdateConnectionStatus();
219 218
220 // Return by copy to be thread-safe. 219 // Return by copy to be thread-safe.
221 const std::string store_birthday() { 220 const std::string store_birthday() {
222 base::AutoLock lock(store_birthday_lock_); 221 base::AutoLock lock(store_birthday_lock_);
223 return store_birthday_; 222 return store_birthday_;
224 } 223 }
225 224
226 // Explicitly indicate that we will not be fetching some updates.
227 void ClearUpdatesQueue() {
228 update_queue_.clear();
229 }
230
231 // Locate the most recent update message for purpose of alteration. 225 // Locate the most recent update message for purpose of alteration.
232 sync_pb::SyncEntity* GetMutableLastUpdate(); 226 sync_pb::SyncEntity* GetMutableLastUpdate();
233 227
234 private: 228 private:
235 sync_pb::SyncEntity* AddUpdateFull(syncable::Id id, syncable::Id parentid, 229 sync_pb::SyncEntity* AddUpdateFull(syncable::Id id, syncable::Id parentid,
236 std::string name, int64 version, 230 std::string name, int64 version,
237 int64 sync_ts, 231 int64 sync_ts,
238 bool is_dir); 232 bool is_dir);
239 sync_pb::SyncEntity* AddUpdateFull(std::string id, 233 sync_pb::SyncEntity* AddUpdateFull(std::string id,
240 std::string parentid, std::string name, 234 std::string parentid, std::string name,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // The next id the mock will return to a commit. 292 // The next id the mock will return to a commit.
299 int next_new_id_; 293 int next_new_id_;
300 294
301 // The store birthday we send to the client. 295 // The store birthday we send to the client.
302 std::string store_birthday_; 296 std::string store_birthday_;
303 base::Lock store_birthday_lock_; 297 base::Lock store_birthday_lock_;
304 bool store_birthday_sent_; 298 bool store_birthday_sent_;
305 bool client_stuck_; 299 bool client_stuck_;
306 std::string commit_time_rename_prepended_string_; 300 std::string commit_time_rename_prepended_string_;
307 301
308 // On each PostBufferToPath() call, we decrement this counter. The call fails 302 // Fail on the next call to PostBufferToPath().
309 // iff we hit zero at that call. 303 bool fail_next_postbuffer_;
310 int countdown_to_postbuffer_fail_;
311 304
312 // Our directory. Used only to ensure that we are not holding the transaction 305 // Our directory. Used only to ensure that we are not holding the transaction
313 // lock when performing network I/O. Can be NULL if the test author is 306 // lock when performing network I/O. Can be NULL if the test author is
314 // confident this can't happen. 307 // confident this can't happen.
315 syncable::Directory* directory_; 308 syncable::Directory* directory_;
316 309
317 // The updates we'll return to the next request. 310 // The updates we'll return to the next request.
318 std::list<sync_pb::GetUpdatesResponse> update_queue_; 311 std::list<sync_pb::GetUpdatesResponse> update_queue_;
319 base::Closure mid_commit_callback_; 312 base::Closure mid_commit_callback_;
320 MidCommitObserver* mid_commit_observer_; 313 MidCommitObserver* mid_commit_observer_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 int num_get_updates_requests_; 351 int num_get_updates_requests_;
359 352
360 std::string next_token_; 353 std::string next_token_;
361 354
362 sync_pb::ClientToServerMessage last_request_; 355 sync_pb::ClientToServerMessage last_request_;
363 356
364 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager); 357 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager);
365 }; 358 };
366 359
367 #endif // SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_ 360 #endif // SYNC_TEST_ENGINE_MOCK_CONNECTION_MANAGER_H_
OLDNEW
« no previous file with comments | « sync/sessions/sync_session_unittest.cc ('k') | sync/test/engine/mock_connection_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698