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

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

Issue 227473008: make SetReceiveBufferSize and SetSendBufferSize return net error codes (instead of bools) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linux typo Created 6 years, 8 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 if (status != net::OK) { 198 if (status != net::OK) {
199 OnError(); 199 OnError();
200 return; 200 return;
201 } 201 }
202 OnOpen(); 202 OnOpen();
203 } 203 }
204 204
205 void P2PSocketHostTcpBase::OnOpen() { 205 void P2PSocketHostTcpBase::OnOpen() {
206 state_ = STATE_OPEN; 206 state_ = STATE_OPEN;
207 // Setting socket send and receive buffer size. 207 // Setting socket send and receive buffer size.
208 if (!socket_->SetReceiveBufferSize(kRecvSocketBufferSize)) { 208 if (net::OK != socket_->SetReceiveBufferSize(kRecvSocketBufferSize)) {
209 LOG(WARNING) << "Failed to set socket receive buffer size to " 209 LOG(WARNING) << "Failed to set socket receive buffer size to "
210 << kRecvSocketBufferSize; 210 << kRecvSocketBufferSize;
211 } 211 }
212 212
213 if (!socket_->SetSendBufferSize(kSendSocketBufferSize)) { 213 if (net::OK != socket_->SetSendBufferSize(kSendSocketBufferSize)) {
214 LOG(WARNING) << "Failed to set socket send buffer size to " 214 LOG(WARNING) << "Failed to set socket send buffer size to "
215 << kSendSocketBufferSize; 215 << kSendSocketBufferSize;
216 } 216 }
217 217
218 DoSendSocketCreateMsg(); 218 DoSendSocketCreateMsg();
219 DoRead(); 219 DoRead();
220 } 220 }
221 221
222 void P2PSocketHostTcpBase::DoSendSocketCreateMsg() { 222 void P2PSocketHostTcpBase::DoSendSocketCreateMsg() {
223 DCHECK(socket_.get()); 223 DCHECK(socket_.get());
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 if (pos && pos <= read_buffer_->offset()) { 405 if (pos && pos <= read_buffer_->offset()) {
406 memmove(head, head + pos, read_buffer_->offset() - pos); 406 memmove(head, head + pos, read_buffer_->offset() - pos);
407 read_buffer_->set_offset(read_buffer_->offset() - pos); 407 read_buffer_->set_offset(read_buffer_->offset() - pos);
408 } 408 }
409 } 409 }
410 410
411 bool P2PSocketHostTcpBase::SetOption(P2PSocketOption option, int value) { 411 bool P2PSocketHostTcpBase::SetOption(P2PSocketOption option, int value) {
412 DCHECK_EQ(STATE_OPEN, state_); 412 DCHECK_EQ(STATE_OPEN, state_);
413 switch (option) { 413 switch (option) {
414 case P2P_SOCKET_OPT_RCVBUF: 414 case P2P_SOCKET_OPT_RCVBUF:
415 return socket_->SetReceiveBufferSize(value); 415 return socket_->SetReceiveBufferSize(value) == net::OK;
416 case P2P_SOCKET_OPT_SNDBUF: 416 case P2P_SOCKET_OPT_SNDBUF:
417 return socket_->SetSendBufferSize(value); 417 return socket_->SetSendBufferSize(value) == net::OK;
418 case P2P_SOCKET_OPT_DSCP: 418 case P2P_SOCKET_OPT_DSCP:
419 return false; // For TCP sockets DSCP setting is not available. 419 return false; // For TCP sockets DSCP setting is not available.
420 default: 420 default:
421 NOTREACHED(); 421 NOTREACHED();
422 return false; 422 return false;
423 } 423 }
424 } 424 }
425 425
426 P2PSocketHostTcp::P2PSocketHostTcp( 426 P2PSocketHostTcp::P2PSocketHostTcp(
427 IPC::Sender* message_sender, int id, 427 IPC::Sender* message_sender, int id,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 } else { 558 } else {
559 packet_size += kTurnChannelDataHeaderSize; 559 packet_size += kTurnChannelDataHeaderSize;
560 // Calculate any padding if present. 560 // Calculate any padding if present.
561 if (packet_size % 4) 561 if (packet_size % 4)
562 *pad_bytes = 4 - packet_size % 4; 562 *pad_bytes = 4 - packet_size % 4;
563 } 563 }
564 return packet_size; 564 return packet_size;
565 } 565 }
566 566
567 } // namespace content 567 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698