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

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

Issue 2068833002: Change Dart_DefaultCanonicalizeUrl to accept the library url string instead of a library, this is u… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address-code-review-comments Created 4 years, 6 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/dartutils.cc ('k') | runtime/include/dart_api.h » ('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 5
6 #include "bin/loader.h" 6 #include "bin/loader.h"
7 7
8 #include "bin/builtin.h" 8 #include "bin/builtin.h"
9 #include "bin/dartutils.h" 9 #include "bin/dartutils.h"
10 #include "bin/extensions.h" 10 #include "bin/extensions.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 snapshot_uri); 355 snapshot_uri);
356 // Destroy the loader. The destructor does a bunch of leg work. 356 // Destroy the loader. The destructor does a bunch of leg work.
357 delete loader; 357 delete loader;
358 } 358 }
359 359
360 360
361 Dart_Handle Loader::LibraryTagHandler(Dart_LibraryTag tag, 361 Dart_Handle Loader::LibraryTagHandler(Dart_LibraryTag tag,
362 Dart_Handle library, 362 Dart_Handle library,
363 Dart_Handle url) { 363 Dart_Handle url) {
364 if (tag == Dart_kCanonicalizeUrl) { 364 if (tag == Dart_kCanonicalizeUrl) {
365 return Dart_DefaultCanonicalizeUrl(library, url); 365 Dart_Handle library_url = Dart_LibraryUrl(library);
366 if (Dart_IsError(library_url)) {
367 return library_url;
368 }
369 return Dart_DefaultCanonicalizeUrl(library_url, url);
366 } 370 }
367 const char* url_string = NULL; 371 const char* url_string = NULL;
368 Dart_Handle result = Dart_StringToCString(url, &url_string); 372 Dart_Handle result = Dart_StringToCString(url, &url_string);
369 if (Dart_IsError(result)) { 373 if (Dart_IsError(result)) {
370 return result; 374 return result;
371 } 375 }
372 376
373 // Special case for handling dart: imports and parts. 377 // Special case for handling dart: imports and parts.
374 if (tag != Dart_kScriptTag) { 378 if (tag != Dart_kScriptTag) {
375 // Grab the library's url. 379 // Grab the library's url.
376 Dart_Handle library_url = Dart_LibraryUrl(library); 380 Dart_Handle library_url = Dart_LibraryUrl(library);
381 if (Dart_IsError(library_url)) {
382 return library_url;
383 }
377 const char* library_url_string = NULL; 384 const char* library_url_string = NULL;
378 result = Dart_StringToCString(library_url, &library_url_string); 385 result = Dart_StringToCString(library_url, &library_url_string);
379 if (Dart_IsError(result)) { 386 if (Dart_IsError(result)) {
380 return result; 387 return result;
381 } 388 }
382 389
383 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string); 390 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string);
384 bool is_dart_library = DartUtils::IsDartSchemeURL(library_url_string); 391 bool is_dart_library = DartUtils::IsDartSchemeURL(library_url_string);
385 392
386 if (is_dart_scheme_url || is_dart_library) { 393 if (is_dart_scheme_url || is_dart_library) {
387 return DartColonLibraryTagHandler(tag, 394 return DartColonLibraryTagHandler(tag,
388 library, 395 library,
389 url, 396 url,
390 library_url_string, 397 library_url_string,
391 url_string); 398 url_string);
392 } 399 }
393 } 400 }
394 401
395 if (DartUtils::IsDartExtensionSchemeURL(url_string)) { 402 if (DartUtils::IsDartExtensionSchemeURL(url_string)) {
396 // Load a native code shared library to use in a native extension 403 // Load a native code shared library to use in a native extension
397 if (tag != Dart_kImportTag) { 404 if (tag != Dart_kImportTag) {
398 return DartUtils::NewError("Dart extensions must use import: '%s'", 405 return DartUtils::NewError("Dart extensions must use import: '%s'",
399 url_string); 406 url_string);
400 } 407 }
401 Dart_Handle library_url = Dart_LibraryUrl(library); 408 Dart_Handle library_url = Dart_LibraryUrl(library);
409 if (Dart_IsError(library_url)) {
410 return library_url;
411 }
402 Dart_Handle library_file_path = DartUtils::LibraryFilePath(library_url); 412 Dart_Handle library_file_path = DartUtils::LibraryFilePath(library_url);
403 const char* lib_path_str = NULL; 413 const char* lib_path_str = NULL;
404 Dart_StringToCString(library_file_path, &lib_path_str); 414 Dart_StringToCString(library_file_path, &lib_path_str);
405 const char* extension_path = DartUtils::RemoveScheme(url_string); 415 const char* extension_path = DartUtils::RemoveScheme(url_string);
406 if (strchr(extension_path, '/') != NULL || 416 if (strchr(extension_path, '/') != NULL ||
407 (IsWindowsHost() && strchr(extension_path, '\\') != NULL)) { 417 (IsWindowsHost() && strchr(extension_path, '\\') != NULL)) {
408 return DartUtils::NewError( 418 return DartUtils::NewError(
409 "Relative paths for dart extensions are not supported: '%s'", 419 "Relative paths for dart extensions are not supported: '%s'",
410 extension_path); 420 extension_path);
411 } 421 }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 MutexLocker ml(&loader_infos_lock_); 625 MutexLocker ml(&loader_infos_lock_);
616 Loader* loader = LoaderForLocked(dest_port_id); 626 Loader* loader = LoaderForLocked(dest_port_id);
617 if (loader == NULL) { 627 if (loader == NULL) {
618 return; 628 return;
619 } 629 }
620 loader->QueueMessage(message); 630 loader->QueueMessage(message);
621 } 631 }
622 632
623 } // namespace bin 633 } // namespace bin
624 } // namespace dart 634 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | runtime/include/dart_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698