Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: ppapi/proxy/udp_socket_resource_base.cc

Issue 690903002: Remove timing limitation of SetOption invocation for PPAPI sockets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/udp_socket_resource_base.h" 5 #include "ppapi/proxy/udp_socket_resource_base.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 PP_UDPSocket_Option name, 62 PP_UDPSocket_Option name,
63 const PP_Var& value, 63 const PP_Var& value,
64 scoped_refptr<TrackedCallback> callback) { 64 scoped_refptr<TrackedCallback> callback) {
65 if (closed_) 65 if (closed_)
66 return PP_ERROR_FAILED; 66 return PP_ERROR_FAILED;
67 67
68 SocketOptionData option_data; 68 SocketOptionData option_data;
69 switch (name) { 69 switch (name) {
70 case PP_UDPSOCKET_OPTION_ADDRESS_REUSE: 70 case PP_UDPSOCKET_OPTION_ADDRESS_REUSE:
71 case PP_UDPSOCKET_OPTION_BROADCAST: { 71 case PP_UDPSOCKET_OPTION_BROADCAST: {
72 if (bound_)
73 return PP_ERROR_FAILED;
74 if (value.type != PP_VARTYPE_BOOL) 72 if (value.type != PP_VARTYPE_BOOL)
75 return PP_ERROR_BADARGUMENT; 73 return PP_ERROR_BADARGUMENT;
76 option_data.SetBool(PP_ToBool(value.value.as_bool)); 74 option_data.SetBool(PP_ToBool(value.value.as_bool));
77 break; 75 break;
78 } 76 }
79 case PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE: 77 case PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE:
80 case PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE: { 78 case PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE: {
81 if (!bound_)
82 return PP_ERROR_FAILED;
83 if (value.type != PP_VARTYPE_INT32) 79 if (value.type != PP_VARTYPE_INT32)
84 return PP_ERROR_BADARGUMENT; 80 return PP_ERROR_BADARGUMENT;
85 option_data.SetInt32(value.value.as_int); 81 option_data.SetInt32(value.value.as_int);
86 break; 82 break;
87 } 83 }
88 default: { 84 default: {
89 NOTREACHED(); 85 NOTREACHED();
90 return PP_ERROR_BADARGUMENT; 86 return PP_ERROR_BADARGUMENT;
91 } 87 }
92 } 88 }
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 if (result == PP_OK && !data.empty()) 340 if (result == PP_OK && !data.empty())
345 memcpy(output_buffer, data.c_str(), data.size()); 341 memcpy(output_buffer, data.c_str(), data.size());
346 342
347 recvfrom_addr_ = addr; 343 recvfrom_addr_ = addr;
348 344
349 return result == PP_OK ? static_cast<int32_t>(data.size()) : result; 345 return result == PP_OK ? static_cast<int32_t>(data.size()) : result;
350 } 346 }
351 347
352 } // namespace proxy 348 } // namespace proxy
353 } // namespace ppapi 349 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698