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

Side by Side Diff: ppapi/cpp/private/flash_udp_socket.cc

Issue 7745005: Initial work for UDP Pepper API (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: A few more changes after self-review Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ppapi/cpp/private/flash_udp_socket.h"
6
7 #include "ppapi/c/pp_bool.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/cpp/completion_callback.h"
10 #include "ppapi/cpp/instance.h"
11 #include "ppapi/cpp/module.h"
12 #include "ppapi/cpp/module_impl.h"
13
14 namespace pp {
15
16 namespace {
17
18 template <> const char* interface_name<PPB_Flash_UDPSocket>() {
19 return PPB_FLASH_UDPSOCKET_INTERFACE;
20 }
21
22 } // namespace
23
24 namespace flash {
25
26 UDPSocket::UDPSocket(Instance* instance, int32_t family) {
27 if (has_interface<PPB_Flash_UDPSocket>() && instance) {
28 PassRefFromConstructor(get_interface<PPB_Flash_UDPSocket>()->Create(
29 instance->pp_instance(), family));
30 }
31 }
32
33 int32_t UDPSocket::Bind(const PP_Flash_NetAddress* addr,
34 const CompletionCallback& callback) {
35 if (!has_interface<PPB_Flash_UDPSocket>())
yzshen1 2011/09/17 02:10:07 Wrong indent.
mtilburg 2011/09/21 01:46:43 Done.
36 return PP_ERROR_NOINTERFACE;
37 return get_interface<PPB_Flash_UDPSocket>()->Bind(
38 pp_resource(), addr, callback.pp_completion_callback());
39 }
40
41 int32_t UDPSocket::RecvFrom(char *buffer,
yzshen1 2011/09/17 02:10:07 Style nit: * position.
mtilburg 2011/09/21 01:46:43 Done.
42 int32_t num_bytes,
43 const CompletionCallback& callback) {
44 if (!has_interface<PPB_Flash_UDPSocket>())
45 return PP_ERROR_NOINTERFACE;
46 return get_interface<PPB_Flash_UDPSocket>()->RecvFrom(
47 pp_resource(), buffer, num_bytes, callback.pp_completion_callback());
yzshen1 2011/09/17 02:10:07 Wrong indent.
mtilburg 2011/09/21 01:46:43 Done.
48 }
49
50 bool UDPSocket::GetRecvFromAddress(PP_Flash_NetAddress* addr) {
51 if (!has_interface<PPB_Flash_UDPSocket>())
52 return false;
53
54 PP_Bool result = get_interface<PPB_Flash_UDPSocket>()->GetRecvFromAddress(
55 pp_resource(), addr);
56 return PP_ToBool(result);
57 }
58
59 int32_t UDPSocket::SendTo(const char* buffer,
60 int32_t num_bytes,
61 const struct PP_Flash_NetAddress* addr,
62 const CompletionCallback& callback) {
63 if (!has_interface<PPB_Flash_UDPSocket>())
64 return PP_ERROR_NOINTERFACE;
65 return get_interface<PPB_Flash_UDPSocket>()->SendTo(
66 pp_resource(), buffer, num_bytes, addr, callback.pp_completion_callback());
yzshen1 2011/09/17 02:10:07 Wrong indent.
mtilburg 2011/09/21 01:46:43 Done.
67 }
68
69 } // namespace flash
70 } // namespace pp
71
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698