Index: content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc |
diff --git a/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc b/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc |
index 38248f423413940c40078ddfecff6501071ebb09..df51021375efa793cdfc717cc9f714233befb29a 100644 |
--- a/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc |
+++ b/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc |
@@ -63,6 +63,7 @@ PepperTCPSocketMessageFilter::PepperTCPSocketMessageFilter( |
state_(TCPSocketState::INITIAL), |
end_of_file_reached_(false), |
bind_input_addr_(NetAddressPrivateImpl::kInvalidNetAddress), |
+ socket_options_(SOCKET_OPTION_NODELAY), |
address_index_(0), |
socket_(new net::TCPSocket(NULL, net::NetLog::Source())), |
ssl_context_helper_(host->ssl_context_helper()), |
@@ -90,6 +91,7 @@ PepperTCPSocketMessageFilter::PepperTCPSocketMessageFilter( |
state_(TCPSocketState::CONNECTED), |
end_of_file_reached_(false), |
bind_input_addr_(NetAddressPrivateImpl::kInvalidNetAddress), |
+ socket_options_(SOCKET_OPTION_NODELAY), |
address_index_(0), |
socket_(socket.Pass()), |
ssl_context_helper_(host->ssl_context_helper()), |
@@ -456,35 +458,46 @@ int32_t PepperTCPSocketMessageFilter::OnMsgSetOption( |
switch (name) { |
case PP_TCPSOCKET_OPTION_NO_DELAY: { |
- if (state_.state() != TCPSocketState::CONNECTED) |
- return PP_ERROR_FAILED; |
- |
bool boolean_value = false; |
if (!value.GetBool(&boolean_value)) |
return PP_ERROR_BADARGUMENT; |
- return socket_->SetNoDelay(boolean_value) ? PP_OK : PP_ERROR_FAILED; |
+ if (state_.state() == TCPSocketState::CONNECTED) |
+ return socket_->SetNoDelay(boolean_value) ? PP_OK : PP_ERROR_FAILED; |
+ |
+ if (boolean_value) { |
+ socket_options_ |= SOCKET_OPTION_NODELAY; |
+ } else { |
+ socket_options_ &= ~SOCKET_OPTION_NODELAY; |
+ } |
+ return PP_OK; |
} |
case PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE: |
case PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE: { |
- if (state_.state() != TCPSocketState::CONNECTED) |
- return PP_ERROR_FAILED; |
- |
int32_t integer_value = 0; |
if (!value.GetInt32(&integer_value) || integer_value <= 0) |
return PP_ERROR_BADARGUMENT; |
- int net_result = net::ERR_UNEXPECTED; |
if (name == PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE) { |
if (integer_value > TCPSocketResourceBase::kMaxSendBufferSize) |
return PP_ERROR_BADARGUMENT; |
- net_result = socket_->SetSendBufferSize(integer_value); |
+ if (state_.state() == TCPSocketState::CONNECTED) { |
+ return NetErrorToPepperError( |
+ socket_->SetSendBufferSize(integer_value)); |
+ } |
+ socket_options_ |= SOCKET_OPTION_SNDBUF_SIZE; |
+ sndbuf_size_ = integer_value; |
+ return PP_OK; |
} else { |
if (integer_value > TCPSocketResourceBase::kMaxReceiveBufferSize) |
return PP_ERROR_BADARGUMENT; |
- net_result = socket_->SetReceiveBufferSize(integer_value); |
+ if (state_.state() == TCPSocketState::CONNECTED) { |
+ return NetErrorToPepperError( |
+ socket_->SetReceiveBufferSize(integer_value)); |
+ } |
+ socket_options_ |= SOCKET_OPTION_RCVBUF_SIZE; |
+ rcvbuf_size_ = integer_value; |
+ return PP_OK; |
} |
- // TODO(wtc): Add error mapping code. |
- return (net_result == net::OK) ? PP_OK : PP_ERROR_FAILED; |
} |
default: { |
NOTREACHED(); |
@@ -749,6 +762,25 @@ void PepperTCPSocketMessageFilter::OnConnectCompleted( |
} |
socket_->SetDefaultOptionsForClient(); |
+ // NODELAY is set by SetDefaultOptionsForClient(). |
+ if (!(socket_options_ & SOCKET_OPTION_NODELAY)) { |
+ pp_result = NetErrorToPepperError(socket_->SetNoDelay(false)); |
+ if (pp_result != PP_OK) |
+ break; |
+ } |
+ if (socket_options_ & SOCKET_OPTION_RCVBUF_SIZE) { |
+ pp_result = NetErrorToPepperError( |
+ socket_->SetReceiveBufferSize(rcvbuf_size_)); |
+ if (pp_result != PP_OK) |
+ break; |
+ } |
+ if (socket_options_ & SOCKET_OPTION_SNDBUF_SIZE) { |
+ pp_result = NetErrorToPepperError( |
+ socket_->SetSendBufferSize(sndbuf_size_)); |
+ if (pp_result != PP_OK) |
+ break; |
+ } |
+ socket_options_ = SOCKET_OPTION_NODELAY; |
SendConnectReply(context, PP_OK, local_addr, remote_addr); |
state_.CompletePendingTransition(true); |
return; |