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

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

Issue 1411853003: Service isolate requests Observatory assets from embedder (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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/dartutils.h ('k') | runtime/bin/gen_snapshot.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) 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 #include "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_tools_api.h" 8 #include "include/dart_tools_api.h"
9 #include "include/dart_native_api.h" 9 #include "include/dart_native_api.h"
10 10
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 const uint8_t* text_buffer = ReadFileFully(filename, &len, &error_msg); 277 const uint8_t* text_buffer = ReadFileFully(filename, &len, &error_msg);
278 if (text_buffer == NULL) { 278 if (text_buffer == NULL) {
279 return Dart_NewApiError(error_msg); 279 return Dart_NewApiError(error_msg);
280 } 280 }
281 Dart_Handle str = Dart_NewStringFromUTF8(text_buffer, len); 281 Dart_Handle str = Dart_NewStringFromUTF8(text_buffer, len);
282 free(const_cast<uint8_t *>(text_buffer)); 282 free(const_cast<uint8_t *>(text_buffer));
283 return str; 283 return str;
284 } 284 }
285 285
286 286
287 Dart_Handle DartUtils::MakeUint8Array(const uint8_t* buffer, intptr_t len) {
288 Dart_Handle array = Dart_NewTypedData(Dart_TypedData_kUint8, len);
289 RETURN_IF_ERROR(array);
290 {
291 Dart_TypedData_Type td_type;
292 void* td_data;
293 intptr_t td_len;
294 Dart_Handle result =
295 Dart_TypedDataAcquireData(array, &td_type, &td_data, &td_len);
296 RETURN_IF_ERROR(result);
297 ASSERT(td_type == Dart_TypedData_kUint8);
298 ASSERT(td_len == len);
299 ASSERT(td_data != NULL);
300 memmove(td_data, buffer, td_len);
301 result = Dart_TypedDataReleaseData(array);
302 RETURN_IF_ERROR(result);
303 }
304 return array;
305 }
306
307
287 Dart_Handle DartUtils::SetWorkingDirectory(Dart_Handle builtin_lib) { 308 Dart_Handle DartUtils::SetWorkingDirectory(Dart_Handle builtin_lib) {
288 Dart_Handle directory = NewString(original_working_directory); 309 Dart_Handle directory = NewString(original_working_directory);
289 return SingleArgDart_Invoke(builtin_lib, "_setWorkingDirectory", directory); 310 return SingleArgDart_Invoke(builtin_lib, "_setWorkingDirectory", directory);
290 } 311 }
291 312
292 313
293 Dart_Handle DartUtils::ResolveUriInWorkingDirectory(Dart_Handle script_uri, 314 Dart_Handle DartUtils::ResolveUriInWorkingDirectory(Dart_Handle script_uri,
294 Dart_Handle builtin_lib) { 315 Dart_Handle builtin_lib) {
295 const int kNumArgs = 1; 316 const int kNumArgs = 1;
296 Dart_Handle dart_args[kNumArgs]; 317 Dart_Handle dart_args[kNumArgs];
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 new CObjectString(CObject::NewString(os_error->message())); 1294 new CObjectString(CObject::NewString(os_error->message()));
1274 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 1295 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1275 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 1296 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
1276 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 1297 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1277 result->SetAt(2, error_message); 1298 result->SetAt(2, error_message);
1278 return result; 1299 return result;
1279 } 1300 }
1280 1301
1281 } // namespace bin 1302 } // namespace bin
1282 } // namespace dart 1303 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/gen_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698