OLD | NEW |
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 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 MockConnectionManager::MidCommitObserver* observer) { | 81 MockConnectionManager::MidCommitObserver* observer) { |
82 mid_commit_observer_ = observer; | 82 mid_commit_observer_ = observer; |
83 } | 83 } |
84 | 84 |
85 bool MockConnectionManager::PostBufferToPath(PostBufferParams* params, | 85 bool MockConnectionManager::PostBufferToPath(PostBufferParams* params, |
86 const string& path, | 86 const string& path, |
87 const string& auth_token, | 87 const string& auth_token, |
88 csync::ScopedServerStatusWatcher* watcher) { | 88 csync::ScopedServerStatusWatcher* watcher) { |
89 ClientToServerMessage post; | 89 ClientToServerMessage post; |
90 CHECK(post.ParseFromString(params->buffer_in)); | 90 CHECK(post.ParseFromString(params->buffer_in)); |
| 91 CHECK(post.has_protocol_version()); |
91 last_request_.CopyFrom(post); | 92 last_request_.CopyFrom(post); |
92 client_stuck_ = post.sync_problem_detected(); | 93 client_stuck_ = post.sync_problem_detected(); |
93 ClientToServerResponse response; | 94 ClientToServerResponse response; |
94 response.Clear(); | 95 response.Clear(); |
95 | 96 |
96 if (directory_) { | 97 if (directory_) { |
97 // If the Directory's locked when we do this, it's a problem as in normal | 98 // If the Directory's locked when we do this, it's a problem as in normal |
98 // use this function could take a while to return because it accesses the | 99 // use this function could take a while to return because it accesses the |
99 // network. As we can't test this we do the next best thing and hang here | 100 // network. As we can't test this we do the next best thing and hang here |
100 // when there's an issue. | 101 // when there's an issue. |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 server_reachable_ = false; | 587 server_reachable_ = false; |
587 } | 588 } |
588 | 589 |
589 void MockConnectionManager::UpdateConnectionStatus() { | 590 void MockConnectionManager::UpdateConnectionStatus() { |
590 if (!server_reachable_) { | 591 if (!server_reachable_) { |
591 server_status_ = HttpResponse::CONNECTION_UNAVAILABLE; | 592 server_status_ = HttpResponse::CONNECTION_UNAVAILABLE; |
592 } else { | 593 } else { |
593 server_status_ = HttpResponse::SERVER_CONNECTION_OK; | 594 server_status_ = HttpResponse::SERVER_CONNECTION_OK; |
594 } | 595 } |
595 } | 596 } |
OLD | NEW |