| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_message_filter.
h" | 5 #include "content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.
h" |
| 6 | 6 |
| 7 #include <cstring> | 7 #include <cstring> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 } | 448 } |
| 449 case PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE: | 449 case PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE: |
| 450 case PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE: { | 450 case PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE: { |
| 451 if (state_.state() != TCPSocketState::CONNECTED) | 451 if (state_.state() != TCPSocketState::CONNECTED) |
| 452 return PP_ERROR_FAILED; | 452 return PP_ERROR_FAILED; |
| 453 | 453 |
| 454 int32_t integer_value = 0; | 454 int32_t integer_value = 0; |
| 455 if (!value.GetInt32(&integer_value) || integer_value <= 0) | 455 if (!value.GetInt32(&integer_value) || integer_value <= 0) |
| 456 return PP_ERROR_BADARGUMENT; | 456 return PP_ERROR_BADARGUMENT; |
| 457 | 457 |
| 458 bool result = false; | 458 int net_result = net::ERR_UNEXPECTED; |
| 459 if (name == PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE) { | 459 if (name == PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE) { |
| 460 if (integer_value > TCPSocketResourceBase::kMaxSendBufferSize) | 460 if (integer_value > TCPSocketResourceBase::kMaxSendBufferSize) |
| 461 return PP_ERROR_BADARGUMENT; | 461 return PP_ERROR_BADARGUMENT; |
| 462 result = socket_->SetSendBufferSize(integer_value); | 462 net_result = socket_->SetSendBufferSize(integer_value); |
| 463 } else { | 463 } else { |
| 464 if (integer_value > TCPSocketResourceBase::kMaxReceiveBufferSize) | 464 if (integer_value > TCPSocketResourceBase::kMaxReceiveBufferSize) |
| 465 return PP_ERROR_BADARGUMENT; | 465 return PP_ERROR_BADARGUMENT; |
| 466 result = socket_->SetReceiveBufferSize(integer_value); | 466 net_result = socket_->SetReceiveBufferSize(integer_value); |
| 467 } | 467 } |
| 468 return result ? PP_OK : PP_ERROR_FAILED; | 468 // TODO(wtc): Add error mapping code. |
| 469 return (net_result == net::OK) ? PP_OK : PP_ERROR_FAILED; |
| 469 } | 470 } |
| 470 default: { | 471 default: { |
| 471 NOTREACHED(); | 472 NOTREACHED(); |
| 472 return PP_ERROR_BADARGUMENT; | 473 return PP_ERROR_BADARGUMENT; |
| 473 } | 474 } |
| 474 } | 475 } |
| 475 } | 476 } |
| 476 | 477 |
| 477 void PepperTCPSocketMessageFilter::DoBind( | 478 void PepperTCPSocketMessageFilter::DoBind( |
| 478 const ppapi::host::ReplyMessageContext& context, | 479 const ppapi::host::ReplyMessageContext& context, |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 | 971 |
| 971 void PepperTCPSocketMessageFilter::SendAcceptError( | 972 void PepperTCPSocketMessageFilter::SendAcceptError( |
| 972 const ppapi::host::ReplyMessageContext& context, | 973 const ppapi::host::ReplyMessageContext& context, |
| 973 int32_t pp_error) { | 974 int32_t pp_error) { |
| 974 SendAcceptReply(context, pp_error, 0, | 975 SendAcceptReply(context, pp_error, 0, |
| 975 NetAddressPrivateImpl::kInvalidNetAddress, | 976 NetAddressPrivateImpl::kInvalidNetAddress, |
| 976 NetAddressPrivateImpl::kInvalidNetAddress); | 977 NetAddressPrivateImpl::kInvalidNetAddress); |
| 977 } | 978 } |
| 978 | 979 |
| 979 } // namespace content | 980 } // namespace content |
| OLD | NEW |