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 int net_result = net::OK; | 143 bool result = false; |
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 net_result = socket_->SetSendBufferSize(integer_value); | 149 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 net_result = socket_->SetReceiveBufferSize(integer_value); | 155 result = socket_->SetReceiveBufferSize(integer_value); |
156 } | 156 } |
157 // TODO(wtc): Add error mapping code. | 157 return result ? PP_OK : PP_ERROR_FAILED; |
158 return (net_result == net::OK) ? PP_OK : PP_ERROR_FAILED; | |
159 } | 158 } |
160 default: { | 159 default: { |
161 NOTREACHED(); | 160 NOTREACHED(); |
162 return PP_ERROR_BADARGUMENT; | 161 return PP_ERROR_BADARGUMENT; |
163 } | 162 } |
164 } | 163 } |
165 } | 164 } |
166 | 165 |
167 int32_t PepperUDPSocketMessageFilter::OnMsgBind( | 166 int32_t PepperUDPSocketMessageFilter::OnMsgBind( |
168 const ppapi::host::HostMessageContext* context, | 167 const ppapi::host::HostMessageContext* context, |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 NetAddressPrivateImpl::kInvalidNetAddress); | 452 NetAddressPrivateImpl::kInvalidNetAddress); |
454 } | 453 } |
455 | 454 |
456 void PepperUDPSocketMessageFilter::SendSendToError( | 455 void PepperUDPSocketMessageFilter::SendSendToError( |
457 const ppapi::host::ReplyMessageContext& context, | 456 const ppapi::host::ReplyMessageContext& context, |
458 int32_t result) { | 457 int32_t result) { |
459 SendSendToReply(context, result, 0); | 458 SendSendToReply(context, result, 0); |
460 } | 459 } |
461 | 460 |
462 } // namespace content | 461 } // namespace content |
OLD | NEW |