OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/location.h" | 8 #include "base/location.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 165 } |
166 | 166 |
167 void JingleSession::CreateDatagramChannel( | 167 void JingleSession::CreateDatagramChannel( |
168 const std::string& name, const DatagramChannelCallback& callback) { | 168 const std::string& name, const DatagramChannelCallback& callback) { |
169 DCHECK(CalledOnValidThread()); | 169 DCHECK(CalledOnValidThread()); |
170 | 170 |
171 AddChannelConnector( | 171 AddChannelConnector( |
172 name, new JingleDatagramConnector(this, name, callback)); | 172 name, new JingleDatagramConnector(this, name, callback)); |
173 } | 173 } |
174 | 174 |
| 175 void JingleSession::CancelChannelCreation(const std::string& name) { |
| 176 ChannelConnectorsMap::iterator it = channel_connectors_.find(name); |
| 177 if (it != channel_connectors_.end()) { |
| 178 delete it->second; |
| 179 channel_connectors_.erase(it); |
| 180 } |
| 181 } |
| 182 |
175 net::Socket* JingleSession::control_channel() { | 183 net::Socket* JingleSession::control_channel() { |
176 DCHECK(CalledOnValidThread()); | 184 DCHECK(CalledOnValidThread()); |
177 return control_channel_socket_.get(); | 185 return control_channel_socket_.get(); |
178 } | 186 } |
179 | 187 |
180 net::Socket* JingleSession::event_channel() { | 188 net::Socket* JingleSession::event_channel() { |
181 DCHECK(CalledOnValidThread()); | 189 DCHECK(CalledOnValidThread()); |
182 return event_channel_socket_.get(); | 190 return event_channel_socket_.get(); |
183 } | 191 } |
184 | 192 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 // Workaround bug in libjingle - it doesn't connect channels if they | 433 // Workaround bug in libjingle - it doesn't connect channels if they |
426 // are created after the session is accepted. See crbug.com/89384. | 434 // are created after the session is accepted. See crbug.com/89384. |
427 // TODO(sergeyu): Fix the bug and remove this line. | 435 // TODO(sergeyu): Fix the bug and remove this line. |
428 cricket_session_->GetTransport(content_name)->ConnectChannels(); | 436 cricket_session_->GetTransport(content_name)->ConnectChannels(); |
429 } | 437 } |
430 | 438 |
431 void JingleSession::OnChannelConnectorFinished( | 439 void JingleSession::OnChannelConnectorFinished( |
432 const std::string& name, JingleChannelConnector* connector) { | 440 const std::string& name, JingleChannelConnector* connector) { |
433 DCHECK(CalledOnValidThread()); | 441 DCHECK(CalledOnValidThread()); |
434 DCHECK_EQ(channel_connectors_[name], connector); | 442 DCHECK_EQ(channel_connectors_[name], connector); |
435 channel_connectors_[name] = NULL; | 443 channel_connectors_.erase(name); |
436 } | 444 } |
437 | 445 |
438 void JingleSession::CreateChannels() { | 446 void JingleSession::CreateChannels() { |
439 CreateStreamChannel( | 447 CreateStreamChannel( |
440 kControlChannelName, | 448 kControlChannelName, |
441 base::Bind(&JingleSession::OnChannelConnected, | 449 base::Bind(&JingleSession::OnChannelConnected, |
442 base::Unretained(this), &control_channel_socket_)); | 450 base::Unretained(this), &control_channel_socket_)); |
443 CreateStreamChannel( | 451 CreateStreamChannel( |
444 kEventChannelName, | 452 kEventChannelName, |
445 base::Bind(&JingleSession::OnChannelConnected, | 453 base::Bind(&JingleSession::OnChannelConnected, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 DCHECK_NE(state_, FAILED); | 493 DCHECK_NE(state_, FAILED); |
486 | 494 |
487 state_ = new_state; | 495 state_ = new_state; |
488 if (!state_change_callback_.is_null()) | 496 if (!state_change_callback_.is_null()) |
489 state_change_callback_.Run(new_state); | 497 state_change_callback_.Run(new_state); |
490 } | 498 } |
491 } | 499 } |
492 | 500 |
493 } // namespace protocol | 501 } // namespace protocol |
494 } // namespace remoting | 502 } // namespace remoting |
OLD | NEW |