| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/c/pp_completion_callback.h" | 5 #include "ppapi/c/pp_completion_callback.h" |
| 6 #include "ppapi/c/pp_errors.h" | 6 #include "ppapi/c/pp_errors.h" |
| 7 #include "ppapi/c/private/ppb_tcp_socket_private.h" | 7 #include "ppapi/c/private/ppb_tcp_socket_private.h" |
| 8 #include "ppapi/thunk/enter.h" | 8 #include "ppapi/thunk/enter.h" |
| 9 #include "ppapi/thunk/thunk.h" | 9 #include "ppapi/thunk/thunk.h" |
| 10 #include "ppapi/thunk/ppb_tcp_socket_private_api.h" | 10 #include "ppapi/thunk/ppb_tcp_socket_private_api.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 const char* server_name, | 68 const char* server_name, |
| 69 uint16_t server_port, | 69 uint16_t server_port, |
| 70 PP_CompletionCallback callback) { | 70 PP_CompletionCallback callback) { |
| 71 EnterTCP enter(tcp_socket, callback, true); | 71 EnterTCP enter(tcp_socket, callback, true); |
| 72 if (enter.failed()) | 72 if (enter.failed()) |
| 73 return enter.retval(); | 73 return enter.retval(); |
| 74 return enter.SetResult(enter.object()->SSLHandshake(server_name, server_port, | 74 return enter.SetResult(enter.object()->SSLHandshake(server_name, server_port, |
| 75 callback)); | 75 callback)); |
| 76 } | 76 } |
| 77 | 77 |
| 78 PP_Resource GetServerCertificate(PP_Resource tcp_socket) { |
| 79 EnterTCP enter(tcp_socket, true); |
| 80 if (enter.failed()) |
| 81 return 0; |
| 82 return enter.object()->GetServerCertificate(); |
| 83 } |
| 84 |
| 85 PP_Bool AddChainBuildingCertificate(PP_Resource tcp_socket, |
| 86 PP_Resource certificate, |
| 87 PP_Bool trusted) { |
| 88 EnterTCP enter(tcp_socket, true); |
| 89 if (enter.failed()) |
| 90 return PP_FALSE; |
| 91 return enter.object()->AddChainBuildingCertificate(certificate, |
| 92 trusted); |
| 93 } |
| 94 |
| 78 int32_t Read(PP_Resource tcp_socket, | 95 int32_t Read(PP_Resource tcp_socket, |
| 79 char* buffer, | 96 char* buffer, |
| 80 int32_t bytes_to_read, | 97 int32_t bytes_to_read, |
| 81 PP_CompletionCallback callback) { | 98 PP_CompletionCallback callback) { |
| 82 EnterTCP enter(tcp_socket, callback, true); | 99 EnterTCP enter(tcp_socket, callback, true); |
| 83 if (enter.failed()) | 100 if (enter.failed()) |
| 84 return enter.retval(); | 101 return enter.retval(); |
| 85 return enter.SetResult(enter.object()->Read(buffer, bytes_to_read, callback)); | 102 return enter.SetResult(enter.object()->Read(buffer, bytes_to_read, callback)); |
| 86 } | 103 } |
| 87 | 104 |
| 88 int32_t Write(PP_Resource tcp_socket, | 105 int32_t Write(PP_Resource tcp_socket, |
| 89 const char* buffer, | 106 const char* buffer, |
| 90 int32_t bytes_to_write, | 107 int32_t bytes_to_write, |
| 91 PP_CompletionCallback callback) { | 108 PP_CompletionCallback callback) { |
| 92 EnterTCP enter(tcp_socket, callback, true); | 109 EnterTCP enter(tcp_socket, callback, true); |
| 93 if (enter.failed()) | 110 if (enter.failed()) |
| 94 return enter.retval(); | 111 return enter.retval(); |
| 95 return enter.SetResult(enter.object()->Write(buffer, bytes_to_write, | 112 return enter.SetResult(enter.object()->Write(buffer, bytes_to_write, |
| 96 callback)); | 113 callback)); |
| 97 } | 114 } |
| 98 | 115 |
| 99 void Disconnect(PP_Resource tcp_socket) { | 116 void Disconnect(PP_Resource tcp_socket) { |
| 100 EnterTCP enter(tcp_socket, true); | 117 EnterTCP enter(tcp_socket, true); |
| 101 if (enter.succeeded()) | 118 if (enter.succeeded()) |
| 102 enter.object()->Disconnect(); | 119 enter.object()->Disconnect(); |
| 103 } | 120 } |
| 104 | 121 |
| 105 const PPB_TCPSocket_Private g_ppb_tcp_socket_thunk = { | 122 const PPB_TCPSocket_Private_0_3 g_ppb_tcp_socket_thunk_0_3 = { |
| 106 &Create, | 123 &Create, |
| 107 &IsTCPSocket, | 124 &IsTCPSocket, |
| 108 &Connect, | 125 &Connect, |
| 126 &ConnectWithNetAddress, |
| 127 &GetLocalAddress, |
| 128 &GetRemoteAddress, |
| 129 &SSLHandshake, |
| 130 &Read, |
| 131 &Write, |
| 132 &Disconnect |
| 133 }; |
| 134 |
| 135 const PPB_TCPSocket_Private g_ppb_tcp_socket_thunk_0_4 = { |
| 136 &Create, |
| 137 &IsTCPSocket, |
| 138 &Connect, |
| 109 &ConnectWithNetAddress, | 139 &ConnectWithNetAddress, |
| 110 &GetLocalAddress, | 140 &GetLocalAddress, |
| 111 &GetRemoteAddress, | 141 &GetRemoteAddress, |
| 112 &SSLHandshake, | 142 &SSLHandshake, |
| 143 &GetServerCertificate, |
| 144 &AddChainBuildingCertificate, |
| 113 &Read, | 145 &Read, |
| 114 &Write, | 146 &Write, |
| 115 &Disconnect | 147 &Disconnect |
| 116 }; | 148 }; |
| 117 | 149 |
| 118 } // namespace | 150 } // namespace |
| 119 | 151 |
| 120 const PPB_TCPSocket_Private_0_3* GetPPB_TCPSocket_Private_0_3_Thunk() { | 152 const PPB_TCPSocket_Private_0_3* GetPPB_TCPSocket_Private_0_3_Thunk() { |
| 121 return &g_ppb_tcp_socket_thunk; | 153 return &g_ppb_tcp_socket_thunk_0_3; |
| 154 } |
| 155 |
| 156 const PPB_TCPSocket_Private_0_4* GetPPB_TCPSocket_Private_0_4_Thunk() { |
| 157 return &g_ppb_tcp_socket_thunk_0_4; |
| 122 } | 158 } |
| 123 | 159 |
| 124 } // namespace thunk | 160 } // namespace thunk |
| 125 } // namespace ppapi | 161 } // namespace ppapi |
| OLD | NEW |