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

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

Issue 1505953002: [Sync] Remove ScopedServerStatusWatcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change format of deprecated names. Created 5 years 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
« no previous file with comments | « sync/test/engine/mock_connection_manager.h ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 regression tests. 5 // Mock ServerConnectionManager class for use in client regression tests.
6 6
7 #include "sync/test/engine/mock_connection_manager.h" 7 #include "sync/test/engine/mock_connection_manager.h"
8 8
9 #include <map> 9 #include <map>
10 10
(...skipping 30 matching lines...) Expand all
41 conflict_n_commits_(0), 41 conflict_n_commits_(0),
42 next_new_id_(10000), 42 next_new_id_(10000),
43 store_birthday_("Store BDay!"), 43 store_birthday_("Store BDay!"),
44 store_birthday_sent_(false), 44 store_birthday_sent_(false),
45 client_stuck_(false), 45 client_stuck_(false),
46 countdown_to_postbuffer_fail_(0), 46 countdown_to_postbuffer_fail_(0),
47 directory_(directory), 47 directory_(directory),
48 mid_commit_observer_(NULL), 48 mid_commit_observer_(NULL),
49 throttling_(false), 49 throttling_(false),
50 partialThrottling_(false), 50 partialThrottling_(false),
51 fail_with_auth_invalid_(false),
52 fail_non_periodic_get_updates_(false), 51 fail_non_periodic_get_updates_(false),
53 next_position_in_parent_(2), 52 next_position_in_parent_(2),
54 use_legacy_bookmarks_protocol_(false), 53 use_legacy_bookmarks_protocol_(false),
55 num_get_updates_requests_(0) { 54 num_get_updates_requests_(0) {
56 SetNewTimestamp(0); 55 SetNewTimestamp(0);
57 SetAuthToken(kValidAuthToken); 56 SetAuthToken(kValidAuthToken);
58 } 57 }
59 58
60 MockConnectionManager::~MockConnectionManager() { 59 MockConnectionManager::~MockConnectionManager() {
61 EXPECT_TRUE(update_queue_.empty()) << "Unfetched updates."; 60 EXPECT_TRUE(update_queue_.empty()) << "Unfetched updates.";
62 } 61 }
63 62
64 void MockConnectionManager::SetCommitTimeRename(const string& prepend) { 63 void MockConnectionManager::SetCommitTimeRename(const string& prepend) {
65 commit_time_rename_prepended_string_ = prepend; 64 commit_time_rename_prepended_string_ = prepend;
66 } 65 }
67 66
68 void MockConnectionManager::SetMidCommitCallback( 67 void MockConnectionManager::SetMidCommitCallback(
69 const base::Closure& callback) { 68 const base::Closure& callback) {
70 mid_commit_callback_ = callback; 69 mid_commit_callback_ = callback;
71 } 70 }
72 71
73 void MockConnectionManager::SetMidCommitObserver( 72 void MockConnectionManager::SetMidCommitObserver(
74 MockConnectionManager::MidCommitObserver* observer) { 73 MockConnectionManager::MidCommitObserver* observer) {
75 mid_commit_observer_ = observer; 74 mid_commit_observer_ = observer;
76 } 75 }
77 76
78 bool MockConnectionManager::PostBufferToPath(PostBufferParams* params, 77 bool MockConnectionManager::PostBufferToPath(PostBufferParams* params,
79 const string& path, 78 const string& path,
80 const string& auth_token, 79 const string& auth_token) {
81 ScopedServerStatusWatcher* watcher) {
82 ClientToServerMessage post; 80 ClientToServerMessage post;
83 CHECK(post.ParseFromString(params->buffer_in)); 81 CHECK(post.ParseFromString(params->buffer_in));
84 CHECK(post.has_protocol_version()); 82 CHECK(post.has_protocol_version());
85 CHECK(post.has_api_key()); 83 CHECK(post.has_api_key());
86 CHECK(post.has_bag_of_chips()); 84 CHECK(post.has_bag_of_chips());
87 85
88 requests_.push_back(post); 86 requests_.push_back(post);
89 client_stuck_ = post.sync_problem_detected(); 87 client_stuck_ = post.sync_problem_detected();
90 sync_pb::ClientToServerResponse response; 88 sync_pb::ClientToServerResponse response;
91 response.Clear(); 89 response.Clear();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 sync_pb::ClientToServerResponse_Error* response_error = 162 sync_pb::ClientToServerResponse_Error* response_error =
165 response.mutable_error(); 163 response.mutable_error();
166 response_error->set_error_type(SyncEnums::PARTIAL_FAILURE); 164 response_error->set_error_type(SyncEnums::PARTIAL_FAILURE);
167 for (ModelTypeSet::Iterator it = throttled_type_.First(); it.Good(); 165 for (ModelTypeSet::Iterator it = throttled_type_.First(); it.Good();
168 it.Inc()) { 166 it.Inc()) {
169 response_error->add_error_data_type_ids( 167 response_error->add_error_data_type_ids(
170 GetSpecificsFieldNumberFromModelType(it.Get())); 168 GetSpecificsFieldNumberFromModelType(it.Get()));
171 } 169 }
172 partialThrottling_ = false; 170 partialThrottling_ = false;
173 } 171 }
174
175 if (fail_with_auth_invalid_)
176 response.set_error_code(SyncEnums::AUTH_INVALID);
177 } 172 }
178 173
179 response.SerializeToString(&params->buffer_out); 174 response.SerializeToString(&params->buffer_out);
180 if (post.message_contents() == ClientToServerMessage::COMMIT && 175 if (post.message_contents() == ClientToServerMessage::COMMIT &&
181 !mid_commit_callback_.is_null()) { 176 !mid_commit_callback_.is_null()) {
182 mid_commit_callback_.Run(); 177 mid_commit_callback_.Run();
183 mid_commit_callback_.Reset(); 178 mid_commit_callback_.Reset();
184 } 179 }
185 if (mid_commit_observer_) { 180 if (mid_commit_observer_) {
186 mid_commit_observer_->Observe(); 181 mid_commit_observer_->Observe();
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 server_status_ = HttpResponse::SERVER_CONNECTION_OK; 766 server_status_ = HttpResponse::SERVER_CONNECTION_OK;
772 } 767 }
773 } 768 }
774 769
775 void MockConnectionManager::SetServerStatus( 770 void MockConnectionManager::SetServerStatus(
776 HttpResponse::ServerConnectionCode server_status) { 771 HttpResponse::ServerConnectionCode server_status) {
777 server_status_ = server_status; 772 server_status_ = server_status;
778 } 773 }
779 774
780 } // namespace syncer 775 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/test/engine/mock_connection_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698