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

Side by Side Diff: remoting/test/test_chromoting_client.cc

Issue 1238343002: Added ConnectionTimeObserver to calculate the times to authenticate and connect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unused headers. Created 5 years, 4 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
« no previous file with comments | « remoting/test/connection_time_observer_unittest.cc ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "remoting/test/test_chromoting_client.h" 5 #include "remoting/test/test_chromoting_client.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 } 54 }
55 55
56 void FetchSecret( 56 void FetchSecret(
57 const std::string& client_secret, 57 const std::string& client_secret,
58 bool pairing_expected, 58 bool pairing_expected,
59 const remoting::protocol::SecretFetchedCallback& secret_fetched_callback) { 59 const remoting::protocol::SecretFetchedCallback& secret_fetched_callback) {
60 secret_fetched_callback.Run(client_secret); 60 secret_fetched_callback.Run(client_secret);
61 } 61 }
62 62
63 const char* ConnectionStateToFriendlyString(
64 remoting::protocol::ConnectionToHost::State state) {
65 switch (state) {
66 case remoting::protocol::ConnectionToHost::INITIALIZING:
67 return "INITIALIZING";
68
69 case remoting::protocol::ConnectionToHost::CONNECTING:
70 return "CONNECTING";
71
72 case remoting::protocol::ConnectionToHost::AUTHENTICATED:
73 return "AUTHENTICATED";
74
75 case remoting::protocol::ConnectionToHost::CONNECTED:
76 return "CONNECTED";
77
78 case remoting::protocol::ConnectionToHost::CLOSED:
79 return "CLOSED";
80
81 case remoting::protocol::ConnectionToHost::FAILED:
82 return "FAILED";
83
84 default:
85 LOG(ERROR) << "Unknown connection state: '" << state << "'";
86 return "UNKNOWN";
87 }
88 }
89
90 const char* ProtocolErrorToFriendlyString(
91 remoting::protocol::ErrorCode error_code) {
92 switch (error_code) {
93 case remoting::protocol::OK:
94 return "NONE";
95
96 case remoting::protocol::PEER_IS_OFFLINE:
97 return "PEER_IS_OFFLINE";
98
99 case remoting::protocol::SESSION_REJECTED:
100 return "SESSION_REJECTED";
101
102 case remoting::protocol::AUTHENTICATION_FAILED:
103 return "AUTHENTICATION_FAILED";
104
105 case remoting::protocol::INCOMPATIBLE_PROTOCOL:
106 return "INCOMPATIBLE_PROTOCOL";
107
108 case remoting::protocol::HOST_OVERLOAD:
109 return "HOST_OVERLOAD";
110
111 case remoting::protocol::CHANNEL_CONNECTION_ERROR:
112 return "CHANNEL_CONNECTION_ERROR";
113
114 case remoting::protocol::SIGNALING_ERROR:
115 return "SIGNALING_ERROR";
116
117 case remoting::protocol::SIGNALING_TIMEOUT:
118 return "SIGNALING_TIMEOUT";
119
120 case remoting::protocol::UNKNOWN_ERROR:
121 return "UNKNOWN_ERROR";
122
123 default:
124 LOG(ERROR) << "Unrecognized error code: '" << error_code << "'";
125 return "UNKNOWN_ERROR";
126 }
127 }
128
129 } // namespace 63 } // namespace
130 64
131 namespace remoting { 65 namespace remoting {
132 namespace test { 66 namespace test {
133 67
134 TestChromotingClient::TestChromotingClient() 68 TestChromotingClient::TestChromotingClient()
135 : connection_to_host_state_(protocol::ConnectionToHost::INITIALIZING), 69 : connection_to_host_state_(protocol::ConnectionToHost::INITIALIZING),
136 connection_error_code_(protocol::OK) {} 70 connection_error_code_(protocol::OK) {}
137 71
138 TestChromotingClient::TestChromotingClient( 72 TestChromotingClient::TestChromotingClient(
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 191
258 void TestChromotingClient::SetConnectionToHostForTests( 192 void TestChromotingClient::SetConnectionToHostForTests(
259 scoped_ptr<protocol::ConnectionToHost> connection_to_host) { 193 scoped_ptr<protocol::ConnectionToHost> connection_to_host) {
260 test_connection_to_host_ = connection_to_host.Pass(); 194 test_connection_to_host_ = connection_to_host.Pass();
261 } 195 }
262 196
263 void TestChromotingClient::OnConnectionState( 197 void TestChromotingClient::OnConnectionState(
264 protocol::ConnectionToHost::State state, 198 protocol::ConnectionToHost::State state,
265 protocol::ErrorCode error_code) { 199 protocol::ErrorCode error_code) {
266 VLOG(1) << "TestChromotingClient::OnConnectionState(" 200 VLOG(1) << "TestChromotingClient::OnConnectionState("
267 << "state: " << ConnectionStateToFriendlyString(state) << ", " 201 << "state: " << protocol::ConnectionToHost::StateToString(state)
268 << "error_code: " << ProtocolErrorToFriendlyString(error_code) 202 << ", error_code: " << protocol::ErrorCodeToString(error_code)
269 << ") Called"; 203 << ") Called";
270 204
271 connection_error_code_ = error_code; 205 connection_error_code_ = error_code;
272 connection_to_host_state_ = state; 206 connection_to_host_state_ = state;
273 207
274 FOR_EACH_OBSERVER(RemoteConnectionObserver, connection_observers_, 208 FOR_EACH_OBSERVER(RemoteConnectionObserver, connection_observers_,
275 ConnectionStateChanged(state, error_code)); 209 ConnectionStateChanged(state, error_code));
276 } 210 }
277 211
278 void TestChromotingClient::OnConnectionReady(bool ready) { 212 void TestChromotingClient::OnConnectionReady(bool ready) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 VLOG(1) << "TestChromotingClient::InjectClipboardEvent() Called"; 273 VLOG(1) << "TestChromotingClient::InjectClipboardEvent() Called";
340 } 274 }
341 275
342 void TestChromotingClient::SetCursorShape( 276 void TestChromotingClient::SetCursorShape(
343 const protocol::CursorShapeInfo& cursor_shape) { 277 const protocol::CursorShapeInfo& cursor_shape) {
344 VLOG(1) << "TestChromotingClient::SetCursorShape() Called"; 278 VLOG(1) << "TestChromotingClient::SetCursorShape() Called";
345 } 279 }
346 280
347 } // namespace test 281 } // namespace test
348 } // namespace remoting 282 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/test/connection_time_observer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698