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

Unified Diff: Source/bindings/core/dart/DartNativeUtilities.cpp

Issue 2543703003: Added setting up VMLibraryHooks for Dartium to support resolvePageUri (Closed)
Patch Set: Incorporated Siva suggestion Created 3 years, 11 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 | « Source/bindings/core/dart/DartNativeUtilities.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/dart/DartNativeUtilities.cpp
diff --git a/Source/bindings/core/dart/DartNativeUtilities.cpp b/Source/bindings/core/dart/DartNativeUtilities.cpp
index ca1d153bed8e22458cbb08edd9a8a157f4510bbe..cad165a2e5fbc11b78cc5308a45b6b3baaa18269 100644
--- a/Source/bindings/core/dart/DartNativeUtilities.cpp
+++ b/Source/bindings/core/dart/DartNativeUtilities.cpp
@@ -155,6 +155,40 @@ fail:
ASSERT_NOT_REACHED();
}
+void resolveUri(Dart_NativeArguments args)
+{
+ Dart_Handle exception = 0;
+ {
+ DartDOMData* domData = static_cast<DartDOMData*>(Dart_GetNativeIsolateData(args));
+ RefPtr<blink::DartApplicationLoader> loader = domData->applicationLoader();
+
+ Dart_Handle uriArg = Dart_GetNativeArgument(args, 0);
+ Dart_Handle uriAsString = Dart_Invoke(uriArg, Dart_NewStringFromCString("toString"), 0, NULL);
+ DartStringAdapter uri = DartUtilities::dartToString(uriAsString, exception);
+ if (exception)
+ goto fail;
+ String uriString = (String)uri;
+
+ String resolvedUrl = DartApplicationLoader::resolveUrl(loader->scriptUrl(), uriString, loader->packageRoot());
+
+ Dart_Handle constructorArg = DartUtilities::stringToDartString(resolvedUrl);
+
+ // Call the Uri.File constructor to create a Uri from the uri string returned from DartApplicationLoader's
+ // resolveUrl.
+ Dart_Handle coreLib = Dart_LookupLibrary(Dart_NewStringFromCString("dart:core"));
+ Dart_Handle uriClass = Dart_GetType(coreLib, Dart_NewStringFromCString("Uri"), 0, 0);
+ Dart_Handle ret = Dart_New(uriClass, Dart_NewStringFromCString("file"), 1, &constructorArg);
+
+ Dart_SetReturnValue(args, ret);
+
+ return;
+ }
+
+fail:
+ Dart_ThrowException(exception);
+ ASSERT_NOT_REACHED();
+}
+
class SpawnDomFunctionTask : public ExecutionContextTask {
public:
SpawnDomFunctionTask(const char* libraryUrl, const char* functionName, Dart_Port replyTo, DartDOMData* parentDOMData)
@@ -261,6 +295,7 @@ static DartNativeEntry nativeEntries[] = {
{ DartNativeUtilitiesInternal::forwardingPrint, 1, "Utils_forwardingPrint" },
{ DartNativeUtilitiesInternal::getNewIsolateId, 0, "Utils_getNewIsolateId" },
{ DartNativeUtilitiesInternal::spawnDomUri, 1, "Utils_spawnDomUri" },
+ { DartNativeUtilitiesInternal::resolveUri, 1, "Utils_resolvePackageUri" },
{ 0, 0, 0 },
};
« no previous file with comments | « Source/bindings/core/dart/DartNativeUtilities.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698