Chromium Code Reviews| 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 "content/renderer/p2p/port_allocator.h" | 5 #include "content/renderer/p2p/port_allocator.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 15 #include "content/renderer/p2p/socket_dispatcher.h" | 15 #include "content/renderer/p2p/socket_dispatcher.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 P2PPortAllocator::P2PPortAllocator( | 19 P2PPortAllocator::P2PPortAllocator( |
| 20 const scoped_refptr<P2PSocketDispatcher>& socket_dispatcher, | 20 const scoped_refptr<P2PSocketDispatcher>& socket_dispatcher, |
| 21 std::unique_ptr<rtc::NetworkManager> network_manager, | 21 std::unique_ptr<rtc::NetworkManager> network_manager, |
| 22 rtc::PacketSocketFactory* socket_factory, | 22 rtc::PacketSocketFactory* socket_factory, |
| 23 const Config& config, | 23 const Config& config, |
| 24 const GURL& origin, | 24 const GURL& origin) |
| 25 const scoped_refptr<base::SingleThreadTaskRunner> task_runner) | |
| 26 : cricket::BasicPortAllocator(network_manager.get(), socket_factory), | 25 : cricket::BasicPortAllocator(network_manager.get(), socket_factory), |
| 27 network_manager_(std::move(network_manager)), | 26 network_manager_(std::move(network_manager)), |
| 28 socket_dispatcher_(socket_dispatcher), | 27 socket_dispatcher_(socket_dispatcher), |
| 29 config_(config), | 28 config_(config), |
| 30 origin_(origin), | 29 origin_(origin) { |
| 31 network_manager_task_runner_(task_runner) { | |
| 32 uint32_t flags = 0; | 30 uint32_t flags = 0; |
| 33 if (!config_.enable_multiple_routes) { | 31 if (!config_.enable_multiple_routes) { |
| 34 flags |= cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION; | 32 flags |= cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION; |
| 35 } | 33 } |
| 36 if (!config_.enable_default_local_candidate) { | 34 if (!config_.enable_default_local_candidate) { |
| 37 flags |= cricket::PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE; | 35 flags |= cricket::PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE; |
| 38 } | 36 } |
| 39 if (!config_.enable_nonproxied_udp) { | 37 if (!config_.enable_nonproxied_udp) { |
| 40 flags |= cricket::PORTALLOCATOR_DISABLE_UDP | | 38 flags |= cricket::PORTALLOCATOR_DISABLE_UDP | |
| 41 cricket::PORTALLOCATOR_DISABLE_STUN | | 39 cricket::PORTALLOCATOR_DISABLE_STUN | |
| 42 cricket::PORTALLOCATOR_DISABLE_UDP_RELAY; | 40 cricket::PORTALLOCATOR_DISABLE_UDP_RELAY; |
| 43 } | 41 } |
| 44 set_flags(flags); | 42 set_flags(flags); |
| 45 set_allow_tcp_listen(false); | 43 set_allow_tcp_listen(false); |
| 46 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 44 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 47 bool enable_webrtc_stun_origin = | 45 bool enable_webrtc_stun_origin = |
| 48 cmd_line->HasSwitch(switches::kEnableWebRtcStunOrigin); | 46 cmd_line->HasSwitch(switches::kEnableWebRtcStunOrigin); |
| 49 if (enable_webrtc_stun_origin) { | 47 if (enable_webrtc_stun_origin) { |
| 50 set_origin(origin_.spec()); | 48 set_origin(origin_.spec()); |
| 51 } | 49 } |
| 52 } | 50 } |
| 53 | 51 |
| 54 // TODO(guoweis): P2PPortAllocator is also deleted in the wrong thread | 52 P2PPortAllocator::~P2PPortAllocator() {} |
|
Sergey Ulanov
2016/05/13 19:44:21
Maybe add ThreadChecker in P2PPortAllocator to mak
| |
| 55 // here. It's created in signaling thread, and held by webrtc::PeerConnection, | |
| 56 // only used on worker thread. The destructor is invoked on signaling thread | |
| 57 // again. crbug.com/535761. DeleteSoon can be removed once the bug is fixed. | |
| 58 P2PPortAllocator::~P2PPortAllocator() { | |
| 59 network_manager_task_runner_->DeleteSoon(FROM_HERE, | |
| 60 network_manager_.release()); | |
| 61 } | |
| 62 | 53 |
| 63 } // namespace content | 54 } // namespace content |
| OLD | NEW |