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

Unified Diff: remoting/protocol/webrtc_transport.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_transport.cc
diff --git a/remoting/protocol/webrtc_transport.cc b/remoting/protocol/webrtc_transport.cc
index 6c4fc1c3bd7ed80a952b7d50bf648a9d7875a3cc..73ba2a4e10eaf559baba5c6ebb260d2a4121d6cd 100644
--- a/remoting/protocol/webrtc_transport.cc
+++ b/remoting/protocol/webrtc_transport.cc
@@ -102,18 +102,23 @@ class SetSessionDescriptionObserver
WebrtcTransport::WebrtcTransport(
rtc::Thread* worker_thread,
- scoped_refptr<TransportContext> transport_context)
- : transport_context_(transport_context),
- worker_thread_(worker_thread),
+ scoped_refptr<TransportContext> transport_context,
+ EventHandler* event_handler)
+ : worker_thread_(worker_thread),
+ transport_context_(transport_context),
+ event_handler_(event_handler),
weak_factory_(this) {}
WebrtcTransport::~WebrtcTransport() {}
-void WebrtcTransport::Start(EventHandler* event_handler,
- Authenticator* authenticator) {
+void WebrtcTransport::Start(
+ Authenticator* authenticator,
+ SendTransportInfoCallback send_transport_info_callback) {
DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(send_transport_info_callback_.is_null());
+
+ send_transport_info_callback_ = std::move(send_transport_info_callback);
- event_handler_ = event_handler;
// TODO(sergeyu): Use the |authenticator| to authenticate PeerConnection.
transport_context_->CreatePortAllocator(base::Bind(
@@ -245,15 +250,6 @@ StreamChannelFactory* WebrtcTransport::GetStreamChannelFactory() {
return &data_stream_adapter_;
}
-StreamChannelFactory* WebrtcTransport::GetMultiplexedChannelFactory() {
- DCHECK(thread_checker_.CalledOnValidThread());
- return GetStreamChannelFactory();
-}
-
-WebrtcTransport* WebrtcTransport::AsWebrtcTransport() {
- return this;
-}
-
void WebrtcTransport::OnLocalSessionDescriptionCreated(
scoped_ptr<webrtc::SessionDescriptionInterface> description,
const std::string& error) {
@@ -284,7 +280,7 @@ void WebrtcTransport::OnLocalSessionDescriptionCreated(
offer_tag->SetAttr(QName(std::string(), "type"), description->type());
offer_tag->SetBodyText(description_sdp);
- event_handler_->OnOutgoingTransportInfo(std::move(transport_info));
+ send_transport_info_callback_.Run(std::move(transport_info));
peer_connection_->SetLocalDescription(
SetSessionDescriptionObserver::Create(base::Bind(
@@ -343,7 +339,7 @@ void WebrtcTransport::Close(ErrorCode error) {
peer_connection_factory_ = nullptr;
if (error != OK)
- event_handler_->OnTransportError(error);
+ event_handler_->OnWebrtcTransportError(error);
}
void WebrtcTransport::OnSignalingChange(
@@ -395,7 +391,7 @@ void WebrtcTransport::OnIceConnectionChange(
DCHECK(thread_checker_.CalledOnValidThread());
if (new_state == webrtc::PeerConnectionInterface::kIceConnectionConnected)
- event_handler_->OnTransportConnected();
+ event_handler_->OnWebrtcTransportConnected();
}
void WebrtcTransport::OnIceGatheringChange(
@@ -470,9 +466,7 @@ void WebrtcTransport::SendTransportInfo() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(pending_transport_info_message_);
- event_handler_->OnOutgoingTransportInfo(
- std::move(pending_transport_info_message_));
- pending_transport_info_message_.reset();
+ send_transport_info_callback_.Run(std::move(pending_transport_info_message_));
}
void WebrtcTransport::AddPendingCandidatesIfPossible() {
@@ -491,18 +485,5 @@ void WebrtcTransport::AddPendingCandidatesIfPossible() {
}
}
-WebrtcTransportFactory::WebrtcTransportFactory(
- rtc::Thread* worker_thread,
- scoped_refptr<TransportContext> transport_context)
- : worker_thread_(worker_thread),
- transport_context_(transport_context) {}
-
-WebrtcTransportFactory::~WebrtcTransportFactory() {}
-
-scoped_ptr<Transport> WebrtcTransportFactory::CreateTransport() {
- return make_scoped_ptr(
- new WebrtcTransport(worker_thread_, transport_context_.get()));
-}
-
} // namespace protocol
} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698