OLD | NEW |
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/location.h" | 7 #include "base/location.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "base/sys_byteorder.h" | 9 #include "base/sys_byteorder.h" |
10 #include "content/common/p2p_messages.h" | 10 #include "content/common/p2p_messages.h" |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 consumed += packet_size; | 515 consumed += packet_size; |
516 return consumed; | 516 return consumed; |
517 } | 517 } |
518 | 518 |
519 void P2PSocketHostTcp::DoSend(const net::IPEndPoint& to, | 519 void P2PSocketHostTcp::DoSend(const net::IPEndPoint& to, |
520 const std::vector<char>& data, | 520 const std::vector<char>& data, |
521 const rtc::PacketOptions& options) { | 521 const rtc::PacketOptions& options) { |
522 int size = kPacketHeaderSize + data.size(); | 522 int size = kPacketHeaderSize + data.size(); |
523 scoped_refptr<net::DrainableIOBuffer> buffer = | 523 scoped_refptr<net::DrainableIOBuffer> buffer = |
524 new net::DrainableIOBuffer(new net::IOBuffer(size), size); | 524 new net::DrainableIOBuffer(new net::IOBuffer(size), size); |
525 *reinterpret_cast<uint16*>(buffer->data()) = base::HostToNet16(data.size()); | 525 *reinterpret_cast<uint16*>(buffer->data()) = |
| 526 base::HostToNet16(static_cast<uint16>(data.size())); |
526 memcpy(buffer->data() + kPacketHeaderSize, &data[0], data.size()); | 527 memcpy(buffer->data() + kPacketHeaderSize, &data[0], data.size()); |
527 | 528 |
528 packet_processing_helpers::ApplyPacketOptions( | 529 packet_processing_helpers::ApplyPacketOptions( |
529 buffer->data() + kPacketHeaderSize, | 530 buffer->data() + kPacketHeaderSize, |
530 buffer->BytesRemaining() - kPacketHeaderSize, | 531 buffer->BytesRemaining() - kPacketHeaderSize, |
531 options, 0); | 532 options, 0); |
532 | 533 |
533 WriteOrQueue(buffer); | 534 WriteOrQueue(buffer); |
534 } | 535 } |
535 | 536 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 } else { | 630 } else { |
630 packet_size += kTurnChannelDataHeaderSize; | 631 packet_size += kTurnChannelDataHeaderSize; |
631 // Calculate any padding if present. | 632 // Calculate any padding if present. |
632 if (packet_size % 4) | 633 if (packet_size % 4) |
633 *pad_bytes = 4 - packet_size % 4; | 634 *pad_bytes = 4 - packet_size % 4; |
634 } | 635 } |
635 return packet_size; | 636 return packet_size; |
636 } | 637 } |
637 | 638 |
638 } // namespace content | 639 } // namespace content |
OLD | NEW |