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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "content/public/common/content_switches.h" | 9 #include "content/public/common/content_switches.h" |
10 #include "content/renderer/p2p/socket_dispatcher.h" | |
10 | 11 |
11 namespace content { | 12 namespace content { |
12 | 13 |
13 P2PPortAllocator::Config::Config() {} | 14 P2PPortAllocator::Config::Config() {} |
14 | 15 |
15 P2PPortAllocator::Config::~Config() { | 16 P2PPortAllocator::Config::~Config() { |
16 } | 17 } |
17 | 18 |
18 P2PPortAllocator::Config::RelayServerConfig::RelayServerConfig() | 19 P2PPortAllocator::Config::RelayServerConfig::RelayServerConfig() |
19 : port(0) { | 20 : port(0) { |
20 } | 21 } |
21 | 22 |
22 P2PPortAllocator::Config::RelayServerConfig::~RelayServerConfig() { | 23 P2PPortAllocator::Config::RelayServerConfig::~RelayServerConfig() { |
23 } | 24 } |
24 | 25 |
25 P2PPortAllocator::P2PPortAllocator( | 26 P2PPortAllocator::P2PPortAllocator( |
26 P2PSocketDispatcher* socket_dispatcher, | 27 const scoped_refptr<P2PSocketDispatcher>& socket_dispatcher, |
27 rtc::NetworkManager* network_manager, | 28 scoped_ptr<rtc::NetworkManager> network_manager, |
28 rtc::PacketSocketFactory* socket_factory, | 29 rtc::PacketSocketFactory* socket_factory, |
29 const Config& config, | 30 const Config& config, |
30 const GURL& origin) | 31 const GURL& origin, |
31 : cricket::BasicPortAllocator(network_manager, socket_factory), | 32 const scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
33 : cricket::BasicPortAllocator(network_manager.get(), socket_factory), | |
34 network_manager_(network_manager.Pass()), | |
32 socket_dispatcher_(socket_dispatcher), | 35 socket_dispatcher_(socket_dispatcher), |
33 config_(config), | 36 config_(config), |
34 origin_(origin) | 37 origin_(origin), |
35 { | 38 network_manager_task_runner_(task_runner) { |
36 uint32 flags = 0; | 39 uint32 flags = 0; |
37 if (!config_.enable_multiple_routes) | 40 if (!config_.enable_multiple_routes) |
38 flags |= cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION; | 41 flags |= cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION; |
39 if (!config_.enable_nonproxied_udp) { | 42 if (!config_.enable_nonproxied_udp) { |
40 flags |= cricket::PORTALLOCATOR_DISABLE_UDP | | 43 flags |= cricket::PORTALLOCATOR_DISABLE_UDP | |
41 cricket::PORTALLOCATOR_DISABLE_STUN | | 44 cricket::PORTALLOCATOR_DISABLE_STUN | |
42 cricket::PORTALLOCATOR_DISABLE_UDP_RELAY; | 45 cricket::PORTALLOCATOR_DISABLE_UDP_RELAY; |
43 } | 46 } |
44 set_flags(flags); | 47 set_flags(flags); |
45 set_allow_tcp_listen(false); | 48 set_allow_tcp_listen(false); |
46 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 49 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
47 bool enable_webrtc_stun_origin = | 50 bool enable_webrtc_stun_origin = |
48 cmd_line->HasSwitch(switches::kEnableWebRtcStunOrigin); | 51 cmd_line->HasSwitch(switches::kEnableWebRtcStunOrigin); |
49 if (enable_webrtc_stun_origin) { | 52 if (enable_webrtc_stun_origin) { |
50 set_origin(origin.spec()); | 53 set_origin(origin_.spec()); |
51 } | 54 } |
52 } | 55 } |
53 | 56 |
54 P2PPortAllocator::~P2PPortAllocator() { | 57 P2PPortAllocator::~P2PPortAllocator() { |
58 network_manager_task_runner_->DeleteSoon(FROM_HERE, | |
Sergey Ulanov
2015/09/24 19:37:29
If you need this it means P2PPortAllocator is dele
guoweis_left_chromium
2015/09/24 23:06:01
Done.
| |
59 network_manager_.release()); | |
55 } | 60 } |
56 | 61 |
57 cricket::PortAllocatorSession* P2PPortAllocator::CreateSessionInternal( | 62 cricket::PortAllocatorSession* P2PPortAllocator::CreateSessionInternal( |
58 const std::string& content_name, | 63 const std::string& content_name, |
59 int component, | 64 int component, |
60 const std::string& ice_username_fragment, | 65 const std::string& ice_username_fragment, |
61 const std::string& ice_password) { | 66 const std::string& ice_password) { |
62 return new P2PPortAllocatorSession( | 67 return new P2PPortAllocatorSession( |
63 this, content_name, component, ice_username_fragment, ice_password); | 68 this, content_name, component, ice_username_fragment, ice_password); |
64 } | 69 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 config.relays[i].port), | 110 config.relays[i].port), |
106 protocol, | 111 protocol, |
107 config.relays[i].secure)); | 112 config.relays[i].secure)); |
108 relay_server.credentials = credentials; | 113 relay_server.credentials = credentials; |
109 port_config->AddRelay(relay_server); | 114 port_config->AddRelay(relay_server); |
110 } | 115 } |
111 ConfigReady(port_config); | 116 ConfigReady(port_config); |
112 } | 117 } |
113 | 118 |
114 } // namespace content | 119 } // namespace content |
OLD | NEW |