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_udp_socket_message_filter.
h" | 5 #include "content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.
h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 case PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE: | 133 case PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE: |
134 case PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE: { | 134 case PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE: { |
135 if (!socket_.get()) { | 135 if (!socket_.get()) { |
136 // They only take effect after the socket is bound. | 136 // They only take effect after the socket is bound. |
137 return PP_ERROR_FAILED; | 137 return PP_ERROR_FAILED; |
138 } | 138 } |
139 int32_t integer_value = 0; | 139 int32_t integer_value = 0; |
140 if (!value.GetInt32(&integer_value) || integer_value <= 0) | 140 if (!value.GetInt32(&integer_value) || integer_value <= 0) |
141 return PP_ERROR_BADARGUMENT; | 141 return PP_ERROR_BADARGUMENT; |
142 | 142 |
143 bool result = false; | 143 int net_result = net::ERR_UNEXPECTED; |
144 if (name == PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE) { | 144 if (name == PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE) { |
145 if (integer_value > | 145 if (integer_value > |
146 ppapi::proxy::UDPSocketResourceBase::kMaxSendBufferSize) { | 146 ppapi::proxy::UDPSocketResourceBase::kMaxSendBufferSize) { |
147 return PP_ERROR_BADARGUMENT; | 147 return PP_ERROR_BADARGUMENT; |
148 } | 148 } |
149 result = socket_->SetSendBufferSize(integer_value); | 149 net_result = socket_->SetSendBufferSize(integer_value); |
150 } else { | 150 } else { |
151 if (integer_value > | 151 if (integer_value > |
152 ppapi::proxy::UDPSocketResourceBase::kMaxReceiveBufferSize) { | 152 ppapi::proxy::UDPSocketResourceBase::kMaxReceiveBufferSize) { |
153 return PP_ERROR_BADARGUMENT; | 153 return PP_ERROR_BADARGUMENT; |
154 } | 154 } |
155 result = socket_->SetReceiveBufferSize(integer_value); | 155 net_result = socket_->SetReceiveBufferSize(integer_value); |
156 } | 156 } |
157 return result ? PP_OK : PP_ERROR_FAILED; | 157 // TODO(wtc): Add error mapping code. |
| 158 return (net_result == net::OK) ? PP_OK : PP_ERROR_FAILED; |
158 } | 159 } |
159 default: { | 160 default: { |
160 NOTREACHED(); | 161 NOTREACHED(); |
161 return PP_ERROR_BADARGUMENT; | 162 return PP_ERROR_BADARGUMENT; |
162 } | 163 } |
163 } | 164 } |
164 } | 165 } |
165 | 166 |
166 int32_t PepperUDPSocketMessageFilter::OnMsgBind( | 167 int32_t PepperUDPSocketMessageFilter::OnMsgBind( |
167 const ppapi::host::HostMessageContext* context, | 168 const ppapi::host::HostMessageContext* context, |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 NetAddressPrivateImpl::kInvalidNetAddress); | 453 NetAddressPrivateImpl::kInvalidNetAddress); |
453 } | 454 } |
454 | 455 |
455 void PepperUDPSocketMessageFilter::SendSendToError( | 456 void PepperUDPSocketMessageFilter::SendSendToError( |
456 const ppapi::host::ReplyMessageContext& context, | 457 const ppapi::host::ReplyMessageContext& context, |
457 int32_t result) { | 458 int32_t result) { |
458 SendSendToReply(context, result, 0); | 459 SendSendToReply(context, result, 0); |
459 } | 460 } |
460 | 461 |
461 } // namespace content | 462 } // namespace content |
OLD | NEW |