OLD | NEW |
---|---|
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/protocol/connection_to_host_impl.h" | 5 #include "remoting/protocol/connection_to_host_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
11 #include "remoting/protocol/audio_reader.h" | 11 #include "remoting/protocol/audio_reader.h" |
12 #include "remoting/protocol/audio_stub.h" | 12 #include "remoting/protocol/audio_stub.h" |
13 #include "remoting/protocol/auth_util.h" | 13 #include "remoting/protocol/auth_util.h" |
14 #include "remoting/protocol/authenticator.h" | 14 #include "remoting/protocol/authenticator.h" |
15 #include "remoting/protocol/client_control_dispatcher.h" | 15 #include "remoting/protocol/client_control_dispatcher.h" |
16 #include "remoting/protocol/client_event_dispatcher.h" | 16 #include "remoting/protocol/client_event_dispatcher.h" |
17 #include "remoting/protocol/client_stub.h" | 17 #include "remoting/protocol/client_stub.h" |
18 #include "remoting/protocol/client_video_dispatcher.h" | 18 #include "remoting/protocol/client_video_dispatcher.h" |
19 #include "remoting/protocol/clipboard_stub.h" | 19 #include "remoting/protocol/clipboard_stub.h" |
20 #include "remoting/protocol/errors.h" | 20 #include "remoting/protocol/errors.h" |
21 #include "remoting/protocol/jingle_session_manager.h" | 21 #include "remoting/protocol/jingle_session_manager.h" |
22 #include "remoting/protocol/transport.h" | 22 #include "remoting/protocol/transport.h" |
23 #include "remoting/protocol/video_stub.h" | 23 #include "remoting/protocol/video_stub.h" |
24 | 24 |
25 #define RETURN_STRING_LITERAL(x) \ | |
26 case x: \ | |
27 return #x; | |
28 | |
25 namespace remoting { | 29 namespace remoting { |
26 namespace protocol { | 30 namespace protocol { |
27 | 31 |
28 ConnectionToHostImpl::ConnectionToHostImpl() | 32 ConnectionToHostImpl::ConnectionToHostImpl() |
29 : event_callback_(nullptr), | 33 : event_callback_(nullptr), |
30 client_stub_(nullptr), | 34 client_stub_(nullptr), |
31 clipboard_stub_(nullptr), | 35 clipboard_stub_(nullptr), |
32 audio_stub_(nullptr), | 36 audio_stub_(nullptr), |
33 signal_strategy_(nullptr), | 37 signal_strategy_(nullptr), |
34 state_(INITIALIZING), | 38 state_(INITIALIZING), |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 // |error| should be specified only when |state| is set to FAILED. | 296 // |error| should be specified only when |state| is set to FAILED. |
293 DCHECK(state == FAILED || error == OK); | 297 DCHECK(state == FAILED || error == OK); |
294 | 298 |
295 if (state != state_) { | 299 if (state != state_) { |
296 state_ = state; | 300 state_ = state; |
297 error_ = error; | 301 error_ = error; |
298 event_callback_->OnConnectionState(state_, error_); | 302 event_callback_->OnConnectionState(state_, error_); |
299 } | 303 } |
300 } | 304 } |
301 | 305 |
306 const char* ConnectionStateToString(ConnectionToHost::State state) { | |
307 switch (state) { | |
308 RETURN_STRING_LITERAL(ConnectionToHost::INITIALIZING); | |
309 RETURN_STRING_LITERAL(ConnectionToHost::CONNECTING); | |
310 RETURN_STRING_LITERAL(ConnectionToHost::AUTHENTICATED); | |
311 RETURN_STRING_LITERAL(ConnectionToHost::CONNECTED); | |
312 RETURN_STRING_LITERAL(ConnectionToHost::CLOSED); | |
313 RETURN_STRING_LITERAL(ConnectionToHost::FAILED); | |
314 default: | |
Sergey Ulanov
2015/07/30 21:00:42
nit: default case should be marked as NOTREACHED()
tonychun
2015/07/30 21:43:16
Done.
| |
315 LOG(ERROR) << "Unknown connection state: '" << state << "'"; | |
316 return "ConnectionToHost::UNKNOWN"; | |
317 } | |
318 } | |
319 | |
320 const char* ErrorCodeToString(ErrorCode error) { | |
Sergey Ulanov
2015/07/30 21:00:42
This function is declared in remoting/protocol/err
tonychun
2015/07/30 21:43:16
Done.
| |
321 switch (error) { | |
322 RETURN_STRING_LITERAL(OK); | |
323 RETURN_STRING_LITERAL(PEER_IS_OFFLINE); | |
324 RETURN_STRING_LITERAL(SESSION_REJECTED); | |
325 RETURN_STRING_LITERAL(INCOMPATIBLE_PROTOCOL); | |
326 RETURN_STRING_LITERAL(AUTHENTICATION_FAILED); | |
327 RETURN_STRING_LITERAL(CHANNEL_CONNECTION_ERROR); | |
328 RETURN_STRING_LITERAL(SIGNALING_ERROR); | |
329 RETURN_STRING_LITERAL(SIGNALING_TIMEOUT); | |
330 RETURN_STRING_LITERAL(HOST_OVERLOAD); | |
331 RETURN_STRING_LITERAL(UNKNOWN_ERROR); | |
332 default: | |
Sergey Ulanov
2015/07/30 21:00:42
same as the previous comment about default case.
tonychun
2015/07/30 21:43:16
Done.
| |
333 LOG(ERROR) << "Unknown error: '" << error << "'"; | |
334 return "UNKNOWN ERROR"; | |
335 } | |
336 } | |
337 | |
302 } // namespace protocol | 338 } // namespace protocol |
303 } // namespace remoting | 339 } // namespace remoting |
OLD | NEW |