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

Side by Side Diff: runtime/bin/secure_socket_boringssl.cc

Issue 1852783003: Implements remaining SecurityContext calls for iOS (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add RefCntReleaseScope Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #if !defined(DART_IO_DISABLED) && !defined(DART_IO_SECURE_SOCKET_DISABLED) 5 #if !defined(DART_IO_DISABLED) && !defined(DART_IO_SECURE_SOCKET_DISABLED)
6 6
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #if defined(TARGET_OS_ANDROID) || \ 8 #if defined(TARGET_OS_ANDROID) || \
9 defined(TARGET_OS_LINUX) || \ 9 defined(TARGET_OS_LINUX) || \
10 defined(TARGET_OS_WINDOWS) 10 defined(TARGET_OS_WINDOWS)
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 reinterpret_cast<intptr_t*>(&filter))); 114 reinterpret_cast<intptr_t*>(&filter)));
115 return filter; 115 return filter;
116 } 116 }
117 117
118 118
119 static void DeleteFilter( 119 static void DeleteFilter(
120 void* isolate_data, 120 void* isolate_data,
121 Dart_WeakPersistentHandle handle, 121 Dart_WeakPersistentHandle handle,
122 void* context_pointer) { 122 void* context_pointer) {
123 SSLFilter* filter = reinterpret_cast<SSLFilter*>(context_pointer); 123 SSLFilter* filter = reinterpret_cast<SSLFilter*>(context_pointer);
124 delete filter; 124 filter->Release();
125 } 125 }
126 126
127 127
128 static Dart_Handle SetFilter(Dart_NativeArguments args, SSLFilter* filter) { 128 static Dart_Handle SetFilter(Dart_NativeArguments args, SSLFilter* filter) {
129 ASSERT(filter != NULL); 129 ASSERT(filter != NULL);
130 Dart_Handle dart_this = Dart_GetNativeArgument(args, 0); 130 Dart_Handle dart_this = Dart_GetNativeArgument(args, 0);
131 RETURN_IF_ERROR(dart_this); 131 RETURN_IF_ERROR(dart_this);
132 ASSERT(Dart_IsInstance(dart_this)); 132 ASSERT(Dart_IsInstance(dart_this));
133 Dart_Handle err = Dart_SetNativeInstanceField( 133 Dart_Handle err = Dart_SetNativeInstanceField(
134 dart_this, 134 dart_this,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // Forward declaration. 198 // Forward declaration.
199 static void SetAlpnProtocolList(Dart_Handle protocols_handle, 199 static void SetAlpnProtocolList(Dart_Handle protocols_handle,
200 SSL* ssl, 200 SSL* ssl,
201 SSL_CTX* context, 201 SSL_CTX* context,
202 bool is_server); 202 bool is_server);
203 203
204 204
205 void FUNCTION_NAME(SecureSocket_Init)(Dart_NativeArguments args) { 205 void FUNCTION_NAME(SecureSocket_Init)(Dart_NativeArguments args) {
206 Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0)); 206 Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0));
207 SSLFilter* filter = new SSLFilter(); 207 SSLFilter* filter = new SSLFilter();
208 filter->Retain();
208 Dart_Handle err = SetFilter(args, filter); 209 Dart_Handle err = SetFilter(args, filter);
209 if (Dart_IsError(err)) { 210 if (Dart_IsError(err)) {
210 delete filter; 211 filter->Release();
211 Dart_PropagateError(err); 212 Dart_PropagateError(err);
212 } 213 }
213 err = filter->Init(dart_this); 214 err = filter->Init(dart_this);
214 if (Dart_IsError(err)) { 215 if (Dart_IsError(err)) {
215 // The finalizer was set up by SetFilter. It will delete `filter` if there 216 // The finalizer was set up by SetFilter. It will delete `filter` if there
216 // is an error. 217 // is an error.
217 filter->Destroy(); 218 filter->Destroy();
218 Dart_PropagateError(err); 219 Dart_PropagateError(err);
219 } 220 }
220 } 221 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 318
318 319
319 void FUNCTION_NAME(SecureSocket_PeerCertificate) 320 void FUNCTION_NAME(SecureSocket_PeerCertificate)
320 (Dart_NativeArguments args) { 321 (Dart_NativeArguments args) {
321 Dart_Handle cert = ThrowIfError(GetFilter(args)->PeerCertificate()); 322 Dart_Handle cert = ThrowIfError(GetFilter(args)->PeerCertificate());
322 Dart_SetReturnValue(args, cert); 323 Dart_SetReturnValue(args, cert);
323 } 324 }
324 325
325 326
326 void FUNCTION_NAME(SecureSocket_FilterPointer)(Dart_NativeArguments args) { 327 void FUNCTION_NAME(SecureSocket_FilterPointer)(Dart_NativeArguments args) {
327 intptr_t filter_pointer = reinterpret_cast<intptr_t>(GetFilter(args)); 328 SSLFilter* filter = GetFilter(args);
329 // This filter pointer is passed to the IO Service thread. The IO Service
330 // thread must Release() the pointer when it is done with it.
331 filter->Retain();
332 intptr_t filter_pointer = reinterpret_cast<intptr_t>(filter);
328 Dart_SetReturnValue(args, Dart_NewInteger(filter_pointer)); 333 Dart_SetReturnValue(args, Dart_NewInteger(filter_pointer));
329 } 334 }
330 335
331 336
332 static void ReleaseCertificate( 337 static void ReleaseCertificate(
333 void* isolate_data, 338 void* isolate_data,
334 Dart_WeakPersistentHandle handle, 339 Dart_WeakPersistentHandle handle,
335 void* context_pointer) { 340 void* context_pointer) {
336 X509* cert = reinterpret_cast<X509*>(context_pointer); 341 X509* cert = reinterpret_cast<X509*>(context_pointer);
337 X509_free(cert); 342 X509_free(cert);
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 * write to the free space and end pointer of input buffers, and read from 1084 * write to the free space and end pointer of input buffers, and read from
1080 * the data space of output buffers, and modify the start pointer. 1085 * the data space of output buffers, and modify the start pointer.
1081 * 1086 *
1082 * When ProcessFilter returns, the Dart thread is responsible for combining 1087 * When ProcessFilter returns, the Dart thread is responsible for combining
1083 * the updated pointers from Dart and C++, to make the new valid state of 1088 * the updated pointers from Dart and C++, to make the new valid state of
1084 * the circular buffer. 1089 * the circular buffer.
1085 */ 1090 */
1086 CObject* SSLFilter::ProcessFilterRequest(const CObjectArray& request) { 1091 CObject* SSLFilter::ProcessFilterRequest(const CObjectArray& request) {
1087 CObjectIntptr filter_object(request[0]); 1092 CObjectIntptr filter_object(request[0]);
1088 SSLFilter* filter = reinterpret_cast<SSLFilter*>(filter_object.Value()); 1093 SSLFilter* filter = reinterpret_cast<SSLFilter*>(filter_object.Value());
1094 RefCntReleaseScope<SSLFilter> rs(filter);
1095
1089 bool in_handshake = CObjectBool(request[1]).Value(); 1096 bool in_handshake = CObjectBool(request[1]).Value();
1090 int starts[SSLFilter::kNumBuffers]; 1097 int starts[SSLFilter::kNumBuffers];
1091 int ends[SSLFilter::kNumBuffers]; 1098 int ends[SSLFilter::kNumBuffers];
1092 for (int i = 0; i < SSLFilter::kNumBuffers; ++i) { 1099 for (int i = 0; i < SSLFilter::kNumBuffers; ++i) {
1093 starts[i] = CObjectInt32(request[2 * i + 2]).Value(); 1100 starts[i] = CObjectInt32(request[2 * i + 2]).Value();
1094 ends[i] = CObjectInt32(request[2 * i + 3]).Value(); 1101 ends[i] = CObjectInt32(request[2 * i + 3]).Value();
1095 } 1102 }
1096 1103
1097 if (filter->ProcessAllBuffers(starts, ends, in_handshake)) { 1104 if (filter->ProcessAllBuffers(starts, ends, in_handshake)) {
1098 CObjectArray* result = new CObjectArray( 1105 CObjectArray* result = new CObjectArray(
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 return bytes_processed; 1685 return bytes_processed;
1679 } 1686 }
1680 1687
1681 } // namespace bin 1688 } // namespace bin
1682 } // namespace dart 1689 } // namespace dart
1683 1690
1684 #endif // defined(TARGET_OS_LINUX) 1691 #endif // defined(TARGET_OS_LINUX)
1685 1692
1686 #endif // !defined(DART_IO_DISABLED) && 1693 #endif // !defined(DART_IO_DISABLED) &&
1687 // !defined(DART_IO_SECURE_SOCKET_DISABLED) 1694 // !defined(DART_IO_SECURE_SOCKET_DISABLED)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698