Chromium Code Reviews| Index: remoting/protocol/webrtc_connection_to_client.cc |
| diff --git a/remoting/protocol/webrtc_connection_to_client.cc b/remoting/protocol/webrtc_connection_to_client.cc |
| index a625300f5e8e9965865fe0d30aa7e49e31618c3a..029bddcf50ef5b29f880e14398ea70959933c208 100644 |
| --- a/remoting/protocol/webrtc_connection_to_client.cc |
| +++ b/remoting/protocol/webrtc_connection_to_client.cc |
| @@ -18,6 +18,7 @@ |
| #include "remoting/protocol/host_event_dispatcher.h" |
| #include "remoting/protocol/host_stub.h" |
| #include "remoting/protocol/input_stub.h" |
| +#include "remoting/protocol/message_pipe.h" |
| #include "remoting/protocol/transport_context.h" |
| #include "remoting/protocol/webrtc_transport.h" |
| #include "remoting/protocol/webrtc_video_stream.h" |
| @@ -144,9 +145,9 @@ void WebrtcConnectionToClient::OnSessionStateChange(Session::State state) { |
| case Session::CLOSED: |
| case Session::FAILED: |
| - transport_->Close(state == Session::CLOSED ? OK : session_->error()); |
| control_dispatcher_.reset(); |
| event_dispatcher_.reset(); |
| + transport_->Close(state == Session::CLOSED ? OK : session_->error()); |
| event_handler_->OnConnectionClosed( |
| this, state == Session::CLOSED ? OK : session_->error()); |
| break; |
| @@ -154,11 +155,10 @@ void WebrtcConnectionToClient::OnSessionStateChange(Session::State state) { |
| } |
| void WebrtcConnectionToClient::OnWebrtcTransportConnecting() { |
| + // Create outgoing control channel by initializing |control_dispatcher_|. |
| + // |event_dispatcher_| is initialized later because event channel is expected |
| + // to be created by the client. |
| control_dispatcher_->Init(transport_->outgoing_channel_factory(), this); |
| - |
| - event_dispatcher_->Init(transport_->incoming_channel_factory(), this); |
| - event_dispatcher_->set_on_input_event_callback(base::Bind( |
| - &ConnectionToClient::OnInputEventReceived, base::Unretained(this))); |
| } |
| void WebrtcConnectionToClient::OnWebrtcTransportConnected() { |
| @@ -170,6 +170,17 @@ void WebrtcConnectionToClient::OnWebrtcTransportError(ErrorCode error) { |
| Disconnect(error); |
| } |
| +void WebrtcConnectionToClient::OnWebrtcTransportIncomingDataChannel( |
| + const std::string& name, |
| + std::unique_ptr<MessagePipe> pipe) { |
| + if (name == event_dispatcher_->channel_name() && |
| + !event_dispatcher_->is_connected()) { |
| + event_dispatcher_->set_on_input_event_callback(base::Bind( |
| + &ConnectionToClient::OnInputEventReceived, base::Unretained(this))); |
| + event_dispatcher_->Init(std::move(pipe), this); |
| + } |
| +} |
| + |
| void WebrtcConnectionToClient::OnWebrtcTransportMediaStreamAdded( |
| scoped_refptr<webrtc::MediaStreamInterface> stream) { |
| LOG(WARNING) << "The client created an unexpected media stream."; |
| @@ -188,5 +199,15 @@ void WebrtcConnectionToClient::OnChannelInitialized( |
| } |
| } |
| +void WebrtcConnectionToClient::OnChannelClosed( |
| + ChannelDispatcherBase* channel_dispatcher) { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + |
| + DCHECK(false); |
|
Jamie
2016/07/20 00:31:39
Left-over debugging?
Sergey Ulanov
2016/07/20 01:18:22
Done.
|
| + LOG(ERROR) << "Channel " << channel_dispatcher->channel_name() |
| + << " was closed unexpectedly."; |
| + Disconnect(INCOMPATIBLE_PROTOCOL); |
| +} |
| + |
| } // namespace protocol |
| } // namespace remoting |