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

Side by Side Diff: ppapi/thunk/ppb_tcp_socket_dev_thunk.cc

Issue 17314012: Move PPB_TCPSocket out of dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
« no previous file with comments | « ppapi/thunk/ppb_tcp_socket_api.h ('k') | ppapi/thunk/ppb_tcp_socket_thunk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // From dev/ppb_tcp_socket_dev.idl modified Wed Jun 05 23:11:18 2013.
6
7 #include "ppapi/c/dev/ppb_tcp_socket_dev.h"
8 #include "ppapi/c/pp_completion_callback.h"
9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/shared_impl/tracked_callback.h"
11 #include "ppapi/thunk/enter.h"
12 #include "ppapi/thunk/ppb_instance_api.h"
13 #include "ppapi/thunk/ppb_tcp_socket_api.h"
14 #include "ppapi/thunk/resource_creation_api.h"
15 #include "ppapi/thunk/thunk.h"
16
17 namespace ppapi {
18 namespace thunk {
19
20 namespace {
21
22 PP_Resource Create(PP_Instance instance) {
23 VLOG(4) << "PPB_TCPSocket_Dev::Create()";
24 EnterResourceCreation enter(instance);
25 if (enter.failed())
26 return 0;
27 return enter.functions()->CreateTCPSocket(instance);
28 }
29
30 PP_Bool IsTCPSocket(PP_Resource resource) {
31 VLOG(4) << "PPB_TCPSocket_Dev::IsTCPSocket()";
32 EnterResource<PPB_TCPSocket_API> enter(resource, false);
33 return PP_FromBool(enter.succeeded());
34 }
35
36 int32_t Connect(PP_Resource tcp_socket,
37 PP_Resource addr,
38 struct PP_CompletionCallback callback) {
39 VLOG(4) << "PPB_TCPSocket_Dev::Connect()";
40 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true);
41 if (enter.failed())
42 return enter.retval();
43 return enter.SetResult(enter.object()->Connect(addr, enter.callback()));
44 }
45
46 PP_Resource GetLocalAddress(PP_Resource tcp_socket) {
47 VLOG(4) << "PPB_TCPSocket_Dev::GetLocalAddress()";
48 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, true);
49 if (enter.failed())
50 return 0;
51 return enter.object()->GetLocalAddress();
52 }
53
54 PP_Resource GetRemoteAddress(PP_Resource tcp_socket) {
55 VLOG(4) << "PPB_TCPSocket_Dev::GetRemoteAddress()";
56 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, true);
57 if (enter.failed())
58 return 0;
59 return enter.object()->GetRemoteAddress();
60 }
61
62 int32_t Read(PP_Resource tcp_socket,
63 char* buffer,
64 int32_t bytes_to_read,
65 struct PP_CompletionCallback callback) {
66 VLOG(4) << "PPB_TCPSocket_Dev::Read()";
67 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true);
68 if (enter.failed())
69 return enter.retval();
70 return enter.SetResult(enter.object()->Read(buffer,
71 bytes_to_read,
72 enter.callback()));
73 }
74
75 int32_t Write(PP_Resource tcp_socket,
76 const char* buffer,
77 int32_t bytes_to_write,
78 struct PP_CompletionCallback callback) {
79 VLOG(4) << "PPB_TCPSocket_Dev::Write()";
80 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true);
81 if (enter.failed())
82 return enter.retval();
83 return enter.SetResult(enter.object()->Write(buffer,
84 bytes_to_write,
85 enter.callback()));
86 }
87
88 void Close(PP_Resource tcp_socket) {
89 VLOG(4) << "PPB_TCPSocket_Dev::Close()";
90 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, true);
91 if (enter.failed())
92 return;
93 enter.object()->Close();
94 }
95
96 int32_t SetOption(PP_Resource tcp_socket,
97 PP_TCPSocket_Option_Dev name,
98 struct PP_Var value,
99 struct PP_CompletionCallback callback) {
100 VLOG(4) << "PPB_TCPSocket_Dev::SetOption()";
101 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true);
102 if (enter.failed())
103 return enter.retval();
104 return enter.SetResult(enter.object()->SetOption(name,
105 value,
106 enter.callback()));
107 }
108
109 const PPB_TCPSocket_Dev_0_1 g_ppb_tcpsocket_dev_thunk_0_1 = {
110 &Create,
111 &IsTCPSocket,
112 &Connect,
113 &GetLocalAddress,
114 &GetRemoteAddress,
115 &Read,
116 &Write,
117 &Close,
118 &SetOption
119 };
120
121 } // namespace
122
123 const PPB_TCPSocket_Dev_0_1* GetPPB_TCPSocket_Dev_0_1_Thunk() {
124 return &g_ppb_tcpsocket_dev_thunk_0_1;
125 }
126
127 } // namespace thunk
128 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_tcp_socket_api.h ('k') | ppapi/thunk/ppb_tcp_socket_thunk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698