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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/proxy/udp_socket_resource_base.cc
diff --git a/ppapi/proxy/udp_socket_resource_base.cc b/ppapi/proxy/udp_socket_resource_base.cc
index 521a6e2f4e284220d649e8d49934f503b6245127..e749c3bbcb3cfdd5711e88da2a69b86540b77d7e 100644
--- a/ppapi/proxy/udp_socket_resource_base.cc
+++ b/ppapi/proxy/udp_socket_resource_base.cc
@@ -34,6 +34,7 @@ UDPSocketResourceBase::UDPSocketResourceBase(Connection connection,
bool private_api)
: PluginResource(connection, instance),
private_api_(private_api),
+ bind_called_(false),
bound_(false),
closed_(false),
read_buffer_(NULL),
@@ -61,6 +62,7 @@ UDPSocketResourceBase::~UDPSocketResourceBase() {
int32_t UDPSocketResourceBase::SetOptionImpl(
PP_UDPSocket_Option name,
const PP_Var& value,
+ bool check_bind_state,
scoped_refptr<TrackedCallback> callback) {
if (closed_)
return PP_ERROR_FAILED;
@@ -69,8 +71,9 @@ int32_t UDPSocketResourceBase::SetOptionImpl(
switch (name) {
case PP_UDPSOCKET_OPTION_ADDRESS_REUSE:
case PP_UDPSOCKET_OPTION_BROADCAST: {
- if (bound_)
+ if (check_bind_state && bind_called_)
bbudge 2014/11/07 17:50:39 Why not use bound_ here? If there is a reason for
hidehiko 2014/11/07 21:13:55 Using |bound_| here could cause a minor timing iss
return PP_ERROR_FAILED;
+
if (value.type != PP_VARTYPE_BOOL)
return PP_ERROR_BADARGUMENT;
option_data.SetBool(PP_ToBool(value.value.as_bool));
@@ -78,8 +81,9 @@ int32_t UDPSocketResourceBase::SetOptionImpl(
}
case PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE:
case PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE: {
- if (!bound_)
+ if (check_bind_state && !bound_)
return PP_ERROR_FAILED;
+
if (value.type != PP_VARTYPE_INT32)
return PP_ERROR_BADARGUMENT;
option_data.SetInt32(value.value.as_int);
@@ -111,6 +115,7 @@ int32_t UDPSocketResourceBase::BindImpl(
if (TrackedCallback::IsPending(bind_callback_))
return PP_ERROR_INPROGRESS;
+ bind_called_ = true;
bind_callback_ = callback;
// Send the request, the browser will call us back via BindReply.

Powered by Google App Engine
This is Rietveld 408576698