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

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

Issue 429253003: Webrtc deps roll. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 4 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"
11 #include "jingle/glue/proxy_resolving_client_socket.h" 11 #include "jingle/glue/proxy_resolving_client_socket.h"
12 #include "net/base/io_buffer.h" 12 #include "net/base/io_buffer.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/base/net_util.h" 14 #include "net/base/net_util.h"
15 #include "net/socket/client_socket_factory.h" 15 #include "net/socket/client_socket_factory.h"
16 #include "net/socket/client_socket_handle.h" 16 #include "net/socket/client_socket_handle.h"
17 #include "net/socket/ssl_client_socket.h" 17 #include "net/socket/ssl_client_socket.h"
18 #include "net/socket/tcp_client_socket.h" 18 #include "net/socket/tcp_client_socket.h"
19 #include "net/url_request/url_request_context.h" 19 #include "net/url_request/url_request_context.h"
20 #include "net/url_request/url_request_context_getter.h" 20 #include "net/url_request/url_request_context_getter.h"
21 #include "third_party/libjingle/source/talk/base/asyncpacketsocket.h" 21 #include "third_party/webrtc/base/asyncpacketsocket.h"
22 22
23 namespace { 23 namespace {
24 24
25 typedef uint16 PacketLength; 25 typedef uint16 PacketLength;
26 const int kPacketHeaderSize = sizeof(PacketLength); 26 const int kPacketHeaderSize = sizeof(PacketLength);
27 const int kReadBufferSize = 4096; 27 const int kReadBufferSize = 4096;
28 const int kPacketLengthOffset = 2; 28 const int kPacketLengthOffset = 2;
29 const int kTurnChannelDataHeaderSize = 4; 29 const int kTurnChannelDataHeaderSize = 4;
30 const int kRecvSocketBufferSize = 128 * 1024; 30 const int kRecvSocketBufferSize = 128 * 1024;
31 const int kSendSocketBufferSize = 128 * 1024; 31 const int kSendSocketBufferSize = 128 * 1024;
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 id_, remote_address_.ip_address, data, base::TimeTicks::Now())); 316 id_, remote_address_.ip_address, data, base::TimeTicks::Now()));
317 317
318 if (dump_incoming_rtp_packet_) 318 if (dump_incoming_rtp_packet_)
319 DumpRtpPacket(&data[0], data.size(), true); 319 DumpRtpPacket(&data[0], data.size(), true);
320 } 320 }
321 321
322 // Note: dscp is not actually used on TCP sockets as this point, 322 // Note: dscp is not actually used on TCP sockets as this point,
323 // but may be honored in the future. 323 // but may be honored in the future.
324 void P2PSocketHostTcpBase::Send(const net::IPEndPoint& to, 324 void P2PSocketHostTcpBase::Send(const net::IPEndPoint& to,
325 const std::vector<char>& data, 325 const std::vector<char>& data,
326 const talk_base::PacketOptions& options, 326 const rtc::PacketOptions& options,
327 uint64 packet_id) { 327 uint64 packet_id) {
328 if (!socket_) { 328 if (!socket_) {
329 // The Send message may be sent after the an OnError message was 329 // The Send message may be sent after the an OnError message was
330 // sent by hasn't been processed the renderer. 330 // sent by hasn't been processed the renderer.
331 return; 331 return;
332 } 332 }
333 333
334 if (!(to == remote_address_.ip_address)) { 334 if (!(to == remote_address_.ip_address)) {
335 // Renderer should use this socket only to send data to |remote_address_|. 335 // Renderer should use this socket only to send data to |remote_address_|.
336 NOTREACHED(); 336 NOTREACHED();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 int consumed = kPacketHeaderSize; 476 int consumed = kPacketHeaderSize;
477 char* cur = input + consumed; 477 char* cur = input + consumed;
478 std::vector<char> data(cur, cur + packet_size); 478 std::vector<char> data(cur, cur + packet_size);
479 OnPacket(data); 479 OnPacket(data);
480 consumed += packet_size; 480 consumed += packet_size;
481 return consumed; 481 return consumed;
482 } 482 }
483 483
484 void P2PSocketHostTcp::DoSend(const net::IPEndPoint& to, 484 void P2PSocketHostTcp::DoSend(const net::IPEndPoint& to,
485 const std::vector<char>& data, 485 const std::vector<char>& data,
486 const talk_base::PacketOptions& options) { 486 const rtc::PacketOptions& options) {
487 int size = kPacketHeaderSize + data.size(); 487 int size = kPacketHeaderSize + data.size();
488 scoped_refptr<net::DrainableIOBuffer> buffer = 488 scoped_refptr<net::DrainableIOBuffer> buffer =
489 new net::DrainableIOBuffer(new net::IOBuffer(size), size); 489 new net::DrainableIOBuffer(new net::IOBuffer(size), size);
490 *reinterpret_cast<uint16*>(buffer->data()) = base::HostToNet16(data.size()); 490 *reinterpret_cast<uint16*>(buffer->data()) = base::HostToNet16(data.size());
491 memcpy(buffer->data() + kPacketHeaderSize, &data[0], data.size()); 491 memcpy(buffer->data() + kPacketHeaderSize, &data[0], data.size());
492 492
493 packet_processing_helpers::ApplyPacketOptions( 493 packet_processing_helpers::ApplyPacketOptions(
494 buffer->data() + kPacketHeaderSize, 494 buffer->data() + kPacketHeaderSize,
495 buffer->BytesRemaining() - kPacketHeaderSize, 495 buffer->BytesRemaining() - kPacketHeaderSize,
496 options, 0); 496 options, 0);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 char* cur = input; 529 char* cur = input;
530 std::vector<char> data(cur, cur + packet_size); 530 std::vector<char> data(cur, cur + packet_size);
531 OnPacket(data); 531 OnPacket(data);
532 consumed += packet_size; 532 consumed += packet_size;
533 consumed += pad_bytes; 533 consumed += pad_bytes;
534 return consumed; 534 return consumed;
535 } 535 }
536 536
537 void P2PSocketHostStunTcp::DoSend(const net::IPEndPoint& to, 537 void P2PSocketHostStunTcp::DoSend(const net::IPEndPoint& to,
538 const std::vector<char>& data, 538 const std::vector<char>& data,
539 const talk_base::PacketOptions& options) { 539 const rtc::PacketOptions& options) {
540 // Each packet is expected to have header (STUN/TURN ChannelData), where 540 // Each packet is expected to have header (STUN/TURN ChannelData), where
541 // header contains message type and and length of message. 541 // header contains message type and and length of message.
542 if (data.size() < kPacketHeaderSize + kPacketLengthOffset) { 542 if (data.size() < kPacketHeaderSize + kPacketLengthOffset) {
543 NOTREACHED(); 543 NOTREACHED();
544 OnError(); 544 OnError();
545 return; 545 return;
546 } 546 }
547 547
548 int pad_bytes; 548 int pad_bytes;
549 size_t expected_len = GetExpectedPacketSize( 549 size_t expected_len = GetExpectedPacketSize(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 } else { 594 } else {
595 packet_size += kTurnChannelDataHeaderSize; 595 packet_size += kTurnChannelDataHeaderSize;
596 // Calculate any padding if present. 596 // Calculate any padding if present.
597 if (packet_size % 4) 597 if (packet_size % 4)
598 *pad_bytes = 4 - packet_size % 4; 598 *pad_bytes = 4 - packet_size % 4;
599 } 599 }
600 return packet_size; 600 return packet_size;
601 } 601 }
602 602
603 } // namespace content 603 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/p2p/socket_host_tcp.h ('k') | content/browser/renderer_host/p2p/socket_host_tcp_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698