Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 if (completeFutures && m_domEnabled) { | 365 if (completeFutures && m_domEnabled) { |
| 366 // Call this after Dart_FinalizeLoading so that everything is ready. | 366 // Call this after Dart_FinalizeLoading so that everything is ready. |
| 367 DartScriptDebugServer::shared().deferredReady(); | 367 DartScriptDebugServer::shared().deferredReady(); |
| 368 } | 368 } |
| 369 | 369 |
| 370 } | 370 } |
| 371 // Invoke the entry point on the main script URL if it has not yet been | 371 // Invoke the entry point on the main script URL if it has not yet been |
| 372 // invoked. | 372 // invoked. |
| 373 if (m_state == Ready) { | 373 if (m_state == Ready) { |
| 374 // Call the entry point on the main script URL. | 374 // Call the entry point on the main script URL. |
| 375 setupVMLibraryHooks(); | |
| 375 callEntryPoint(); | 376 callEntryPoint(); |
| 376 } | 377 } |
| 377 } | 378 } |
| 378 | 379 |
| 379 void DartApplicationLoader::initializePlaceholderInteropClasses() | 380 void DartApplicationLoader::initializePlaceholderInteropClasses() |
| 380 { | 381 { |
| 381 // Generate a stub patch for JsObjectImpl for non-DOM isolates to avoid | 382 // Generate a stub patch for JsObjectImpl for non-DOM isolates to avoid |
| 382 // warnings about missing classes. | 383 // warnings about missing classes. |
| 383 DartApiScope apiScope; | 384 DartApiScope apiScope; |
| 384 | 385 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 509 } | 510 } |
| 510 } | 511 } |
| 511 | 512 |
| 512 Dart_Handle DartApplicationLoader::topLevelLibrary() | 513 Dart_Handle DartApplicationLoader::topLevelLibrary() |
| 513 { | 514 { |
| 514 Dart_Handle library = Dart_LookupLibrary(DartUtilities::safeStringToDartStri ng(m_scriptUrlString)); | 515 Dart_Handle library = Dart_LookupLibrary(DartUtilities::safeStringToDartStri ng(m_scriptUrlString)); |
| 515 RELEASE_ASSERT(!Dart_IsError(library)); | 516 RELEASE_ASSERT(!Dart_IsError(library)); |
| 516 return library; | 517 return library; |
| 517 } | 518 } |
| 518 | 519 |
| 520 void DartApplicationLoader::setupVMLibraryHooks() | |
| 521 { | |
| 522 Dart_Handle builtin_library = Dart_LookupLibrary(Dart_NewStringFromCString(" dart:_builtin")); | |
| 523 RELEASE_ASSERT(!Dart_IsError(builtin_library)); | |
|
siva
2017/01/06 21:39:33
Wouldn't need this library if the setup code was a
| |
| 524 | |
| 525 // Call Dartium version of _setupHooks to configure VMLibraryHooks. | |
| 526 Dart_Handle dartium_setup_class = Dart_GetType(builtin_library, Dart_NewStri ngFromCString("DartiumSetup"), 0, 0); | |
| 527 RELEASE_ASSERT(!Dart_IsError(dartium_setup_class)); | |
| 528 Dart_Handle result = Dart_Invoke(dartium_setup_class, Dart_NewStringFromCStr ing("_setupHooks"), 0, NULL); | |
| 529 if (Dart_IsError(result)) { | |
| 530 reportError("Unable to invoke _setupHooks", "dart:_builtin"); | |
| 531 } | |
| 532 } | |
| 533 | |
| 534 | |
| 519 void DartApplicationLoader::findDependences(const String& url, const String& sou rce, intptr_t lineNumber) | 535 void DartApplicationLoader::findDependences(const String& url, const String& sou rce, intptr_t lineNumber) |
| 520 { | 536 { |
| 521 ASSERT(m_pendingLibraries.contains(url) || m_pendingSource.contains(url)); | 537 ASSERT(m_pendingLibraries.contains(url) || m_pendingSource.contains(url)); |
| 522 | 538 |
| 523 DartIsolateScope isolateScope(m_isolate); | 539 DartIsolateScope isolateScope(m_isolate); |
| 524 DartApiScope dartApiScope; | 540 DartApiScope dartApiScope; |
| 525 | 541 |
| 526 if (m_pendingLibraries.contains(url)) { | 542 if (m_pendingLibraries.contains(url)) { |
| 527 processLibrary(url, source, lineNumber); | 543 processLibrary(url, source, lineNumber); |
| 528 } else { | 544 } else { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 755 m_scriptResource->removeClient(this); | 771 m_scriptResource->removeClient(this); |
| 756 delete this; | 772 delete this; |
| 757 } | 773 } |
| 758 | 774 |
| 759 private: | 775 private: |
| 760 String m_url; | 776 String m_url; |
| 761 RefPtr<DartApplicationLoader> m_loader; | 777 RefPtr<DartApplicationLoader> m_loader; |
| 762 ResourcePtr<ScriptResource> m_scriptResource; | 778 ResourcePtr<ScriptResource> m_scriptResource; |
| 763 }; | 779 }; |
| 764 | 780 |
| 765 static String resolveUrl(String mainLibraryURL, const String& url, const String& packageRootOverride) | 781 String DartApplicationLoader::resolveUrl(String mainLibraryURL, const String& ur l, const String& packageRootOverride) |
| 766 { | 782 { |
| 767 if (!url.startsWith("package:") || url.startsWith("package://")) | 783 if (!url.startsWith("package:") || url.startsWith("package://")) |
| 768 return url; | 784 return url; |
| 769 | 785 |
| 770 String packageRoot; | 786 String packageRoot; |
| 771 String packageUrl; | 787 String packageUrl; |
| 772 if (!packageRootOverride.isNull()) { | 788 if (!packageRootOverride.isNull()) { |
| 773 // Resolve with respect to the override. Append a | 789 // Resolve with respect to the override. Append a |
| 774 // slash to ensure that resolution is against this | 790 // slash to ensure that resolution is against this |
| 775 // path and not its parent. | 791 // path and not its parent. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 853 | 869 |
| 854 void DartApplicationLoader::reportError(const String& error, const String& url) | 870 void DartApplicationLoader::reportError(const String& error, const String& url) |
| 855 { | 871 { |
| 856 if (m_state < Running) | 872 if (m_state < Running) |
| 857 m_state = Error; | 873 m_state = Error; |
| 858 m_loadCallback->reportError(error, url); | 874 m_loadCallback->reportError(error, url); |
| 859 } | 875 } |
| 860 | 876 |
| 861 | 877 |
| 862 } | 878 } |
| OLD | NEW |