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 "ppapi/proxy/tcp_socket_resource_base.h" | 5 #include "ppapi/proxy/tcp_socket_resource_base.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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 PostAbortIfNecessary(&accept_callback_); | 311 PostAbortIfNecessary(&accept_callback_); |
312 read_buffer_ = NULL; | 312 read_buffer_ = NULL; |
313 bytes_to_read_ = -1; | 313 bytes_to_read_ = -1; |
314 server_certificate_ = NULL; | 314 server_certificate_ = NULL; |
315 accepted_tcp_socket_ = NULL; | 315 accepted_tcp_socket_ = NULL; |
316 } | 316 } |
317 | 317 |
318 int32_t TCPSocketResourceBase::SetOptionImpl( | 318 int32_t TCPSocketResourceBase::SetOptionImpl( |
319 PP_TCPSocket_Option name, | 319 PP_TCPSocket_Option name, |
320 const PP_Var& value, | 320 const PP_Var& value, |
| 321 bool check_connect_state, |
321 scoped_refptr<TrackedCallback> callback) { | 322 scoped_refptr<TrackedCallback> callback) { |
322 SocketOptionData option_data; | 323 SocketOptionData option_data; |
323 switch (name) { | 324 switch (name) { |
324 case PP_TCPSOCKET_OPTION_NO_DELAY: { | 325 case PP_TCPSOCKET_OPTION_NO_DELAY: { |
325 if (!state_.IsConnected()) | 326 if (check_connect_state && !state_.IsConnected()) |
326 return PP_ERROR_FAILED; | 327 return PP_ERROR_FAILED; |
327 | 328 |
328 if (value.type != PP_VARTYPE_BOOL) | 329 if (value.type != PP_VARTYPE_BOOL) |
329 return PP_ERROR_BADARGUMENT; | 330 return PP_ERROR_BADARGUMENT; |
330 option_data.SetBool(PP_ToBool(value.value.as_bool)); | 331 option_data.SetBool(PP_ToBool(value.value.as_bool)); |
331 break; | 332 break; |
332 } | 333 } |
333 case PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE: | 334 case PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE: |
334 case PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE: { | 335 case PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE: { |
335 if (!state_.IsConnected()) | 336 if (check_connect_state && !state_.IsConnected()) |
336 return PP_ERROR_FAILED; | 337 return PP_ERROR_FAILED; |
337 | 338 |
338 if (value.type != PP_VARTYPE_INT32) | 339 if (value.type != PP_VARTYPE_INT32) |
339 return PP_ERROR_BADARGUMENT; | 340 return PP_ERROR_BADARGUMENT; |
340 option_data.SetInt32(value.value.as_int); | 341 option_data.SetInt32(value.value.as_int); |
341 break; | 342 break; |
342 } | 343 } |
343 default: { | 344 default: { |
344 NOTREACHED(); | 345 NOTREACHED(); |
345 return PP_ERROR_BADARGUMENT; | 346 return PP_ERROR_BADARGUMENT; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 } | 503 } |
503 | 504 |
504 void TCPSocketResourceBase::RunCallback(scoped_refptr<TrackedCallback> callback, | 505 void TCPSocketResourceBase::RunCallback(scoped_refptr<TrackedCallback> callback, |
505 int32_t pp_result) { | 506 int32_t pp_result) { |
506 callback->Run(ConvertNetworkAPIErrorForCompatibility( | 507 callback->Run(ConvertNetworkAPIErrorForCompatibility( |
507 pp_result, version_ == TCP_SOCKET_VERSION_PRIVATE)); | 508 pp_result, version_ == TCP_SOCKET_VERSION_PRIVATE)); |
508 } | 509 } |
509 | 510 |
510 } // namespace ppapi | 511 } // namespace ppapi |
511 } // namespace proxy | 512 } // namespace proxy |
OLD | NEW |