Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: content/renderer/p2p/port_allocator.cc

Issue 1349823004: Check media permissions (mic/camera) before exposing local addresses to WebRTC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, fix test issue, fix windows build issue. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/p2p/port_allocator.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
57 // TODO(guoweis): P2PPortAllocator is also deleted in the wrong thread
58 // here. It's created in signaling thread, and held by webrtc::PeerConnection,
59 // only used on worker thread. The destructor is invoked on signaling thread
60 // again. crbug.com/535761. DeleteSoon can be removed once the bug is fixed.
54 P2PPortAllocator::~P2PPortAllocator() { 61 P2PPortAllocator::~P2PPortAllocator() {
62 network_manager_task_runner_->DeleteSoon(FROM_HERE,
63 network_manager_.release());
55 } 64 }
56 65
57 cricket::PortAllocatorSession* P2PPortAllocator::CreateSessionInternal( 66 cricket::PortAllocatorSession* P2PPortAllocator::CreateSessionInternal(
58 const std::string& content_name, 67 const std::string& content_name,
59 int component, 68 int component,
60 const std::string& ice_username_fragment, 69 const std::string& ice_username_fragment,
61 const std::string& ice_password) { 70 const std::string& ice_password) {
62 return new P2PPortAllocatorSession( 71 return new P2PPortAllocatorSession(
63 this, content_name, component, ice_username_fragment, ice_password); 72 this, content_name, component, ice_username_fragment, ice_password);
64 } 73 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 config.relays[i].port), 114 config.relays[i].port),
106 protocol, 115 protocol,
107 config.relays[i].secure)); 116 config.relays[i].secure));
108 relay_server.credentials = credentials; 117 relay_server.credentials = credentials;
109 port_config->AddRelay(relay_server); 118 port_config->AddRelay(relay_server);
110 } 119 }
111 ConfigReady(port_config); 120 ConfigReady(port_config);
112 } 121 }
113 122
114 } // namespace content 123 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/p2p/port_allocator.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698