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

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

Powered by Google App Engine
This is Rietveld 408576698