| OLD | NEW |
| 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" |
| 11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 14 #include "jingle/glue/utils.h" | 14 #include "jingle/glue/utils.h" |
| 15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 16 #include "remoting/protocol/channel_socket_adapter.h" | 16 #include "remoting/protocol/channel_socket_adapter.h" |
| 17 #include "remoting/protocol/port_allocator_factory.h" |
| 17 #include "remoting/protocol/transport_context.h" | 18 #include "remoting/protocol/transport_context.h" |
| 18 #include "third_party/webrtc/base/network.h" | 19 #include "third_party/webrtc/base/network.h" |
| 19 #include "third_party/webrtc/p2p/base/constants.h" | 20 #include "third_party/webrtc/p2p/base/constants.h" |
| 20 #include "third_party/webrtc/p2p/base/p2ptransportchannel.h" | 21 #include "third_party/webrtc/p2p/base/p2ptransportchannel.h" |
| 21 #include "third_party/webrtc/p2p/base/port.h" | 22 #include "third_party/webrtc/p2p/base/port.h" |
| 22 #include "third_party/webrtc/p2p/client/httpportallocator.h" | 23 #include "third_party/webrtc/p2p/client/httpportallocator.h" |
| 23 | 24 |
| 24 namespace remoting { | 25 namespace remoting { |
| 25 namespace protocol { | 26 namespace protocol { |
| 26 | 27 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 DCHECK(thread_checker_.CalledOnValidThread()); | 77 DCHECK(thread_checker_.CalledOnValidThread()); |
| 77 DCHECK(!name.empty()); | 78 DCHECK(!name.empty()); |
| 78 DCHECK(delegate); | 79 DCHECK(delegate); |
| 79 DCHECK(!callback.is_null()); | 80 DCHECK(!callback.is_null()); |
| 80 | 81 |
| 81 DCHECK(name_.empty()); | 82 DCHECK(name_.empty()); |
| 82 name_ = name; | 83 name_ = name; |
| 83 delegate_ = delegate; | 84 delegate_ = delegate; |
| 84 callback_ = callback; | 85 callback_ = callback; |
| 85 | 86 |
| 86 transport_context_->CreatePortAllocator( | 87 port_allocator_ = |
| 87 base::Bind(&IceTransportChannel::OnPortAllocatorCreated, | 88 transport_context_->port_allocator_factory()->CreatePortAllocator( |
| 88 weak_factory_.GetWeakPtr())); | 89 transport_context_); |
| 89 } | |
| 90 | |
| 91 void IceTransportChannel::OnPortAllocatorCreated( | |
| 92 scoped_ptr<cricket::PortAllocator> port_allocator){ | |
| 93 DCHECK(!channel_.get()); | |
| 94 | |
| 95 port_allocator_ = std::move(port_allocator); | |
| 96 | 90 |
| 97 // Create P2PTransportChannel, attach signal handlers and connect it. | 91 // Create P2PTransportChannel, attach signal handlers and connect it. |
| 98 // TODO(sergeyu): Specify correct component ID for the channel. | 92 // TODO(sergeyu): Specify correct component ID for the channel. |
| 99 channel_.reset(new cricket::P2PTransportChannel( | 93 channel_.reset(new cricket::P2PTransportChannel( |
| 100 std::string(), 0, nullptr, port_allocator_.get())); | 94 std::string(), 0, nullptr, port_allocator_.get())); |
| 101 std::string ice_password = rtc::CreateRandomString(cricket::ICE_PWD_LENGTH); | 95 std::string ice_password = rtc::CreateRandomString(cricket::ICE_PWD_LENGTH); |
| 102 channel_->SetIceProtocolType(cricket::ICEPROTO_RFC5245); | 96 channel_->SetIceProtocolType(cricket::ICEPROTO_RFC5245); |
| 103 channel_->SetIceRole((transport_context_->role() == TransportRole::CLIENT) | 97 channel_->SetIceRole((transport_context_->role() == TransportRole::CLIENT) |
| 104 ? cricket::ICEROLE_CONTROLLING | 98 ? cricket::ICEROLE_CONTROLLING |
| 105 : cricket::ICEROLE_CONTROLLED); | 99 : cricket::ICEROLE_CONTROLLED); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 268 |
| 275 // Restart ICE by resetting ICE password. | 269 // Restart ICE by resetting ICE password. |
| 276 std::string ice_password = rtc::CreateRandomString(cricket::ICE_PWD_LENGTH); | 270 std::string ice_password = rtc::CreateRandomString(cricket::ICE_PWD_LENGTH); |
| 277 delegate_->OnChannelIceCredentials(this, ice_username_fragment_, | 271 delegate_->OnChannelIceCredentials(this, ice_username_fragment_, |
| 278 ice_password); | 272 ice_password); |
| 279 channel_->SetIceCredentials(ice_username_fragment_, ice_password); | 273 channel_->SetIceCredentials(ice_username_fragment_, ice_password); |
| 280 } | 274 } |
| 281 | 275 |
| 282 } // namespace protocol | 276 } // namespace protocol |
| 283 } // namespace remoting | 277 } // namespace remoting |
| OLD | NEW |