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/udp_socket_resource.h" | 5 #include "ppapi/proxy/udp_socket_resource.h" |
6 | 6 |
7 #include "ppapi/shared_impl/tracked_callback.h" | 7 #include "ppapi/shared_impl/tracked_callback.h" |
8 #include "ppapi/thunk/enter.h" | 8 #include "ppapi/thunk/enter.h" |
9 #include "ppapi/thunk/ppb_net_address_api.h" | 9 #include "ppapi/thunk/ppb_net_address_api.h" |
10 #include "ppapi/thunk/resource_creation_api.h" | 10 #include "ppapi/thunk/resource_creation_api.h" |
11 | 11 |
12 namespace ppapi { | 12 namespace ppapi { |
13 namespace proxy { | 13 namespace proxy { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 typedef thunk::EnterResourceNoLock<thunk::PPB_NetAddress_API> | 17 typedef thunk::EnterResourceNoLock<thunk::PPB_NetAddress_API> |
18 EnterNetAddressNoLock; | 18 EnterNetAddressNoLock; |
19 | 19 |
20 } // namespace | 20 } // namespace |
21 | 21 |
22 UDPSocketResource::UDPSocketResource(Connection connection, | 22 UDPSocketResource::UDPSocketResource(Connection connection, |
23 PP_Instance instance) | 23 PP_Instance instance) |
24 : UDPSocketResourceBase(connection, instance) { | 24 : UDPSocketResourceBase(connection, instance, false) { |
25 } | 25 } |
26 | 26 |
27 UDPSocketResource::~UDPSocketResource() { | 27 UDPSocketResource::~UDPSocketResource() { |
28 } | 28 } |
29 | 29 |
30 thunk::PPB_UDPSocket_API* UDPSocketResource::AsPPB_UDPSocket_API() { | 30 thunk::PPB_UDPSocket_API* UDPSocketResource::AsPPB_UDPSocket_API() { |
31 return this; | 31 return this; |
32 } | 32 } |
33 | 33 |
34 int32_t UDPSocketResource::Bind(PP_Resource addr, | 34 int32_t UDPSocketResource::Bind(PP_Resource addr, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 callback); | 71 callback); |
72 } | 72 } |
73 | 73 |
74 void UDPSocketResource::Close() { | 74 void UDPSocketResource::Close() { |
75 CloseImpl(); | 75 CloseImpl(); |
76 } | 76 } |
77 | 77 |
78 int32_t UDPSocketResource::SetOption( | 78 int32_t UDPSocketResource::SetOption( |
79 PP_UDPSocket_Option_Dev name, | 79 PP_UDPSocket_Option_Dev name, |
80 const PP_Var& value, | 80 const PP_Var& value, |
81 scoped_refptr<TrackedCallback> /* callback */) { | 81 scoped_refptr<TrackedCallback> callback) { |
82 // TODO(yzshen): Add support for other options. | 82 return SetOptionImpl(name, value, callback); |
83 PP_UDPSocketFeature_Private feature; | |
84 switch (name) { | |
85 case PP_UDPSOCKET_OPTION_ADDRESS_REUSE: | |
86 feature = PP_UDPSOCKETFEATURE_ADDRESS_REUSE; | |
87 break; | |
88 case PP_UDPSOCKET_OPTION_BROADCAST: | |
89 feature = PP_UDPSOCKETFEATURE_BROADCAST; | |
90 break; | |
91 default: | |
92 return PP_ERROR_NOTSUPPORTED; | |
93 } | |
94 | |
95 return SetSocketFeatureImpl(feature, value); | |
96 } | 83 } |
97 | 84 |
98 } // namespace proxy | 85 } // namespace proxy |
99 } // namespace ppapi | 86 } // namespace ppapi |
OLD | NEW |