| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 } | 477 } |
| 478 // We've consumed all complete packets from the buffer; now move any remaining | 478 // We've consumed all complete packets from the buffer; now move any remaining |
| 479 // bytes to the head of the buffer and set offset to reflect this. | 479 // bytes to the head of the buffer and set offset to reflect this. |
| 480 if (pos && pos <= read_buffer_->offset()) { | 480 if (pos && pos <= read_buffer_->offset()) { |
| 481 memmove(head, head + pos, read_buffer_->offset() - pos); | 481 memmove(head, head + pos, read_buffer_->offset() - pos); |
| 482 read_buffer_->set_offset(read_buffer_->offset() - pos); | 482 read_buffer_->set_offset(read_buffer_->offset() - pos); |
| 483 } | 483 } |
| 484 } | 484 } |
| 485 | 485 |
| 486 bool P2PSocketHostTcpBase::SetOption(P2PSocketOption option, int value) { | 486 bool P2PSocketHostTcpBase::SetOption(P2PSocketOption option, int value) { |
| 487 DCHECK_EQ(STATE_OPEN, state_); | 487 if (state_ != STATE_OPEN) { |
| 488 DCHECK_EQ(state_, STATE_ERROR); |
| 489 return false; |
| 490 } |
| 491 |
| 488 switch (option) { | 492 switch (option) { |
| 489 case P2P_SOCKET_OPT_RCVBUF: | 493 case P2P_SOCKET_OPT_RCVBUF: |
| 490 return socket_->SetReceiveBufferSize(value) == net::OK; | 494 return socket_->SetReceiveBufferSize(value) == net::OK; |
| 491 case P2P_SOCKET_OPT_SNDBUF: | 495 case P2P_SOCKET_OPT_SNDBUF: |
| 492 return socket_->SetSendBufferSize(value) == net::OK; | 496 return socket_->SetSendBufferSize(value) == net::OK; |
| 493 case P2P_SOCKET_OPT_DSCP: | 497 case P2P_SOCKET_OPT_DSCP: |
| 494 return false; // For TCP sockets DSCP setting is not available. | 498 return false; // For TCP sockets DSCP setting is not available. |
| 495 default: | 499 default: |
| 496 NOTREACHED(); | 500 NOTREACHED(); |
| 497 return false; | 501 return false; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 } else { | 646 } else { |
| 643 packet_size += kTurnChannelDataHeaderSize; | 647 packet_size += kTurnChannelDataHeaderSize; |
| 644 // Calculate any padding if present. | 648 // Calculate any padding if present. |
| 645 if (packet_size % 4) | 649 if (packet_size % 4) |
| 646 *pad_bytes = 4 - packet_size % 4; | 650 *pad_bytes = 4 - packet_size % 4; |
| 647 } | 651 } |
| 648 return packet_size; | 652 return packet_size; |
| 649 } | 653 } |
| 650 | 654 |
| 651 } // namespace content | 655 } // namespace content |
| OLD | NEW |