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

Side by Side Diff: runtime/bin/secure_socket_macos.h

Issue 1845273004: Allows adding trusted certs on iOS. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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
« no previous file with comments | « runtime/bin/secure_socket_ios.cc ('k') | runtime/bin/secure_socket_macos.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 (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 #ifndef BIN_SECURE_SOCKET_MACOS_H_ 5 #ifndef BIN_SECURE_SOCKET_MACOS_H_
6 #define BIN_SECURE_SOCKET_MACOS_H_ 6 #define BIN_SECURE_SOCKET_MACOS_H_
7 7
8 #if !defined(BIN_SECURE_SOCKET_H_) 8 #if !defined(BIN_SECURE_SOCKET_H_)
9 #error Do not include secure_socket_macos.h directly. Use secure_socket.h. 9 #error Do not include secure_socket_macos.h directly. Use secure_socket.h.
10 #endif 10 #endif
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 Dart_PersistentHandle bad_certificate_callback_; 136 Dart_PersistentHandle bad_certificate_callback_;
137 bool in_handshake_; 137 bool in_handshake_;
138 bool connected_; 138 bool connected_;
139 bool bad_cert_; 139 bool bad_cert_;
140 bool is_server_; 140 bool is_server_;
141 char* hostname_; 141 char* hostname_;
142 142
143 DISALLOW_COPY_AND_ASSIGN(SSLFilter); 143 DISALLOW_COPY_AND_ASSIGN(SSLFilter);
144 }; 144 };
145 145
146 // Where the argument to the constructor is the handle for an object
147 // implementing List<int>, this class creates a scope in which the memory
148 // backing the list can be accessed.
149 //
150 // Do not make Dart_ API calls while in a ScopedMemBuffer.
151 // Do not call Dart_PropagateError while in a ScopedMemBuffer.
152 class ScopedMemBuffer {
153 public:
154 explicit ScopedMemBuffer(Dart_Handle object) {
155 if (!Dart_IsTypedData(object) && !Dart_IsList(object)) {
156 Dart_ThrowException(DartUtils::NewDartArgumentError(
157 "Argument is not a List<int>"));
158 }
159
160 uint8_t* bytes = NULL;
161 intptr_t bytes_len = 0;
162 bool is_typed_data = false;
163 if (Dart_IsTypedData(object)) {
164 is_typed_data = true;
165 Dart_TypedData_Type typ;
166 ThrowIfError(Dart_TypedDataAcquireData(
167 object,
168 &typ,
169 reinterpret_cast<void**>(&bytes),
170 &bytes_len));
171 } else {
172 ASSERT(Dart_IsList(object));
173 ThrowIfError(Dart_ListLength(object, &bytes_len));
174 bytes = Dart_ScopeAllocate(bytes_len);
175 ASSERT(bytes != NULL);
176 ThrowIfError(Dart_ListGetAsBytes(object, 0, bytes, bytes_len));
177 }
178
179 object_ = object;
180 bytes_ = bytes;
181 bytes_len_ = bytes_len;
182 is_typed_data_ = is_typed_data;
183 }
184
185 ~ScopedMemBuffer() {
186 if (is_typed_data_) {
187 ThrowIfError(Dart_TypedDataReleaseData(object_));
188 }
189 }
190
191 uint8_t* get() const { return bytes_; }
192 intptr_t length() const { return bytes_len_; }
193
194 private:
195 Dart_Handle object_;
196 uint8_t* bytes_;
197 intptr_t bytes_len_;
198 bool is_typed_data_;
199
200 DISALLOW_ALLOCATION();
201 DISALLOW_COPY_AND_ASSIGN(ScopedMemBuffer);
202 };
203
146 } // namespace bin 204 } // namespace bin
147 } // namespace dart 205 } // namespace dart
148 206
149 #endif // BIN_SECURE_SOCKET_MACOS_H_ 207 #endif // BIN_SECURE_SOCKET_MACOS_H_
OLDNEW
« no previous file with comments | « runtime/bin/secure_socket_ios.cc ('k') | runtime/bin/secure_socket_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698