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

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

Issue 450463002: Update webrtc&libjingle 6774:6825. (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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 id_, remote_address_.ip_address, data, base::TimeTicks::Now())); 323 id_, remote_address_.ip_address, data, base::TimeTicks::Now()));
324 324
325 if (dump_incoming_rtp_packet_) 325 if (dump_incoming_rtp_packet_)
326 DumpRtpPacket(&data[0], data.size(), true); 326 DumpRtpPacket(&data[0], data.size(), true);
327 } 327 }
328 328
329 // Note: dscp is not actually used on TCP sockets as this point, 329 // Note: dscp is not actually used on TCP sockets as this point,
330 // but may be honored in the future. 330 // but may be honored in the future.
331 void P2PSocketHostTcpBase::Send(const net::IPEndPoint& to, 331 void P2PSocketHostTcpBase::Send(const net::IPEndPoint& to,
332 const std::vector<char>& data, 332 const std::vector<char>& data,
333 const talk_base::PacketOptions& options, 333 const rtc::PacketOptions& options,
334 uint64 packet_id) { 334 uint64 packet_id) {
335 if (!socket_) { 335 if (!socket_) {
336 // The Send message may be sent after the an OnError message was 336 // The Send message may be sent after the an OnError message was
337 // sent by hasn't been processed the renderer. 337 // sent by hasn't been processed the renderer.
338 return; 338 return;
339 } 339 }
340 340
341 if (!(to == remote_address_.ip_address)) { 341 if (!(to == remote_address_.ip_address)) {
342 // Renderer should use this socket only to send data to |remote_address_|. 342 // Renderer should use this socket only to send data to |remote_address_|.
343 NOTREACHED(); 343 NOTREACHED();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 int consumed = kPacketHeaderSize; 483 int consumed = kPacketHeaderSize;
484 char* cur = input + consumed; 484 char* cur = input + consumed;
485 std::vector<char> data(cur, cur + packet_size); 485 std::vector<char> data(cur, cur + packet_size);
486 OnPacket(data); 486 OnPacket(data);
487 consumed += packet_size; 487 consumed += packet_size;
488 return consumed; 488 return consumed;
489 } 489 }
490 490
491 void P2PSocketHostTcp::DoSend(const net::IPEndPoint& to, 491 void P2PSocketHostTcp::DoSend(const net::IPEndPoint& to,
492 const std::vector<char>& data, 492 const std::vector<char>& data,
493 const talk_base::PacketOptions& options) { 493 const rtc::PacketOptions& options) {
494 int size = kPacketHeaderSize + data.size(); 494 int size = kPacketHeaderSize + data.size();
495 scoped_refptr<net::DrainableIOBuffer> buffer = 495 scoped_refptr<net::DrainableIOBuffer> buffer =
496 new net::DrainableIOBuffer(new net::IOBuffer(size), size); 496 new net::DrainableIOBuffer(new net::IOBuffer(size), size);
497 *reinterpret_cast<uint16*>(buffer->data()) = base::HostToNet16(data.size()); 497 *reinterpret_cast<uint16*>(buffer->data()) = base::HostToNet16(data.size());
498 memcpy(buffer->data() + kPacketHeaderSize, &data[0], data.size()); 498 memcpy(buffer->data() + kPacketHeaderSize, &data[0], data.size());
499 499
500 packet_processing_helpers::ApplyPacketOptions( 500 packet_processing_helpers::ApplyPacketOptions(
501 buffer->data() + kPacketHeaderSize, 501 buffer->data() + kPacketHeaderSize,
502 buffer->BytesRemaining() - kPacketHeaderSize, 502 buffer->BytesRemaining() - kPacketHeaderSize,
503 options, 0); 503 options, 0);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 char* cur = input; 536 char* cur = input;
537 std::vector<char> data(cur, cur + packet_size); 537 std::vector<char> data(cur, cur + packet_size);
538 OnPacket(data); 538 OnPacket(data);
539 consumed += packet_size; 539 consumed += packet_size;
540 consumed += pad_bytes; 540 consumed += pad_bytes;
541 return consumed; 541 return consumed;
542 } 542 }
543 543
544 void P2PSocketHostStunTcp::DoSend(const net::IPEndPoint& to, 544 void P2PSocketHostStunTcp::DoSend(const net::IPEndPoint& to,
545 const std::vector<char>& data, 545 const std::vector<char>& data,
546 const talk_base::PacketOptions& options) { 546 const rtc::PacketOptions& options) {
547 // Each packet is expected to have header (STUN/TURN ChannelData), where 547 // Each packet is expected to have header (STUN/TURN ChannelData), where
548 // header contains message type and and length of message. 548 // header contains message type and and length of message.
549 if (data.size() < kPacketHeaderSize + kPacketLengthOffset) { 549 if (data.size() < kPacketHeaderSize + kPacketLengthOffset) {
550 NOTREACHED(); 550 NOTREACHED();
551 OnError(); 551 OnError();
552 return; 552 return;
553 } 553 }
554 554
555 int pad_bytes; 555 int pad_bytes;
556 size_t expected_len = GetExpectedPacketSize( 556 size_t expected_len = GetExpectedPacketSize(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 } else { 601 } else {
602 packet_size += kTurnChannelDataHeaderSize; 602 packet_size += kTurnChannelDataHeaderSize;
603 // Calculate any padding if present. 603 // Calculate any padding if present.
604 if (packet_size % 4) 604 if (packet_size % 4)
605 *pad_bytes = 4 - packet_size % 4; 605 *pad_bytes = 4 - packet_size % 4;
606 } 606 }
607 return packet_size; 607 return packet_size;
608 } 608 }
609 609
610 } // namespace content 610 } // 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