| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 regression tests. | 5 // Mock ServerConnectionManager class for use in client regression tests. |
| 6 | 6 |
| 7 #include "chrome/test/sync/engine/mock_server_connection.h" | 7 #include "chrome/test/sync/engine/mock_server_connection.h" |
| 8 | 8 |
| 9 #include "chrome/browser/sync/engine/syncer_proto_util.h" | 9 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
| 10 #include "chrome/browser/sync/util/character_set_converters.h" | 10 #include "chrome/browser/sync/util/character_set_converters.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 conflict_all_commits_(false), | 34 conflict_all_commits_(false), |
| 35 conflict_n_commits_(0), | 35 conflict_n_commits_(0), |
| 36 next_new_id_(10000), | 36 next_new_id_(10000), |
| 37 store_birthday_("Store BDay!"), | 37 store_birthday_("Store BDay!"), |
| 38 store_birthday_sent_(false), | 38 store_birthday_sent_(false), |
| 39 client_stuck_(false), | 39 client_stuck_(false), |
| 40 commit_time_rename_prepended_string_(""), | 40 commit_time_rename_prepended_string_(""), |
| 41 fail_next_postbuffer_(false), | 41 fail_next_postbuffer_(false), |
| 42 directory_manager_(dirmgr), | 42 directory_manager_(dirmgr), |
| 43 directory_name_(name), | 43 directory_name_(name), |
| 44 mid_commit_callback_function_(NULL), | 44 mid_commit_callback_(NULL), |
| 45 mid_commit_observer_(NULL), | 45 mid_commit_observer_(NULL), |
| 46 throttling_(false), | 46 throttling_(false), |
| 47 fail_non_periodic_get_updates_(false), | 47 fail_non_periodic_get_updates_(false), |
| 48 client_command_(NULL), | 48 client_command_(NULL), |
| 49 next_position_in_parent_(2) { | 49 next_position_in_parent_(2) { |
| 50 server_reachable_ = true; | 50 server_reachable_ = true; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 MockConnectionManager::~MockConnectionManager() { | 53 MockConnectionManager::~MockConnectionManager() { |
| 54 for (size_t i = 0; i < commit_messages_.size(); i++) | 54 for (size_t i = 0; i < commit_messages_.size(); i++) |
| 55 delete commit_messages_[i]; | 55 delete commit_messages_[i]; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void MockConnectionManager::SetCommitTimeRename(string prepend) { | 58 void MockConnectionManager::SetCommitTimeRename(string prepend) { |
| 59 commit_time_rename_prepended_string_ = prepend; | 59 commit_time_rename_prepended_string_ = prepend; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void MockConnectionManager::SetMidCommitCallbackFunction( | 62 void MockConnectionManager::SetMidCommitCallback(Closure* callback) { |
| 63 MockConnectionManager::TestCallbackFunction callback) { | 63 mid_commit_callback_ = callback; |
| 64 mid_commit_callback_function_ = callback; | |
| 65 } | 64 } |
| 66 | 65 |
| 67 void MockConnectionManager::SetMidCommitObserver( | 66 void MockConnectionManager::SetMidCommitObserver( |
| 68 MockConnectionManager::MidCommitObserver* observer) { | 67 MockConnectionManager::MidCommitObserver* observer) { |
| 69 mid_commit_observer_ = observer; | 68 mid_commit_observer_ = observer; |
| 70 } | 69 } |
| 71 | 70 |
| 72 bool MockConnectionManager::PostBufferToPath(const PostBufferParams* params, | 71 bool MockConnectionManager::PostBufferToPath(const PostBufferParams* params, |
| 73 const string& path, | 72 const string& path, |
| 74 const string& auth_token) { | 73 const string& auth_token) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 123 |
| 125 { | 124 { |
| 126 AutoLock throttle_lock(throttle_lock_); | 125 AutoLock throttle_lock(throttle_lock_); |
| 127 if (throttling_) { | 126 if (throttling_) { |
| 128 response.set_error_code(ClientToServerResponse::THROTTLED); | 127 response.set_error_code(ClientToServerResponse::THROTTLED); |
| 129 throttling_ = false; | 128 throttling_ = false; |
| 130 } | 129 } |
| 131 } | 130 } |
| 132 | 131 |
| 133 response.SerializeToString(params->buffer_out); | 132 response.SerializeToString(params->buffer_out); |
| 134 if (mid_commit_callback_function_) { | 133 if (mid_commit_callback_) { |
| 135 if (mid_commit_callback_function_(directory)) | 134 mid_commit_callback_->Run(); |
| 136 mid_commit_callback_function_ = 0; | |
| 137 } | 135 } |
| 138 if (mid_commit_observer_) { | 136 if (mid_commit_observer_) { |
| 139 mid_commit_observer_->Observe(); | 137 mid_commit_observer_->Observe(); |
| 140 } | 138 } |
| 141 | 139 |
| 142 return result; | 140 return result; |
| 143 } | 141 } |
| 144 | 142 |
| 145 bool MockConnectionManager::IsServerReachable() { | 143 bool MockConnectionManager::IsServerReachable() { |
| 146 return true; | 144 return true; |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } | 398 } |
| 401 | 399 |
| 402 void MockConnectionManager::ThrottleNextRequest( | 400 void MockConnectionManager::ThrottleNextRequest( |
| 403 ThrottleRequestVisitor* visitor) { | 401 ThrottleRequestVisitor* visitor) { |
| 404 AutoLock lock(throttle_lock_); | 402 AutoLock lock(throttle_lock_); |
| 405 throttling_ = true; | 403 throttling_ = true; |
| 406 if (visitor) | 404 if (visitor) |
| 407 visitor->VisitAtomically(); | 405 visitor->VisitAtomically(); |
| 408 } | 406 } |
| 409 | 407 |
| OLD | NEW |