OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/jingle_session.h" | 5 #include "remoting/protocol/jingle_session.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 while(it != pending_remote_candidates_.end()) { | 243 while(it != pending_remote_candidates_.end()) { |
244 if (it->name == name) { | 244 if (it->name == name) { |
245 channel->AddRemoteCandidate(it->candidate); | 245 channel->AddRemoteCandidate(it->candidate); |
246 it = pending_remote_candidates_.erase(it); | 246 it = pending_remote_candidates_.erase(it); |
247 } else { | 247 } else { |
248 ++it; | 248 ++it; |
249 } | 249 } |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 void JingleSession::CreateStreamChannel( | 253 void JingleSession::CreateChannel(const std::string& name, |
254 const std::string& name, | 254 const ChannelCreatedCallback& callback) { |
255 const StreamChannelCallback& callback) { | |
256 DCHECK(!channels_[name]); | 255 DCHECK(!channels_[name]); |
257 | 256 |
258 scoped_ptr<ChannelAuthenticator> channel_authenticator = | 257 scoped_ptr<ChannelAuthenticator> channel_authenticator = |
259 authenticator_->CreateChannelAuthenticator(); | 258 authenticator_->CreateChannelAuthenticator(); |
260 scoped_ptr<StreamTransport> channel = | 259 scoped_ptr<StreamTransport> channel = |
261 session_manager_->transport_factory_->CreateStreamTransport(); | 260 session_manager_->transport_factory_->CreateStreamTransport(); |
262 channel->Initialize(name, this, channel_authenticator.Pass()); | 261 channel->Initialize(name, this, channel_authenticator.Pass()); |
263 channel->Connect(callback); | 262 channel->Connect(callback); |
264 AddPendingRemoteCandidates(channel.get(), name); | 263 AddPendingRemoteCandidates(channel.get(), name); |
265 channels_[name] = channel.release(); | 264 channels_[name] = channel.release(); |
266 } | 265 } |
267 | 266 |
268 void JingleSession::CreateDatagramChannel( | |
269 const std::string& name, | |
270 const DatagramChannelCallback& callback) { | |
271 DCHECK(!channels_[name]); | |
272 | |
273 scoped_ptr<ChannelAuthenticator> channel_authenticator = | |
274 authenticator_->CreateChannelAuthenticator(); | |
275 scoped_ptr<DatagramTransport> channel = | |
276 session_manager_->transport_factory_->CreateDatagramTransport(); | |
277 channel->Initialize(name, this, channel_authenticator.Pass()); | |
278 channel->Connect(callback); | |
279 AddPendingRemoteCandidates(channel.get(), name); | |
280 channels_[name] = channel.release(); | |
281 } | |
282 | |
283 void JingleSession::CancelChannelCreation(const std::string& name) { | 267 void JingleSession::CancelChannelCreation(const std::string& name) { |
284 ChannelsMap::iterator it = channels_.find(name); | 268 ChannelsMap::iterator it = channels_.find(name); |
285 if (it != channels_.end() && !it->second->is_connected()) { | 269 if (it != channels_.end() && !it->second->is_connected()) { |
286 delete it->second; | 270 delete it->second; |
287 DCHECK(!channels_[name]); | 271 DCHECK(!channels_[name]); |
288 } | 272 } |
289 } | 273 } |
290 | 274 |
291 void JingleSession::OnTransportCandidate(Transport* transport, | 275 void JingleSession::OnTransportCandidate(Transport* transport, |
292 const cricket::Candidate& candidate) { | 276 const cricket::Candidate& candidate) { |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 } | 659 } |
676 } | 660 } |
677 | 661 |
678 bool JingleSession::is_session_active() { | 662 bool JingleSession::is_session_active() { |
679 return state_ == CONNECTING || state_ == ACCEPTING || state_ == CONNECTED || | 663 return state_ == CONNECTING || state_ == ACCEPTING || state_ == CONNECTED || |
680 state_ == AUTHENTICATING || state_ == AUTHENTICATED; | 664 state_ == AUTHENTICATING || state_ == AUTHENTICATED; |
681 } | 665 } |
682 | 666 |
683 } // namespace protocol | 667 } // namespace protocol |
684 } // namespace remoting | 668 } // namespace remoting |
OLD | NEW |