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

Unified Diff: ppapi/proxy/udp_socket_resource_base.cc

Issue 704133005: Pepper: Add support for multicast in PPB_UDPSocket API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase, remove IF option, JoinGroup and LeaveGroup as functions Created 5 years, 10 months 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 97864d535b2678ccdb191cca0483b6350b69229f..15ce5eea2d0ce3a7af7ca7f238992ce1533ef4f8 100644
--- a/ppapi/proxy/udp_socket_resource_base.cc
+++ b/ppapi/proxy/udp_socket_resource_base.cc
@@ -68,18 +68,35 @@ int32_t UDPSocketResourceBase::SetOptionImpl(
if (closed_)
return PP_ERROR_FAILED;
- SocketOptionData option_data;
+ // Check if socket is expected to be bound or not according to the option
bbudge 2015/02/13 00:03:16 nit: period at end of sentence.
etrunko 2015/02/13 20:19:58 Done.
switch (name) {
case PP_UDPSOCKET_OPTION_ADDRESS_REUSE:
- case PP_UDPSOCKET_OPTION_BROADCAST: {
- if ((check_bind_state || name == PP_UDPSOCKET_OPTION_ADDRESS_REUSE) &&
- bind_called_) {
+ check_bind_state = true; // fallthrough
+ case PP_UDPSOCKET_OPTION_BROADCAST:
+ case PP_UDPSOCKET_OPTION_MULTICAST_LOOP:
+ case PP_UDPSOCKET_OPTION_MULTICAST_TTL: {
+ if (check_bind_state && bind_called_) {
// SetOption should fail in this case in order to give predictable
// behavior while binding. Note that we use |bind_called_| rather
// than |bound_| since the latter is only set on successful completion
// of Bind().
return PP_ERROR_FAILED;
}
+ break;
+ }
+ case PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE:
+ case PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE: {
+ if (check_bind_state && !bound_)
+ return PP_ERROR_FAILED;
+ break;
+ }
+ }
+
+ SocketOptionData option_data;
+ switch (name) {
+ case PP_UDPSOCKET_OPTION_ADDRESS_REUSE:
+ case PP_UDPSOCKET_OPTION_BROADCAST:
+ case PP_UDPSOCKET_OPTION_MULTICAST_LOOP: {
if (value.type != PP_VARTYPE_BOOL)
return PP_ERROR_BADARGUMENT;
option_data.SetBool(PP_ToBool(value.value.as_bool));
@@ -87,13 +104,18 @@ int32_t UDPSocketResourceBase::SetOptionImpl(
}
case PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE:
case PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE: {
- 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);
break;
}
+ case PP_UDPSOCKET_OPTION_MULTICAST_TTL: {
+ int32_t ival = value.value.as_int;
+ if (value.type != PP_VARTYPE_INT32 && (ival < 0 || ival > 255))
+ return PP_ERROR_BADARGUMENT;
+ option_data.SetInt32(ival);
+ break;
+ }
default: {
NOTREACHED();
return PP_ERROR_BADARGUMENT;
@@ -233,6 +255,38 @@ void UDPSocketResourceBase::CloseImpl() {
bytes_to_read_ = -1;
}
+int32_t UDPSocketResourceBase::JoinGroupImpl(
+ const PP_NetAddress_Private *group,
+ scoped_refptr<TrackedCallback> callback) {
+ if (!group)
+ return PP_ERROR_BADARGUMENT;
bbudge 2015/02/13 00:03:16 A plugin error isn't quite right here, because the
etrunko 2015/02/13 20:19:58 Done.
+
+ Call<PpapiPluginMsg_UDPSocket_JoinGroupReply>(
+ BROWSER,
+ PpapiHostMsg_UDPSocket_JoinGroup(*group),
+ base::Bind(&UDPSocketResourceBase::OnPluginMsgSetOptionReply,
bbudge 2015/02/13 00:03:16 I think at this point we should rename this method
etrunko 2015/02/13 20:19:58 Done. I guess so, by the time I wondered if this
+ base::Unretained(this),
+ callback),
+ callback);
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t UDPSocketResourceBase::LeaveGroupImpl(
+ const PP_NetAddress_Private *group,
+ scoped_refptr<TrackedCallback> callback) {
+ if (!group)
+ return PP_ERROR_BADARGUMENT;
bbudge 2015/02/13 00:03:16 DCHECK
etrunko 2015/02/13 20:19:58 Done.
+
+ Call<PpapiPluginMsg_UDPSocket_LeaveGroupReply>(
+ BROWSER,
+ PpapiHostMsg_UDPSocket_LeaveGroup(*group),
+ base::Bind(&UDPSocketResourceBase::OnPluginMsgSetOptionReply,
+ base::Unretained(this),
+ callback),
+ callback);
+ return PP_OK_COMPLETIONPENDING;
+}
+
void UDPSocketResourceBase::OnReplyReceived(
const ResourceMessageReplyParams& params,
const IPC::Message& msg) {

Powered by Google App Engine
This is Rietveld 408576698