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

Side by Side Diff: content/browser/renderer_host/p2p/socket_dispatcher_host.cc

Issue 264793017: Implements RTP header dumping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
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/browser/renderer_host/p2p/socket_dispatcher_host.h" 5 #include "content/browser/renderer_host/p2p/socket_dispatcher_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "content/browser/renderer_host/p2p/socket_host.h" 9 #include "content/browser/renderer_host/p2p/socket_host.h"
10 #include "content/common/p2p_messages.h" 10 #include "content/common/p2p_messages.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 net::AddressList addresses_; 88 net::AddressList addresses_;
89 89
90 std::string host_name_; 90 std::string host_name_;
91 net::SingleRequestHostResolver resolver_; 91 net::SingleRequestHostResolver resolver_;
92 92
93 DoneCallback done_callback_; 93 DoneCallback done_callback_;
94 }; 94 };
95 95
96 P2PSocketDispatcherHost::P2PSocketDispatcherHost( 96 P2PSocketDispatcherHost::P2PSocketDispatcherHost(
97 content::ResourceContext* resource_context, 97 content::ResourceContext* resource_context,
98 net::URLRequestContextGetter* url_context) 98 net::URLRequestContextGetter* url_context,
99 int render_process_host_id)
99 : BrowserMessageFilter(P2PMsgStart), 100 : BrowserMessageFilter(P2PMsgStart),
100 resource_context_(resource_context), 101 resource_context_(resource_context),
101 url_context_(url_context), 102 url_context_(url_context),
102 monitoring_networks_(false) { 103 render_process_host_id_(render_process_host_id),
104 monitoring_networks_(false),
105 dump_incoming_rtp_packet_(false),
106 dump_outgoing_rtp_packet_(false) {
103 } 107 }
104 108
105 void P2PSocketDispatcherHost::OnChannelClosing() { 109 void P2PSocketDispatcherHost::OnChannelClosing() {
106 // Since the IPC channel is gone, close pending connections. 110 // Since the IPC channel is gone, close pending connections.
107 STLDeleteContainerPairSecondPointers(sockets_.begin(), sockets_.end()); 111 STLDeleteContainerPairSecondPointers(sockets_.begin(), sockets_.end());
108 sockets_.clear(); 112 sockets_.clear();
109 113
110 STLDeleteContainerPointers(dns_requests_.begin(), dns_requests_.end()); 114 STLDeleteContainerPointers(dns_requests_.begin(), dns_requests_.end());
111 dns_requests_.clear(); 115 dns_requests_.clear();
112 116
(...skipping 27 matching lines...) Expand all
140 return handled; 144 return handled;
141 } 145 }
142 146
143 void P2PSocketDispatcherHost::OnIPAddressChanged() { 147 void P2PSocketDispatcherHost::OnIPAddressChanged() {
144 // Notify the renderer about changes to list of network interfaces. 148 // Notify the renderer about changes to list of network interfaces.
145 BrowserThread::PostTask( 149 BrowserThread::PostTask(
146 BrowserThread::FILE, FROM_HERE, base::Bind( 150 BrowserThread::FILE, FROM_HERE, base::Bind(
147 &P2PSocketDispatcherHost::DoGetNetworkList, this)); 151 &P2PSocketDispatcherHost::DoGetNetworkList, this));
148 } 152 }
149 153
154 void P2PSocketDispatcherHost::StartRtpDump(bool incoming, bool outgoing) {
155 if (dump_incoming_rtp_packet_ != incoming ||
Mallinath (Gone from Chromium) 2014/05/14 00:57:01 Do we really need if condition here? Let socket de
jiayl 2014/05/14 15:54:51 The check is to avoid unnecessary work if no chang
156 dump_outgoing_rtp_packet_ != outgoing) {
157 dump_incoming_rtp_packet_ = incoming;
158 dump_outgoing_rtp_packet_ = outgoing;
159
160 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it)
161 it->second->StartRtpDump(incoming, outgoing);
162 }
163 }
164
165 void P2PSocketDispatcherHost::StopRtpDump(bool incoming, bool outgoing) {
166 if (dump_incoming_rtp_packet_ == incoming ||
Mallinath (Gone from Chromium) 2014/05/14 00:57:01 same as above.
167 dump_outgoing_rtp_packet_ == outgoing) {
168 dump_incoming_rtp_packet_ = !incoming;
169 dump_outgoing_rtp_packet_ = !outgoing;
170
171 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it)
172 it->second->StopRtpDump(incoming, outgoing);
173 }
174 }
175
150 P2PSocketDispatcherHost::~P2PSocketDispatcherHost() { 176 P2PSocketDispatcherHost::~P2PSocketDispatcherHost() {
151 DCHECK(sockets_.empty()); 177 DCHECK(sockets_.empty());
152 DCHECK(dns_requests_.empty()); 178 DCHECK(dns_requests_.empty());
153 179
154 if (monitoring_networks_) 180 if (monitoring_networks_)
155 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); 181 net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
156 } 182 }
157 183
158 P2PSocketHost* P2PSocketDispatcherHost::LookupSocket(int socket_id) { 184 P2PSocketHost* P2PSocketDispatcherHost::LookupSocket(int socket_id) {
159 SocketsMap::iterator it = sockets_.find(socket_id); 185 SocketsMap::iterator it = sockets_.find(socket_id);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 void P2PSocketDispatcherHost::OnCreateSocket( 219 void P2PSocketDispatcherHost::OnCreateSocket(
194 P2PSocketType type, int socket_id, 220 P2PSocketType type, int socket_id,
195 const net::IPEndPoint& local_address, 221 const net::IPEndPoint& local_address,
196 const P2PHostAndIPEndPoint& remote_address) { 222 const P2PHostAndIPEndPoint& remote_address) {
197 if (LookupSocket(socket_id)) { 223 if (LookupSocket(socket_id)) {
198 LOG(ERROR) << "Received P2PHostMsg_CreateSocket for socket " 224 LOG(ERROR) << "Received P2PHostMsg_CreateSocket for socket "
199 "that already exists."; 225 "that already exists.";
200 return; 226 return;
201 } 227 }
202 228
203 scoped_ptr<P2PSocketHost> socket(P2PSocketHost::Create( 229 scoped_ptr<P2PSocketHost> socket(
204 this, socket_id, type, url_context_.get(), &throttler_)); 230 P2PSocketHost::Create(this,
231 socket_id,
232 render_process_host_id_,
233 type,
234 url_context_.get(),
235 &throttler_));
205 236
206 if (!socket) { 237 if (!socket) {
207 Send(new P2PMsg_OnError(socket_id)); 238 Send(new P2PMsg_OnError(socket_id));
208 return; 239 return;
209 } 240 }
210 241
211 if (socket->Init(local_address, remote_address)) { 242 if (socket->Init(local_address, remote_address)) {
212 sockets_[socket_id] = socket.release(); 243 sockets_[socket_id] = socket.release();
244
245 if (dump_incoming_rtp_packet_ || dump_outgoing_rtp_packet_) {
246 sockets_[socket_id]->StartRtpDump(dump_incoming_rtp_packet_,
247 dump_outgoing_rtp_packet_);
248 }
213 } 249 }
214 } 250 }
215 251
216 void P2PSocketDispatcherHost::OnAcceptIncomingTcpConnection( 252 void P2PSocketDispatcherHost::OnAcceptIncomingTcpConnection(
217 int listen_socket_id, const net::IPEndPoint& remote_address, 253 int listen_socket_id, const net::IPEndPoint& remote_address,
218 int connected_socket_id) { 254 int connected_socket_id) {
219 P2PSocketHost* socket = LookupSocket(listen_socket_id); 255 P2PSocketHost* socket = LookupSocket(listen_socket_id);
220 if (!socket) { 256 if (!socket) {
221 LOG(ERROR) << "Received P2PHostMsg_AcceptIncomingTcpConnection " 257 LOG(ERROR) << "Received P2PHostMsg_AcceptIncomingTcpConnection "
222 "for invalid socket_id."; 258 "for invalid socket_id.";
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 void P2PSocketDispatcherHost::OnAddressResolved( 327 void P2PSocketDispatcherHost::OnAddressResolved(
292 DnsRequest* request, 328 DnsRequest* request,
293 const net::IPAddressList& addresses) { 329 const net::IPAddressList& addresses) {
294 Send(new P2PMsg_GetHostAddressResult(request->request_id(), addresses)); 330 Send(new P2PMsg_GetHostAddressResult(request->request_id(), addresses));
295 331
296 dns_requests_.erase(request); 332 dns_requests_.erase(request);
297 delete request; 333 delete request;
298 } 334 }
299 335
300 } // namespace content 336 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698