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

Unified Diff: runtime/bin/dartutils.cc

Issue 2004933002: Simplify the canonicalization of dart-ext uris. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/dartutils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/dartutils.cc
diff --git a/runtime/bin/dartutils.cc b/runtime/bin/dartutils.cc
index 02f6016c0b96b871119cde7bf0f55280e9a22928..b7f418b7a7cab7c68bbed5b6373039ae6fb55c26 100644
--- a/runtime/bin/dartutils.cc
+++ b/runtime/bin/dartutils.cc
@@ -180,6 +180,16 @@ bool DartUtils::IsDartBuiltinLibURL(const char* url_name) {
}
+const char* DartUtils::RemoveScheme(const char* url) {
+ const char* colon = strchr(url, ':');
+ if (colon == NULL) {
+ return url;
+ } else {
+ return colon + 1;
+ }
+}
+
+
void* DartUtils::MapExecutable(const char* name, intptr_t* len) {
File* file = File::Open(name, File::kRead);
if (file == NULL) {
@@ -346,12 +356,12 @@ Dart_Handle DartUtils::FilePathFromUri(Dart_Handle script_uri) {
}
-Dart_Handle DartUtils::ExtensionPathFromUri(Dart_Handle extension_uri) {
+Dart_Handle DartUtils::LibraryFilePath(Dart_Handle library_uri) {
const int kNumArgs = 1;
Dart_Handle dart_args[kNumArgs];
- dart_args[0] = extension_uri;
+ dart_args[0] = library_uri;
return Dart_Invoke(DartUtils::BuiltinLib(),
- NewString("_extensionPathFromUri"),
+ NewString("_libraryFilePath"),
kNumArgs,
dart_args);
}
@@ -452,25 +462,18 @@ Dart_Handle DartUtils::LibraryTagHandler(Dart_LibraryTag tag,
if (tag != Dart_kImportTag) {
return NewError("Dart extensions must use import: '%s'", url_string);
}
- Dart_Handle path_parts = DartUtils::ExtensionPathFromUri(url);
- if (Dart_IsError(path_parts)) {
- return path_parts;
- }
-#if defined(DEBUG)
- intptr_t path_parts_length;
- result = Dart_ListLength(path_parts, &path_parts_length);
- if (Dart_IsError(result)) {
- return result;
+ Dart_Handle library_file_path = DartUtils::LibraryFilePath(library_url);
+ const char* lib_path_str = NULL;
+ Dart_StringToCString(library_file_path, &lib_path_str);
+ const char* extension_path = DartUtils::RemoveScheme(url_string);
+ if (strchr(extension_path, '/') != NULL ||
+ (IsWindowsHost() && strchr(extension_path, '\\') != NULL)) {
+ return NewError(
+ "Relative paths for dart extensions are not supported: '%s'",
+ extension_path);
}
- ASSERT(path_parts_length == 2);
-#endif
- const char* extension_directory = NULL;
- Dart_StringToCString(Dart_ListGetAt(path_parts, 0), &extension_directory);
- const char* extension_name = NULL;
- Dart_StringToCString(Dart_ListGetAt(path_parts, 1), &extension_name);
-
- return Extensions::LoadExtension(extension_directory,
- extension_name,
+ return Extensions::LoadExtension(lib_path_str,
+ extension_path,
library);
}
« no previous file with comments | « runtime/bin/dartutils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698