OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_client.h" | 5 #include "remoting/protocol/connection_to_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "google/protobuf/message.h" | 10 #include "google/protobuf/message.h" |
11 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
12 #include "remoting/protocol/host_control_dispatcher.h" | 12 #include "remoting/protocol/host_control_dispatcher.h" |
13 #include "remoting/protocol/host_event_dispatcher.h" | 13 #include "remoting/protocol/host_event_dispatcher.h" |
14 #include "remoting/protocol/host_stub.h" | 14 #include "remoting/protocol/host_stub.h" |
15 #include "remoting/protocol/input_stub.h" | 15 #include "remoting/protocol/input_stub.h" |
16 | 16 |
17 namespace remoting { | 17 namespace remoting { |
18 namespace protocol { | 18 namespace protocol { |
19 | 19 |
20 ConnectionToClient::ConnectionToClient(protocol::Session* session) | 20 ConnectionToClient::ConnectionToClient(protocol::Session* session) |
21 : handler_(NULL), | 21 : handler_(NULL), |
22 host_stub_(NULL), | 22 host_stub_(NULL), |
23 input_stub_(NULL), | 23 input_stub_(NULL), |
24 session_(session) { | 24 session_(session) { |
25 session_->SetStateChangeCallback( | 25 session_->SetStateChangeCallback( |
26 base::Bind(&ConnectionToClient::OnSessionStateChange, | 26 base::Bind(&ConnectionToClient::OnSessionStateChange, |
27 base::Unretained(this))); | 27 base::Unretained(this))); |
| 28 session_->SetRouteChangeCallback( |
| 29 base::Bind(&ConnectionToClient::OnSessionRouteChange, |
| 30 base::Unretained(this))); |
28 } | 31 } |
29 | 32 |
30 ConnectionToClient::~ConnectionToClient() { | 33 ConnectionToClient::~ConnectionToClient() { |
31 if (session_.get()) { | 34 if (session_.get()) { |
32 base::MessageLoopProxy::current()->DeleteSoon( | 35 base::MessageLoopProxy::current()->DeleteSoon( |
33 FROM_HERE, session_.release()); | 36 FROM_HERE, session_.release()); |
34 } | 37 } |
35 } | 38 } |
36 | 39 |
37 void ConnectionToClient::SetEventHandler(EventHandler* event_handler) { | 40 void ConnectionToClient::SetEventHandler(EventHandler* event_handler) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 CloseChannels(); | 127 CloseChannels(); |
125 handler_->OnConnectionClosed(this); | 128 handler_->OnConnectionClosed(this); |
126 break; | 129 break; |
127 | 130 |
128 case Session::FAILED: | 131 case Session::FAILED: |
129 CloseOnError(); | 132 CloseOnError(); |
130 break; | 133 break; |
131 } | 134 } |
132 } | 135 } |
133 | 136 |
| 137 void ConnectionToClient::OnSessionRouteChange( |
| 138 const std::string& channel_name, const net::IPEndPoint& end_point) { |
| 139 handler_->OnClientIpEndPoint(this, channel_name, end_point); |
| 140 } |
| 141 |
134 void ConnectionToClient::OnChannelInitialized(bool successful) { | 142 void ConnectionToClient::OnChannelInitialized(bool successful) { |
135 DCHECK(CalledOnValidThread()); | 143 DCHECK(CalledOnValidThread()); |
136 | 144 |
137 if (!successful) { | 145 if (!successful) { |
138 LOG(ERROR) << "Failed to connect a channel"; | 146 LOG(ERROR) << "Failed to connect a channel"; |
139 CloseOnError(); | 147 CloseOnError(); |
140 return; | 148 return; |
141 } | 149 } |
142 | 150 |
143 NotifyIfChannelsReady(); | 151 NotifyIfChannelsReady(); |
(...skipping 15 matching lines...) Expand all Loading... |
159 } | 167 } |
160 | 168 |
161 void ConnectionToClient::CloseChannels() { | 169 void ConnectionToClient::CloseChannels() { |
162 control_dispatcher_.reset(); | 170 control_dispatcher_.reset(); |
163 event_dispatcher_.reset(); | 171 event_dispatcher_.reset(); |
164 video_writer_.reset(); | 172 video_writer_.reset(); |
165 } | 173 } |
166 | 174 |
167 } // namespace protocol | 175 } // namespace protocol |
168 } // namespace remoting | 176 } // namespace remoting |
OLD | NEW |