| 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 // From ppb_tcp_socket.idl modified Sun Sep 15 16:14:21 2013. | 5 // From ppb_tcp_socket.idl modified Sun Sep 15 16:14:21 2013. |
| 6 | 6 |
| 7 #include "ppapi/c/pp_completion_callback.h" | 7 #include "ppapi/c/pp_completion_callback.h" |
| 8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/c/ppb_tcp_socket.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" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 78 } |
| 79 | 79 |
| 80 int32_t Read(PP_Resource tcp_socket, | 80 int32_t Read(PP_Resource tcp_socket, |
| 81 char* buffer, | 81 char* buffer, |
| 82 int32_t bytes_to_read, | 82 int32_t bytes_to_read, |
| 83 struct PP_CompletionCallback callback) { | 83 struct PP_CompletionCallback callback) { |
| 84 VLOG(4) << "PPB_TCPSocket::Read()"; | 84 VLOG(4) << "PPB_TCPSocket::Read()"; |
| 85 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); | 85 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); |
| 86 if (enter.failed()) | 86 if (enter.failed()) |
| 87 return enter.retval(); | 87 return enter.retval(); |
| 88 return enter.SetResult(enter.object()->Read(buffer, | 88 return enter.SetResult( |
| 89 bytes_to_read, | 89 enter.object()->Read(buffer, bytes_to_read, enter.callback())); |
| 90 enter.callback())); | |
| 91 } | 90 } |
| 92 | 91 |
| 93 int32_t Write(PP_Resource tcp_socket, | 92 int32_t Write(PP_Resource tcp_socket, |
| 94 const char* buffer, | 93 const char* buffer, |
| 95 int32_t bytes_to_write, | 94 int32_t bytes_to_write, |
| 96 struct PP_CompletionCallback callback) { | 95 struct PP_CompletionCallback callback) { |
| 97 VLOG(4) << "PPB_TCPSocket::Write()"; | 96 VLOG(4) << "PPB_TCPSocket::Write()"; |
| 98 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); | 97 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); |
| 99 if (enter.failed()) | 98 if (enter.failed()) |
| 100 return enter.retval(); | 99 return enter.retval(); |
| 101 return enter.SetResult(enter.object()->Write(buffer, | 100 return enter.SetResult( |
| 102 bytes_to_write, | 101 enter.object()->Write(buffer, bytes_to_write, enter.callback())); |
| 103 enter.callback())); | |
| 104 } | 102 } |
| 105 | 103 |
| 106 int32_t Listen(PP_Resource tcp_socket, | 104 int32_t Listen(PP_Resource tcp_socket, |
| 107 int32_t backlog, | 105 int32_t backlog, |
| 108 struct PP_CompletionCallback callback) { | 106 struct PP_CompletionCallback callback) { |
| 109 VLOG(4) << "PPB_TCPSocket::Listen()"; | 107 VLOG(4) << "PPB_TCPSocket::Listen()"; |
| 110 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); | 108 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); |
| 111 if (enter.failed()) | 109 if (enter.failed()) |
| 112 return enter.retval(); | 110 return enter.retval(); |
| 113 return enter.SetResult(enter.object()->Listen(backlog, enter.callback())); | 111 return enter.SetResult(enter.object()->Listen(backlog, enter.callback())); |
| 114 } | 112 } |
| 115 | 113 |
| 116 int32_t Accept(PP_Resource tcp_socket, | 114 int32_t Accept(PP_Resource tcp_socket, |
| 117 PP_Resource* accepted_tcp_socket, | 115 PP_Resource* accepted_tcp_socket, |
| 118 struct PP_CompletionCallback callback) { | 116 struct PP_CompletionCallback callback) { |
| 119 VLOG(4) << "PPB_TCPSocket::Accept()"; | 117 VLOG(4) << "PPB_TCPSocket::Accept()"; |
| 120 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); | 118 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); |
| 121 if (enter.failed()) | 119 if (enter.failed()) |
| 122 return enter.retval(); | 120 return enter.retval(); |
| 123 return enter.SetResult(enter.object()->Accept(accepted_tcp_socket, | 121 return enter.SetResult( |
| 124 enter.callback())); | 122 enter.object()->Accept(accepted_tcp_socket, enter.callback())); |
| 125 } | 123 } |
| 126 | 124 |
| 127 void Close(PP_Resource tcp_socket) { | 125 void Close(PP_Resource tcp_socket) { |
| 128 VLOG(4) << "PPB_TCPSocket::Close()"; | 126 VLOG(4) << "PPB_TCPSocket::Close()"; |
| 129 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, true); | 127 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, true); |
| 130 if (enter.failed()) | 128 if (enter.failed()) |
| 131 return; | 129 return; |
| 132 enter.object()->Close(); | 130 enter.object()->Close(); |
| 133 } | 131 } |
| 134 | 132 |
| 135 int32_t SetOption(PP_Resource tcp_socket, | 133 int32_t SetOption(PP_Resource tcp_socket, |
| 136 PP_TCPSocket_Option name, | 134 PP_TCPSocket_Option name, |
| 137 struct PP_Var value, | 135 struct PP_Var value, |
| 138 struct PP_CompletionCallback callback) { | 136 struct PP_CompletionCallback callback) { |
| 139 VLOG(4) << "PPB_TCPSocket::SetOption()"; | 137 VLOG(4) << "PPB_TCPSocket::SetOption()"; |
| 140 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); | 138 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); |
| 141 if (enter.failed()) | 139 if (enter.failed()) |
| 142 return enter.retval(); | 140 return enter.retval(); |
| 143 return enter.SetResult(enter.object()->SetOption(name, | 141 return enter.SetResult( |
| 144 value, | 142 enter.object()->SetOption(name, value, enter.callback())); |
| 145 enter.callback())); | |
| 146 } | 143 } |
| 147 | 144 |
| 148 const PPB_TCPSocket_1_0 g_ppb_tcpsocket_thunk_1_0 = { | 145 const PPB_TCPSocket_1_0 g_ppb_tcpsocket_thunk_1_0 = { |
| 149 &Create_1_0, | 146 &Create_1_0, &IsTCPSocket, &Connect, &GetLocalAddress, &GetRemoteAddress, |
| 150 &IsTCPSocket, | 147 &Read, &Write, &Close, &SetOption}; |
| 151 &Connect, | |
| 152 &GetLocalAddress, | |
| 153 &GetRemoteAddress, | |
| 154 &Read, | |
| 155 &Write, | |
| 156 &Close, | |
| 157 &SetOption | |
| 158 }; | |
| 159 | 148 |
| 160 const PPB_TCPSocket_1_1 g_ppb_tcpsocket_thunk_1_1 = { | 149 const PPB_TCPSocket_1_1 g_ppb_tcpsocket_thunk_1_1 = { |
| 161 &Create, | 150 &Create, &IsTCPSocket, &Bind, &Connect, |
| 162 &IsTCPSocket, | 151 &GetLocalAddress, &GetRemoteAddress, &Read, &Write, |
| 163 &Bind, | 152 &Listen, &Accept, &Close, &SetOption}; |
| 164 &Connect, | |
| 165 &GetLocalAddress, | |
| 166 &GetRemoteAddress, | |
| 167 &Read, | |
| 168 &Write, | |
| 169 &Listen, | |
| 170 &Accept, | |
| 171 &Close, | |
| 172 &SetOption | |
| 173 }; | |
| 174 | 153 |
| 175 } // namespace | 154 } // namespace |
| 176 | 155 |
| 177 const PPB_TCPSocket_1_0* GetPPB_TCPSocket_1_0_Thunk() { | 156 const PPB_TCPSocket_1_0* GetPPB_TCPSocket_1_0_Thunk() { |
| 178 return &g_ppb_tcpsocket_thunk_1_0; | 157 return &g_ppb_tcpsocket_thunk_1_0; |
| 179 } | 158 } |
| 180 | 159 |
| 181 const PPB_TCPSocket_1_1* GetPPB_TCPSocket_1_1_Thunk() { | 160 const PPB_TCPSocket_1_1* GetPPB_TCPSocket_1_1_Thunk() { |
| 182 return &g_ppb_tcpsocket_thunk_1_1; | 161 return &g_ppb_tcpsocket_thunk_1_1; |
| 183 } | 162 } |
| 184 | 163 |
| 185 } // namespace thunk | 164 } // namespace thunk |
| 186 } // namespace ppapi | 165 } // namespace ppapi |
| OLD | NEW |