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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 2011543002: Canonicalize uris in C++ instead of Dart for the standalone embedder. (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
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index eed7789bca86aae03f9e07c088014a73247366f0..aa65f987b15bd7994d5a720f9ea3e7cf52210fc0 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -42,6 +42,7 @@
#include "vm/timeline.h"
#include "vm/timer.h"
#include "vm/unicode.h"
+#include "vm/uri.h"
#include "vm/verifier.h"
#include "vm/version.h"
@@ -5148,6 +5149,31 @@ DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler(
}
+DART_EXPORT Dart_Handle Dart_DefaultCanonicalizeUrl(Dart_Handle library,
+ Dart_Handle url) {
+ API_TIMELINE_DURATION;
+ DARTSCOPE(Thread::Current());
+ CHECK_CALLBACK_STATE(T);
+
+ const Library& lib = Api::UnwrapLibraryHandle(Z, library);
+ if (lib.IsNull()) {
+ RETURN_TYPE_ERROR(Z, library, Library);
+ }
+ const String& uri = Api::UnwrapStringHandle(Z, url);
+ if (uri.IsNull()) {
+ RETURN_TYPE_ERROR(Z, url, String);
+ }
+
+ const String& lib_uri = String::Handle(Z, lib.url());
+ const char* resolved_uri;
ahe 2016/05/25 12:44:52 I don't understand how memory is managed for this.
Florian Schneider 2016/05/26 14:09:45 The string is in zone-allocated memory.
+ if (!ResolveUri(uri.ToCString(), lib_uri.ToCString(), &resolved_uri)) {
+ return Api::NewError("%s: Unable to canonicalize uri '%s'.",
+ CURRENT_FUNC, uri.ToCString());
+ }
+ return Api::NewHandle(T, String::New(resolved_uri));
+}
+
+
// NOTE: Need to pass 'result' as a parameter here in order to avoid
// warning: variable 'result' might be clobbered by 'longjmp' or 'vfork'
// which shows up because of the use of setjmp.

Powered by Google App Engine
This is Rietveld 408576698