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

Side by Side Diff: content/browser/renderer_host/pepper/pepper_tcp_socket.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/pepper/pepper_tcp_socket.h" 5 #include "content/browser/renderer_host/pepper/pepper_tcp_socket.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 return; 247 return;
248 } 248 }
249 case PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE: 249 case PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE:
250 case PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE: { 250 case PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE: {
251 int32_t integer_value = 0; 251 int32_t integer_value = 0;
252 if (!value.GetInt32(&integer_value) || integer_value <= 0) { 252 if (!value.GetInt32(&integer_value) || integer_value <= 0) {
253 SendSetOptionACK(PP_ERROR_BADARGUMENT); 253 SendSetOptionACK(PP_ERROR_BADARGUMENT);
254 return; 254 return;
255 } 255 }
256 256
257 bool result = false; 257 int net_result = net::OK;
258 if (name == PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE) { 258 if (name == PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE) {
259 if (integer_value > ppapi::TCPSocketShared::kMaxSendBufferSize) { 259 if (integer_value > ppapi::TCPSocketShared::kMaxSendBufferSize) {
260 SendSetOptionACK(PP_ERROR_BADARGUMENT); 260 SendSetOptionACK(PP_ERROR_BADARGUMENT);
261 return; 261 return;
262 } 262 }
263 result = tcp_socket->SetSendBufferSize(integer_value); 263 net_result = tcp_socket->SetSendBufferSize(integer_value);
264 } else { 264 } else {
265 if (integer_value > ppapi::TCPSocketShared::kMaxReceiveBufferSize) { 265 if (integer_value > ppapi::TCPSocketShared::kMaxReceiveBufferSize) {
266 SendSetOptionACK(PP_ERROR_BADARGUMENT); 266 SendSetOptionACK(PP_ERROR_BADARGUMENT);
267 return; 267 return;
268 } 268 }
269 result = tcp_socket->SetReceiveBufferSize(integer_value); 269 net_result = tcp_socket->SetReceiveBufferSize(integer_value);
270 } 270 }
271 SendSetOptionACK(result ? PP_OK : PP_ERROR_FAILED); 271 // TODO(wtc): Add error mapping.
272 SendSetOptionACK((net_result == net::OK) ? PP_OK : PP_ERROR_FAILED);
272 return; 273 return;
273 } 274 }
274 default: { 275 default: {
275 NOTREACHED(); 276 NOTREACHED();
276 SendSetOptionACK(PP_ERROR_BADARGUMENT); 277 SendSetOptionACK(PP_ERROR_BADARGUMENT);
277 return; 278 return;
278 } 279 }
279 } 280 }
280 } 281 }
281 282
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 519
519 int net_result = socket_->Write( 520 int net_result = socket_->Write(
520 write_buffer_.get(), 521 write_buffer_.get(),
521 write_buffer_->BytesRemaining(), 522 write_buffer_->BytesRemaining(),
522 base::Bind(&PepperTCPSocket::OnWriteCompleted, base::Unretained(this))); 523 base::Bind(&PepperTCPSocket::OnWriteCompleted, base::Unretained(this)));
523 if (net_result != net::ERR_IO_PENDING) 524 if (net_result != net::ERR_IO_PENDING)
524 OnWriteCompleted(net_result); 525 OnWriteCompleted(net_result);
525 } 526 }
526 527
527 } // namespace content 528 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698