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

Side by Side Diff: trunk/src/content/browser/renderer_host/p2p/socket_host_tcp.cc

Issue 307063003: Revert 273745 "Implements RTP header dumping." due to memory leak (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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_host_tcp.h" 5 #include "content/browser/renderer_host/p2p/socket_host_tcp.h"
6 6
7 #include "base/sys_byteorder.h" 7 #include "base/sys_byteorder.h"
8 #include "content/common/p2p_messages.h" 8 #include "content/common/p2p_messages.h"
9 #include "ipc/ipc_sender.h" 9 #include "ipc/ipc_sender.h"
10 #include "jingle/glue/fake_ssl_client_socket.h" 10 #include "jingle/glue/fake_ssl_client_socket.h"
(...skipping 27 matching lines...) Expand all
38 bool IsPseudoTlsClientSocket(content::P2PSocketType type) { 38 bool IsPseudoTlsClientSocket(content::P2PSocketType type) {
39 return (type == content::P2P_SOCKET_SSLTCP_CLIENT || 39 return (type == content::P2P_SOCKET_SSLTCP_CLIENT ||
40 type == content::P2P_SOCKET_STUN_SSLTCP_CLIENT); 40 type == content::P2P_SOCKET_STUN_SSLTCP_CLIENT);
41 } 41 }
42 42
43 } // namespace 43 } // namespace
44 44
45 namespace content { 45 namespace content {
46 46
47 P2PSocketHostTcpBase::P2PSocketHostTcpBase( 47 P2PSocketHostTcpBase::P2PSocketHostTcpBase(
48 IPC::Sender* message_sender, 48 IPC::Sender* message_sender, int id,
49 int socket_id, 49 P2PSocketType type, net::URLRequestContextGetter* url_context)
50 P2PSocketType type, 50 : P2PSocketHost(message_sender, id),
51 net::URLRequestContextGetter* url_context)
52 : P2PSocketHost(message_sender, socket_id),
53 write_pending_(false), 51 write_pending_(false),
54 connected_(false), 52 connected_(false),
55 type_(type), 53 type_(type),
56 url_context_(url_context) { 54 url_context_(url_context) {
57 } 55 }
58 56
59 P2PSocketHostTcpBase::~P2PSocketHostTcpBase() { 57 P2PSocketHostTcpBase::~P2PSocketHostTcpBase() {
60 if (state_ == STATE_OPEN) { 58 if (state_ == STATE_OPEN) {
61 DCHECK(socket_.get()); 59 DCHECK(socket_.get());
62 socket_.reset(); 60 socket_.reset();
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 << remote_address_.ip_address.ToString() 280 << remote_address_.ip_address.ToString()
283 << " before STUN binding is finished. " 281 << " before STUN binding is finished. "
284 << "Terminating connection."; 282 << "Terminating connection.";
285 OnError(); 283 OnError();
286 return; 284 return;
287 } 285 }
288 } 286 }
289 287
290 message_sender_->Send(new P2PMsg_OnDataReceived( 288 message_sender_->Send(new P2PMsg_OnDataReceived(
291 id_, remote_address_.ip_address, data, base::TimeTicks::Now())); 289 id_, remote_address_.ip_address, data, base::TimeTicks::Now()));
292
293 if (dump_incoming_rtp_packet_)
294 DumpRtpPacket(&data[0], data.size(), true);
295 } 290 }
296 291
297 // Note: dscp is not actually used on TCP sockets as this point, 292 // Note: dscp is not actually used on TCP sockets as this point,
298 // but may be honored in the future. 293 // but may be honored in the future.
299 void P2PSocketHostTcpBase::Send(const net::IPEndPoint& to, 294 void P2PSocketHostTcpBase::Send(const net::IPEndPoint& to,
300 const std::vector<char>& data, 295 const std::vector<char>& data,
301 const talk_base::PacketOptions& options, 296 const talk_base::PacketOptions& options,
302 uint64 packet_id) { 297 uint64 packet_id) {
303 if (!socket_) { 298 if (!socket_) {
304 // The Send message may be sent after the an OnError message was 299 // The Send message may be sent after the an OnError message was
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 case P2P_SOCKET_OPT_SNDBUF: 416 case P2P_SOCKET_OPT_SNDBUF:
422 return socket_->SetSendBufferSize(value) == net::OK; 417 return socket_->SetSendBufferSize(value) == net::OK;
423 case P2P_SOCKET_OPT_DSCP: 418 case P2P_SOCKET_OPT_DSCP:
424 return false; // For TCP sockets DSCP setting is not available. 419 return false; // For TCP sockets DSCP setting is not available.
425 default: 420 default:
426 NOTREACHED(); 421 NOTREACHED();
427 return false; 422 return false;
428 } 423 }
429 } 424 }
430 425
431 P2PSocketHostTcp::P2PSocketHostTcp(IPC::Sender* message_sender, 426 P2PSocketHostTcp::P2PSocketHostTcp(
432 int socket_id, 427 IPC::Sender* message_sender, int id,
433 P2PSocketType type, 428 P2PSocketType type, net::URLRequestContextGetter* url_context)
434 net::URLRequestContextGetter* url_context) 429 : P2PSocketHostTcpBase(message_sender, id, type, url_context) {
435 : P2PSocketHostTcpBase(message_sender, socket_id, type, url_context) {
436 DCHECK(type == P2P_SOCKET_TCP_CLIENT || 430 DCHECK(type == P2P_SOCKET_TCP_CLIENT ||
437 type == P2P_SOCKET_SSLTCP_CLIENT || 431 type == P2P_SOCKET_SSLTCP_CLIENT ||
438 type == P2P_SOCKET_TLS_CLIENT); 432 type == P2P_SOCKET_TLS_CLIENT);
439 } 433 }
440 434
441 P2PSocketHostTcp::~P2PSocketHostTcp() { 435 P2PSocketHostTcp::~P2PSocketHostTcp() {
442 } 436 }
443 437
444 int P2PSocketHostTcp::ProcessInput(char* input, int input_len) { 438 int P2PSocketHostTcp::ProcessInput(char* input, int input_len) {
445 if (input_len < kPacketHeaderSize) 439 if (input_len < kPacketHeaderSize)
(...skipping 22 matching lines...) Expand all
468 packet_processing_helpers::ApplyPacketOptions( 462 packet_processing_helpers::ApplyPacketOptions(
469 buffer->data() + kPacketHeaderSize, 463 buffer->data() + kPacketHeaderSize,
470 buffer->BytesRemaining() - kPacketHeaderSize, 464 buffer->BytesRemaining() - kPacketHeaderSize,
471 options, 0); 465 options, 0);
472 466
473 WriteOrQueue(buffer); 467 WriteOrQueue(buffer);
474 } 468 }
475 469
476 // P2PSocketHostStunTcp 470 // P2PSocketHostStunTcp
477 P2PSocketHostStunTcp::P2PSocketHostStunTcp( 471 P2PSocketHostStunTcp::P2PSocketHostStunTcp(
478 IPC::Sender* message_sender, 472 IPC::Sender* message_sender, int id,
479 int socket_id, 473 P2PSocketType type, net::URLRequestContextGetter* url_context)
480 P2PSocketType type, 474 : P2PSocketHostTcpBase(message_sender, id, type, url_context) {
481 net::URLRequestContextGetter* url_context)
482 : P2PSocketHostTcpBase(message_sender, socket_id, type, url_context) {
483 DCHECK(type == P2P_SOCKET_STUN_TCP_CLIENT || 475 DCHECK(type == P2P_SOCKET_STUN_TCP_CLIENT ||
484 type == P2P_SOCKET_STUN_SSLTCP_CLIENT || 476 type == P2P_SOCKET_STUN_SSLTCP_CLIENT ||
485 type == P2P_SOCKET_STUN_TLS_CLIENT); 477 type == P2P_SOCKET_STUN_TLS_CLIENT);
486 } 478 }
487 479
488 P2PSocketHostStunTcp::~P2PSocketHostStunTcp() { 480 P2PSocketHostStunTcp::~P2PSocketHostStunTcp() {
489 } 481 }
490 482
491 int P2PSocketHostStunTcp::ProcessInput(char* input, int input_len) { 483 int P2PSocketHostStunTcp::ProcessInput(char* input, int input_len) {
492 if (input_len < kPacketHeaderSize + kPacketLengthOffset) 484 if (input_len < kPacketHeaderSize + kPacketLengthOffset)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 532
541 packet_processing_helpers::ApplyPacketOptions( 533 packet_processing_helpers::ApplyPacketOptions(
542 buffer->data(), data.size(), options, 0); 534 buffer->data(), data.size(), options, 0);
543 535
544 if (pad_bytes) { 536 if (pad_bytes) {
545 char padding[4] = {0}; 537 char padding[4] = {0};
546 DCHECK_LE(pad_bytes, 4); 538 DCHECK_LE(pad_bytes, 4);
547 memcpy(buffer->data() + data.size(), padding, pad_bytes); 539 memcpy(buffer->data() + data.size(), padding, pad_bytes);
548 } 540 }
549 WriteOrQueue(buffer); 541 WriteOrQueue(buffer);
550
551 if (dump_outgoing_rtp_packet_)
552 DumpRtpPacket(buffer->data(), data.size(), false);
553 } 542 }
554 543
555 int P2PSocketHostStunTcp::GetExpectedPacketSize( 544 int P2PSocketHostStunTcp::GetExpectedPacketSize(
556 const char* data, int len, int* pad_bytes) { 545 const char* data, int len, int* pad_bytes) {
557 DCHECK_LE(kTurnChannelDataHeaderSize, len); 546 DCHECK_LE(kTurnChannelDataHeaderSize, len);
558 // Both stun and turn had length at offset 2. 547 // Both stun and turn had length at offset 2.
559 int packet_size = base::NetToHost16(*reinterpret_cast<const uint16*>( 548 int packet_size = base::NetToHost16(*reinterpret_cast<const uint16*>(
560 data + kPacketLengthOffset)); 549 data + kPacketLengthOffset));
561 550
562 // Get packet type (STUN or TURN). 551 // Get packet type (STUN or TURN).
563 uint16 msg_type = base::NetToHost16(*reinterpret_cast<const uint16*>(data)); 552 uint16 msg_type = base::NetToHost16(*reinterpret_cast<const uint16*>(data));
564 553
565 *pad_bytes = 0; 554 *pad_bytes = 0;
566 // Add heder length to packet length. 555 // Add heder length to packet length.
567 if ((msg_type & 0xC000) == 0) { 556 if ((msg_type & 0xC000) == 0) {
568 packet_size += kStunHeaderSize; 557 packet_size += kStunHeaderSize;
569 } else { 558 } else {
570 packet_size += kTurnChannelDataHeaderSize; 559 packet_size += kTurnChannelDataHeaderSize;
571 // Calculate any padding if present. 560 // Calculate any padding if present.
572 if (packet_size % 4) 561 if (packet_size % 4)
573 *pad_bytes = 4 - packet_size % 4; 562 *pad_bytes = 4 - packet_size % 4;
574 } 563 }
575 return packet_size; 564 return packet_size;
576 } 565 }
577 566
578 } // namespace content 567 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698