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

Unified Diff: remoting/protocol/webrtc_connection_to_client.cc

Issue 2146213002: Add support for dynamic channels in WebrtcTransport. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/webrtc_connection_to_client.h ('k') | remoting/protocol/webrtc_connection_to_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..65df2fc4f4a82e4e47877a133b536a7571dbab59 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,14 @@ void WebrtcConnectionToClient::OnChannelInitialized(
}
}
+void WebrtcConnectionToClient::OnChannelClosed(
+ ChannelDispatcherBase* channel_dispatcher) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ LOG(ERROR) << "Channel " << channel_dispatcher->channel_name()
+ << " was closed unexpectedly.";
+ Disconnect(INCOMPATIBLE_PROTOCOL);
+}
+
} // namespace protocol
} // namespace remoting
« no previous file with comments | « remoting/protocol/webrtc_connection_to_client.h ('k') | remoting/protocol/webrtc_connection_to_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698