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

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: Added errors.cc and cleaned up switch statements. 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 #define RETURN_STRING_LITERAL(x) \
Sergey Ulanov 2015/07/30 22:00:44 nit: move this next to StateToString()
tonychun 2015/07/30 23:20:26 Done.
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),
35 error_(OK) { 39 error_(OK) {
36 } 40 }
37 41
38 ConnectionToHostImpl::~ConnectionToHostImpl() { 42 ConnectionToHostImpl::~ConnectionToHostImpl() {
39 CloseChannels(); 43 CloseChannels();
40 44
41 if (session_.get()) 45 if (session_.get())
42 session_.reset(); 46 session_.reset();
43 47
44 if (session_manager_.get()) 48 if (session_manager_.get())
45 session_manager_.reset(); 49 session_manager_.reset();
46 50
47 if (signal_strategy_) 51 if (signal_strategy_)
48 signal_strategy_->RemoveListener(this); 52 signal_strategy_->RemoveListener(this);
49 } 53 }
50 54
55 const char* ConnectionToHost::StateToString(State state) {
56 switch (state) {
57 RETURN_STRING_LITERAL(INITIALIZING);
58 RETURN_STRING_LITERAL(CONNECTING);
59 RETURN_STRING_LITERAL(AUTHENTICATED);
60 RETURN_STRING_LITERAL(CONNECTED);
61 RETURN_STRING_LITERAL(CLOSED);
62 RETURN_STRING_LITERAL(FAILED);
63 }
64 NOTREACHED();
65 return nullptr;
66 }
67
51 void ConnectionToHostImpl::Connect( 68 void ConnectionToHostImpl::Connect(
52 SignalStrategy* signal_strategy, 69 SignalStrategy* signal_strategy,
53 scoped_ptr<TransportFactory> transport_factory, 70 scoped_ptr<TransportFactory> transport_factory,
54 scoped_ptr<Authenticator> authenticator, 71 scoped_ptr<Authenticator> authenticator,
55 const std::string& host_jid, 72 const std::string& host_jid,
56 HostEventCallback* event_callback) { 73 HostEventCallback* event_callback) {
57 DCHECK(client_stub_); 74 DCHECK(client_stub_);
58 DCHECK(clipboard_stub_); 75 DCHECK(clipboard_stub_);
59 DCHECK(monitored_video_stub_); 76 DCHECK(monitored_video_stub_);
60 77
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 311
295 if (state != state_) { 312 if (state != state_) {
296 state_ = state; 313 state_ = state;
297 error_ = error; 314 error_ = error;
298 event_callback_->OnConnectionState(state_, error_); 315 event_callback_->OnConnectionState(state_, error_);
299 } 316 }
300 } 317 }
301 318
302 } // namespace protocol 319 } // namespace protocol
303 } // namespace remoting 320 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698