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