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

Side by Side Diff: remoting/protocol/ice_transport_channel.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 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « remoting/protocol/ice_transport_channel.h ('k') | remoting/protocol/ice_transport_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ice_transport_channel.h" 5 #include "remoting/protocol/ice_transport_channel.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 ice_username_fragment_( 54 ice_username_fragment_(
55 rtc::CreateRandomString(cricket::ICE_UFRAG_LENGTH)), 55 rtc::CreateRandomString(cricket::ICE_UFRAG_LENGTH)),
56 connect_attempts_left_(kMaxReconnectAttempts), 56 connect_attempts_left_(kMaxReconnectAttempts),
57 weak_factory_(this) { 57 weak_factory_(this) {
58 DCHECK(!ice_username_fragment_.empty()); 58 DCHECK(!ice_username_fragment_.empty());
59 } 59 }
60 60
61 IceTransportChannel::~IceTransportChannel() { 61 IceTransportChannel::~IceTransportChannel() {
62 DCHECK(delegate_); 62 DCHECK(delegate_);
63 63
64 delegate_->OnTransportDeleted(this); 64 delegate_->OnChannelDeleted(this);
65 65
66 auto task_runner = base::ThreadTaskRunnerHandle::Get(); 66 auto task_runner = base::ThreadTaskRunnerHandle::Get();
67 if (channel_) 67 if (channel_)
68 task_runner->DeleteSoon(FROM_HERE, channel_.release()); 68 task_runner->DeleteSoon(FROM_HERE, channel_.release());
69 if (port_allocator_) 69 if (port_allocator_)
70 task_runner->DeleteSoon(FROM_HERE, port_allocator_.release()); 70 task_runner->DeleteSoon(FROM_HERE, port_allocator_.release());
71 } 71 }
72 72
73 void IceTransportChannel::Connect(const std::string& name, 73 void IceTransportChannel::Connect(const std::string& name,
74 Delegate* delegate, 74 Delegate* delegate,
(...skipping 21 matching lines...) Expand all
96 96
97 // Create P2PTransportChannel, attach signal handlers and connect it. 97 // Create P2PTransportChannel, attach signal handlers and connect it.
98 // TODO(sergeyu): Specify correct component ID for the channel. 98 // TODO(sergeyu): Specify correct component ID for the channel.
99 channel_.reset(new cricket::P2PTransportChannel( 99 channel_.reset(new cricket::P2PTransportChannel(
100 std::string(), 0, nullptr, port_allocator_.get())); 100 std::string(), 0, nullptr, port_allocator_.get()));
101 std::string ice_password = rtc::CreateRandomString(cricket::ICE_PWD_LENGTH); 101 std::string ice_password = rtc::CreateRandomString(cricket::ICE_PWD_LENGTH);
102 channel_->SetIceProtocolType(cricket::ICEPROTO_RFC5245); 102 channel_->SetIceProtocolType(cricket::ICEPROTO_RFC5245);
103 channel_->SetIceRole((transport_context_->role() == TransportRole::CLIENT) 103 channel_->SetIceRole((transport_context_->role() == TransportRole::CLIENT)
104 ? cricket::ICEROLE_CONTROLLING 104 ? cricket::ICEROLE_CONTROLLING
105 : cricket::ICEROLE_CONTROLLED); 105 : cricket::ICEROLE_CONTROLLED);
106 delegate_->OnTransportIceCredentials(this, ice_username_fragment_, 106 delegate_->OnChannelIceCredentials(this, ice_username_fragment_,
107 ice_password); 107 ice_password);
108 channel_->SetIceCredentials(ice_username_fragment_, ice_password); 108 channel_->SetIceCredentials(ice_username_fragment_, ice_password);
109 channel_->SignalCandidateGathered.connect( 109 channel_->SignalCandidateGathered.connect(
110 this, &IceTransportChannel::OnCandidateGathered); 110 this, &IceTransportChannel::OnCandidateGathered);
111 channel_->SignalRouteChange.connect( 111 channel_->SignalRouteChange.connect(
112 this, &IceTransportChannel::OnRouteChange); 112 this, &IceTransportChannel::OnRouteChange);
113 channel_->SignalReceivingState.connect( 113 channel_->SignalReceivingState.connect(
114 this, &IceTransportChannel::OnReceivingState); 114 this, &IceTransportChannel::OnReceivingState);
115 channel_->SignalWritableState.connect( 115 channel_->SignalWritableState.connect(
116 this, &IceTransportChannel::OnWritableState); 116 this, &IceTransportChannel::OnWritableState);
117 channel_->set_incoming_only(!(transport_context_->network_settings().flags & 117 channel_->set_incoming_only(!(transport_context_->network_settings().flags &
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 bool IceTransportChannel::is_connected() const { 185 bool IceTransportChannel::is_connected() const {
186 DCHECK(thread_checker_.CalledOnValidThread()); 186 DCHECK(thread_checker_.CalledOnValidThread());
187 return callback_.is_null(); 187 return callback_.is_null();
188 } 188 }
189 189
190 void IceTransportChannel::OnCandidateGathered( 190 void IceTransportChannel::OnCandidateGathered(
191 cricket::TransportChannelImpl* channel, 191 cricket::TransportChannelImpl* channel,
192 const cricket::Candidate& candidate) { 192 const cricket::Candidate& candidate) {
193 DCHECK(thread_checker_.CalledOnValidThread()); 193 DCHECK(thread_checker_.CalledOnValidThread());
194 delegate_->OnTransportCandidate(this, candidate); 194 delegate_->OnChannelCandidate(this, candidate);
195 } 195 }
196 196
197 void IceTransportChannel::OnRouteChange( 197 void IceTransportChannel::OnRouteChange(
198 cricket::TransportChannel* channel, 198 cricket::TransportChannel* channel,
199 const cricket::Candidate& candidate) { 199 const cricket::Candidate& candidate) {
200 // Ignore notifications if the channel is not writable. 200 // Ignore notifications if the channel is not writable.
201 if (channel_->writable()) 201 if (channel_->writable())
202 NotifyRouteChanged(); 202 NotifyRouteChanged();
203 } 203 }
204 204
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 LOG(FATAL) << "Failed to convert peer IP address."; 254 LOG(FATAL) << "Failed to convert peer IP address.";
255 } 255 }
256 256
257 const cricket::Candidate& local_candidate = 257 const cricket::Candidate& local_candidate =
258 channel_->best_connection()->local_candidate(); 258 channel_->best_connection()->local_candidate();
259 if (!jingle_glue::SocketAddressToIPEndPoint( 259 if (!jingle_glue::SocketAddressToIPEndPoint(
260 local_candidate.address(), &route.local_address)) { 260 local_candidate.address(), &route.local_address)) {
261 LOG(FATAL) << "Failed to convert local IP address."; 261 LOG(FATAL) << "Failed to convert local IP address.";
262 } 262 }
263 263
264 delegate_->OnTransportRouteChange(this, route); 264 delegate_->OnChannelRouteChange(this, route);
265 } 265 }
266 266
267 void IceTransportChannel::TryReconnect() { 267 void IceTransportChannel::TryReconnect() {
268 DCHECK(!channel_->writable()); 268 DCHECK(!channel_->writable());
269 269
270 if (connect_attempts_left_ <= 0) { 270 if (connect_attempts_left_ <= 0) {
271 reconnect_timer_.Stop(); 271 reconnect_timer_.Stop();
272 272
273 // Notify the caller that ICE connection has failed - normally that will 273 // Notify the caller that ICE connection has failed - normally that will
274 // terminate Jingle connection (i.e. the transport will be destroyed). 274 // terminate Jingle connection (i.e. the transport will be destroyed).
275 delegate_->OnTransportFailed(this); 275 delegate_->OnChannelFailed(this);
276 return; 276 return;
277 } 277 }
278 --connect_attempts_left_; 278 --connect_attempts_left_;
279 279
280 // Restart ICE by resetting ICE password. 280 // Restart ICE by resetting ICE password.
281 std::string ice_password = rtc::CreateRandomString(cricket::ICE_PWD_LENGTH); 281 std::string ice_password = rtc::CreateRandomString(cricket::ICE_PWD_LENGTH);
282 delegate_->OnTransportIceCredentials(this, ice_username_fragment_, 282 delegate_->OnChannelIceCredentials(this, ice_username_fragment_,
283 ice_password); 283 ice_password);
284 channel_->SetIceCredentials(ice_username_fragment_, ice_password); 284 channel_->SetIceCredentials(ice_username_fragment_, ice_password);
285 } 285 }
286 286
287 } // namespace protocol 287 } // namespace protocol
288 } // namespace remoting 288 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/ice_transport_channel.h ('k') | remoting/protocol/ice_transport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698