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

Unified Diff: Source/bindings/dart/DartUtilities.cpp

Issue 26490003: Reapply "Move isolate loading to a separate loader isolate." (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Initialize flag properly Created 7 years, 2 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/dart/DartUtilities.h ('k') | Source/bindings/dart/gyp/overrides.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/dart/DartUtilities.cpp
diff --git a/Source/bindings/dart/DartUtilities.cpp b/Source/bindings/dart/DartUtilities.cpp
index dfa636ea1a4c963f4f3a190ae08181a1e34fbc6f..99508573306e3ed8719d254eee05ae6a70c5c86c 100644
--- a/Source/bindings/dart/DartUtilities.cpp
+++ b/Source/bindings/dart/DartUtilities.cpp
@@ -941,6 +941,46 @@ const uint8_t* DartUtilities::fullSnapshot(Frame* frame)
return reinterpret_cast<uint8_t*>(snapshotData.data());
}
+Dart_Handle DartUtilities::canonicalizeUrl(Dart_Handle library, Dart_Handle urlHandle, String url)
+{
+ if (url.startsWith("dart:") || url.startsWith("package:"))
+ return urlHandle;
+
+ Dart_Handle libraryURLHandle = Dart_LibraryUrl(library);
+ ASSERT(!Dart_IsError(libraryURLHandle));
+ String libraryURL = DartUtilities::toString(libraryURLHandle);
+
+ bool packageScheme = false;
+
+ const char* kPackagePrefix = "package:";
+ const int kPackagePrefixLength = strlen(kPackagePrefix);
+
+ const char* kHttpPrefix = "http://";
+ const int kHttpPrefixLength = strlen(kHttpPrefix);
+
+ if (libraryURL.startsWith(kPackagePrefix)) {
+ // KURL has problems concating package:foo/bar (without slashes right after colon)
+ // and relative urls. Therefore pretend to be a standard absolute URL.
+ packageScheme = true;
+ libraryURL = kHttpPrefix + libraryURL.substring(kPackagePrefixLength);
+ }
+
+ const KURL canonical = KURL(KURL(KURL(), libraryURL), url);
+ String result = canonical.string();
+ if (packageScheme)
+ result = kPackagePrefix + result.substring(kHttpPrefixLength);
+ return DartUtilities::stringToDartString(result);
+}
+
+void DartUtilities::reportProblem(ScriptExecutionContext* context, const String& error)
+{
+ String sourceURL = context->url().string();
+ // FIXME: Pass in line number and stack trace.
+ if (context && context->isDocument()) {
+ static_cast<Document*>(context)->reportException(ErrorEvent::create(error, sourceURL, 0, 0), 0, NotSharableCrossOrigin);
+ }
+}
+
void DartUtilities::reportProblem(ScriptExecutionContext* context, Dart_Handle result)
{
// FIXME: provide sourceURL.
« no previous file with comments | « Source/bindings/dart/DartUtilities.h ('k') | Source/bindings/dart/gyp/overrides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698