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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/dart/DartUtilities.h ('k') | Source/bindings/dart/gyp/overrides.gypi » ('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 2011, Google Inc. 1 // Copyright 2011, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 unsigned long result = frame->loader()->loadResourceSynchronously(reques t, DoNotAllowStoredCredentials, error, response, snapshotData); 934 unsigned long result = frame->loader()->loadResourceSynchronously(reques t, DoNotAllowStoredCredentials, error, response, snapshotData);
935 if (result) { 935 if (result) {
936 frame->document()->reportException( 936 frame->document()->reportException(
937 ErrorEvent::create(String("Failed to load snapshot"), String(), 0, 0), 0, NotSharableCrossOrigin); 937 ErrorEvent::create(String("Failed to load snapshot"), String(), 0, 0), 0, NotSharableCrossOrigin);
938 return snapshotBuffer; 938 return snapshotBuffer;
939 } 939 }
940 } 940 }
941 return reinterpret_cast<uint8_t*>(snapshotData.data()); 941 return reinterpret_cast<uint8_t*>(snapshotData.data());
942 } 942 }
943 943
944 Dart_Handle DartUtilities::canonicalizeUrl(Dart_Handle library, Dart_Handle urlH andle, String url)
945 {
946 if (url.startsWith("dart:") || url.startsWith("package:"))
947 return urlHandle;
948
949 Dart_Handle libraryURLHandle = Dart_LibraryUrl(library);
950 ASSERT(!Dart_IsError(libraryURLHandle));
951 String libraryURL = DartUtilities::toString(libraryURLHandle);
952
953 bool packageScheme = false;
954
955 const char* kPackagePrefix = "package:";
956 const int kPackagePrefixLength = strlen(kPackagePrefix);
957
958 const char* kHttpPrefix = "http://";
959 const int kHttpPrefixLength = strlen(kHttpPrefix);
960
961 if (libraryURL.startsWith(kPackagePrefix)) {
962 // KURL has problems concating package:foo/bar (without slashes right af ter colon)
963 // and relative urls. Therefore pretend to be a standard absolute URL.
964 packageScheme = true;
965 libraryURL = kHttpPrefix + libraryURL.substring(kPackagePrefixLength);
966 }
967
968 const KURL canonical = KURL(KURL(KURL(), libraryURL), url);
969 String result = canonical.string();
970 if (packageScheme)
971 result = kPackagePrefix + result.substring(kHttpPrefixLength);
972 return DartUtilities::stringToDartString(result);
973 }
974
975 void DartUtilities::reportProblem(ScriptExecutionContext* context, const String& error)
976 {
977 String sourceURL = context->url().string();
978 // FIXME: Pass in line number and stack trace.
979 if (context && context->isDocument()) {
980 static_cast<Document*>(context)->reportException(ErrorEvent::create(erro r, sourceURL, 0, 0), 0, NotSharableCrossOrigin);
981 }
982 }
983
944 void DartUtilities::reportProblem(ScriptExecutionContext* context, Dart_Handle r esult) 984 void DartUtilities::reportProblem(ScriptExecutionContext* context, Dart_Handle r esult)
945 { 985 {
946 // FIXME: provide sourceURL. 986 // FIXME: provide sourceURL.
947 String sourceURL = "FIXME"; 987 String sourceURL = "FIXME";
948 reportProblem(context, result, sourceURL); 988 reportProblem(context, result, sourceURL);
949 } 989 }
950 990
951 static PassRefPtr<ScriptCallStack> createScriptCallStackFromStackTrace(Dart_Hand le stackTrace, Dart_Handle& exception) { 991 static PassRefPtr<ScriptCallStack> createScriptCallStackFromStackTrace(Dart_Hand le stackTrace, Dart_Handle& exception) {
952 Dart_Handle parsedStackTrace = DartUtilities::invokeUtilsMethod("parseStackT race", 1, &stackTrace); 992 Dart_Handle parsedStackTrace = DartUtilities::invokeUtilsMethod("parseStackT race", 1, &stackTrace);
953 if (!DartUtilities::checkResult(parsedStackTrace, exception)) 993 if (!DartUtilities::checkResult(parsedStackTrace, exception))
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 Dart_PersistentHandle library = domData->htmlLibrary(); 1081 Dart_PersistentHandle library = domData->htmlLibrary();
1042 ASSERT(!Dart_IsError(library)); 1082 ASSERT(!Dart_IsError(library));
1043 1083
1044 Dart_Handle utilsClass = Dart_GetType(library, Dart_NewStringFromCString("_U tils"), 0, 0); 1084 Dart_Handle utilsClass = Dart_GetType(library, Dart_NewStringFromCString("_U tils"), 0, 0);
1045 ASSERT(!Dart_IsError(utilsClass)); 1085 ASSERT(!Dart_IsError(utilsClass));
1046 1086
1047 return Dart_Invoke(utilsClass, Dart_NewStringFromCString(methodName), argCou nt, args); 1087 return Dart_Invoke(utilsClass, Dart_NewStringFromCString(methodName), argCou nt, args);
1048 } 1088 }
1049 1089
1050 } 1090 }
OLDNEW
« 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