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

Side by Side Diff: remoting/protocol/connection_to_host_impl.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: Moved ConnectionStateToFriendlyString to ConnectionToHostImpl and Added environment class to main. 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
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/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 namespace remoting { 25 namespace remoting {
26 namespace protocol { 26 namespace protocol {
27 27
28 const char* ConnectionStateToFriendlyString(
29 remoting::protocol::ConnectionToHost::State state) {
30 switch (state) {
31 case remoting::protocol::ConnectionToHost::INITIALIZING:
Sergey Ulanov 2015/07/29 00:56:23 You can use macro like this to make this code shor
tonychun 2015/07/29 16:10:13 Done.
32 return "INITIALIZING";
33
34 case remoting::protocol::ConnectionToHost::CONNECTING:
35 return "CONNECTING";
36
37 case remoting::protocol::ConnectionToHost::AUTHENTICATED:
38 return "AUTHENTICATED";
39
40 case remoting::protocol::ConnectionToHost::CONNECTED:
41 return "CONNECTED";
42
43 case remoting::protocol::ConnectionToHost::CLOSED:
44 return "CLOSED";
45
46 case remoting::protocol::ConnectionToHost::FAILED:
47 return "FAILED";
48
49 default:
50 LOG(ERROR) << "Unknown connection state: '" << state << "'";
51 return "UNKNOWN";
52 }
53 }
54
55 const char* ProtocolErrorToFriendlyString(
56 remoting::protocol::ErrorCode error_code) {
57 switch (error_code) {
58 case remoting::protocol::OK:
59 return "NONE";
60
61 case remoting::protocol::PEER_IS_OFFLINE:
62 return "PEER_IS_OFFLINE";
63
64 case remoting::protocol::SESSION_REJECTED:
65 return "SESSION_REJECTED";
66
67 case remoting::protocol::AUTHENTICATION_FAILED:
68 return "AUTHENTICATION_FAILED";
69
70 case remoting::protocol::INCOMPATIBLE_PROTOCOL:
71 return "INCOMPATIBLE_PROTOCOL";
72
73 case remoting::protocol::HOST_OVERLOAD:
74 return "HOST_OVERLOAD";
75
76 case remoting::protocol::CHANNEL_CONNECTION_ERROR:
77 return "CHANNEL_CONNECTION_ERROR";
78
79 case remoting::protocol::SIGNALING_ERROR:
80 return "SIGNALING_ERROR";
81
82 case remoting::protocol::SIGNALING_TIMEOUT:
83 return "SIGNALING_TIMEOUT";
84
85 case remoting::protocol::UNKNOWN_ERROR:
86 return "UNKNOWN_ERROR";
87
88 default:
89 LOG(ERROR) << "Unrecognized error code: '" << error_code << "'";
90 return "UNKNOWN_ERROR";
91 }
92 }
93
28 ConnectionToHostImpl::ConnectionToHostImpl() 94 ConnectionToHostImpl::ConnectionToHostImpl()
29 : event_callback_(nullptr), 95 : event_callback_(nullptr),
30 client_stub_(nullptr), 96 client_stub_(nullptr),
31 clipboard_stub_(nullptr), 97 clipboard_stub_(nullptr),
32 audio_stub_(nullptr), 98 audio_stub_(nullptr),
33 signal_strategy_(nullptr), 99 signal_strategy_(nullptr),
34 state_(INITIALIZING), 100 state_(INITIALIZING),
35 error_(OK) { 101 error_(OK) {
36 } 102 }
37 103
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 360
295 if (state != state_) { 361 if (state != state_) {
296 state_ = state; 362 state_ = state;
297 error_ = error; 363 error_ = error;
298 event_callback_->OnConnectionState(state_, error_); 364 event_callback_->OnConnectionState(state_, error_);
299 } 365 }
300 } 366 }
301 367
302 } // namespace protocol 368 } // namespace protocol
303 } // namespace remoting 369 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698