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

Side by Side Diff: Source/bindings/dart/DartApplicationLoader.cpp

Issue 26540002: Don't run main if library failed to import (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009, Google Inc. 1 // Copyright (c) 2009, 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // DartDOMData::current()->applicationLoader() may be 0 at this point. 94 // DartDOMData::current()->applicationLoader() may be 0 at this point.
95 return DartUtilities::canonicalizeUrl(library, urlHandle, url); 95 return DartUtilities::canonicalizeUrl(library, urlHandle, url);
96 } 96 }
97 97
98 ASSERT(DartDOMData::current()->applicationLoader()); 98 ASSERT(DartDOMData::current()->applicationLoader());
99 return DartDOMData::current()->applicationLoader()->libraryTagHandler(tag, l ibrary, urlHandle, url); 99 return DartDOMData::current()->applicationLoader()->libraryTagHandler(tag, l ibrary, urlHandle, url);
100 } 100 }
101 101
102 Dart_Handle DartApplicationLoader::libraryTagHandler(Dart_LibraryTag tag, Dart_H andle library, Dart_Handle urlHandle, String url) 102 Dart_Handle DartApplicationLoader::libraryTagHandler(Dart_LibraryTag tag, Dart_H andle library, Dart_Handle urlHandle, String url)
103 { 103 {
104 ASSERT(m_asyncLoader->contains(url)); 104 if (!m_asyncLoader->contains(url)) {
105 scriptLoadError(url);
106 return Dart_NewBoolean(false);
107 }
108
105 const String& source = m_asyncLoader->get(url); 109 const String& source = m_asyncLoader->get(url);
106 110
107 Dart_Handle import; 111 Dart_Handle import;
108 if (tag == Dart_kImportTag) { 112 if (tag == Dart_kImportTag) {
109 import = Dart_LoadLibrary(DartUtilities::stringToDartString(url), DartUt ilities::convertSourceString(source)); 113 import = Dart_LoadLibrary(DartUtilities::stringToDartString(url), DartUt ilities::convertSourceString(source));
110 } else if (tag == Dart_kSourceTag) { 114 } else if (tag == Dart_kSourceTag) {
111 import = Dart_LoadSource(library, DartUtilities::stringToDartString(url) , DartUtilities::convertSourceString(source)); 115 import = Dart_LoadSource(library, DartUtilities::stringToDartString(url) , DartUtilities::convertSourceString(source));
112 } else { 116 } else {
113 ASSERT_NOT_REACHED(); 117 ASSERT_NOT_REACHED();
118 m_scriptHasError = true;
114 DartUtilities::reportProblem(m_originDocument, "Invalid import tag"); 119 DartUtilities::reportProblem(m_originDocument, "Invalid import tag");
115 return Dart_NewBoolean(false); 120 return Dart_NewBoolean(false);
116 } 121 }
117 122
118 if (Dart_IsError(import)) { 123 if (Dart_IsError(import)) {
119 reportDartError(import); 124 reportDartError(import);
120 return Dart_NewBoolean(false); 125 return Dart_NewBoolean(false);
121 } 126 }
122 127
123 return Dart_NewBoolean(true); 128 return Dart_NewBoolean(true);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 258
254 Dart_Handle DartApplicationLoader::topLevelLibrary() 259 Dart_Handle DartApplicationLoader::topLevelLibrary()
255 { 260 {
256 Dart_Handle library = Dart_LookupLibrary(DartUtilities::stringToDartString(m _libraryUrl)); 261 Dart_Handle library = Dart_LookupLibrary(DartUtilities::stringToDartString(m _libraryUrl));
257 ASSERT(!Dart_IsError(library)); 262 ASSERT(!Dart_IsError(library));
258 return library; 263 return library;
259 } 264 }
260 265
261 void DartApplicationLoader::scriptLoadError(String failedUrl) 266 void DartApplicationLoader::scriptLoadError(String failedUrl)
262 { 267 {
268 m_scriptHasError = true;
263 // FIXME: try to dig out line number, -1 for now. 269 // FIXME: try to dig out line number, -1 for now.
264 if (failedUrl.startsWith(String("dart:"))) { 270 if (failedUrl.startsWith(String("dart:"))) {
265 m_originDocument->logExceptionToConsole(String("The built-in library '") + failedUrl + String("' is not available on Dartium."), m_libraryUrl, -1, 0, 0) ; 271 m_originDocument->logExceptionToConsole(String("The built-in library '") + failedUrl + String("' is not available on Dartium."), m_libraryUrl, -1, 0, 0) ;
266 } else { 272 } else {
267 m_originDocument->logExceptionToConsole(String("Failed to load a file ") + failedUrl, m_libraryUrl, -1, 0, 0); 273 m_originDocument->logExceptionToConsole(String("Failed to load a file ") + failedUrl, m_libraryUrl, -1, 0, 0);
268 } 274 }
269 m_errorEventDispatcher->dispatchErrorEvent(); 275 m_errorEventDispatcher->dispatchErrorEvent();
270 } 276 }
271 277
272 } 278 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698