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

Unified Diff: remoting/protocol/webrtc_connection_to_host.cc

Issue 1545743002: Move ownership of Transport out of Session. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_not_pass_client
Patch Set: Created 5 years 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
Index: remoting/protocol/webrtc_connection_to_host.cc
diff --git a/remoting/protocol/webrtc_connection_to_host.cc b/remoting/protocol/webrtc_connection_to_host.cc
index 52dfc594e41b5094b3946b8fef1b777c079d6bef..6a7326f0407a2e0de8521de4fddd18ebc7b85136 100644
--- a/remoting/protocol/webrtc_connection_to_host.cc
+++ b/remoting/protocol/webrtc_connection_to_host.cc
@@ -4,10 +4,12 @@
#include "remoting/protocol/webrtc_connection_to_host.h"
+#include "jingle/glue/thread_wrapper.h"
#include "remoting/protocol/client_control_dispatcher.h"
#include "remoting/protocol/client_event_dispatcher.h"
#include "remoting/protocol/client_stub.h"
#include "remoting/protocol/clipboard_stub.h"
+#include "remoting/protocol/transport_context.h"
#include "remoting/protocol/webrtc_transport.h"
namespace remoting {
@@ -16,13 +18,19 @@ namespace protocol {
WebrtcConnectionToHost::WebrtcConnectionToHost() {}
WebrtcConnectionToHost::~WebrtcConnectionToHost() {}
-void WebrtcConnectionToHost::Connect(scoped_ptr<Session> session,
- HostEventCallback* event_callback) {
+void WebrtcConnectionToHost::Connect(
+ scoped_ptr<Session> session,
+ scoped_refptr<TransportContext> transport_context,
+ HostEventCallback* event_callback) {
DCHECK(client_stub_);
DCHECK(clipboard_stub_);
+ transport_.reset(new WebrtcTransport(
+ jingle_glue::JingleThreadWrapper::current(), transport_context, this));
+
session_ = std::move(session);
session_->SetEventHandler(this);
+ session_->SetTransport(transport_.get());
event_callback_ = event_callback;
@@ -70,7 +78,6 @@ void WebrtcConnectionToHost::OnSessionStateChange(Session::State state) {
case Session::ACCEPTING:
case Session::ACCEPTED:
case Session::AUTHENTICATING:
- case Session::CONNECTED:
// Don't care about these events.
break;
@@ -78,14 +85,12 @@ void WebrtcConnectionToHost::OnSessionStateChange(Session::State state) {
SetState(AUTHENTICATED, OK);
control_dispatcher_.reset(new ClientControlDispatcher());
- control_dispatcher_->Init(
- session_->GetTransport()->GetStreamChannelFactory(), this);
+ control_dispatcher_->Init(transport_->GetStreamChannelFactory(), this);
control_dispatcher_->set_client_stub(client_stub_);
control_dispatcher_->set_clipboard_stub(clipboard_stub_);
event_dispatcher_.reset(new ClientEventDispatcher());
- event_dispatcher_->Init(
- session_->GetTransport()->GetStreamChannelFactory(), this);
+ event_dispatcher_->Init(transport_->GetStreamChannelFactory(), this);
break;
case Session::CLOSED:
@@ -96,10 +101,11 @@ void WebrtcConnectionToHost::OnSessionStateChange(Session::State state) {
}
}
-void WebrtcConnectionToHost::OnSessionRouteChange(
- const std::string& channel_name,
- const TransportRoute& route) {
- event_callback_->OnRouteChanged(channel_name, route);
+void WebrtcConnectionToHost::OnWebrtcTransportConnected() {}
+
+void WebrtcConnectionToHost::OnWebrtcTransportError(ErrorCode error) {
+ CloseChannels();
+ SetState(FAILED, error);
}
void WebrtcConnectionToHost::OnChannelInitialized(
@@ -113,7 +119,6 @@ void WebrtcConnectionToHost::OnChannelError(
LOG(ERROR) << "Failed to connect channel " << channel_dispatcher;
CloseChannels();
SetState(FAILED, CHANNEL_CONNECTION_ERROR);
- return;
}
ConnectionToHost::State WebrtcConnectionToHost::state() const {

Powered by Google App Engine
This is Rietveld 408576698