| 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 patches.append(htmlPatch); | 383 patches.append(htmlPatch); |
| 384 | 384 |
| 385 JsInterop::initializeJsInterop(DartDOMData::current(), patches, exception); | 385 JsInterop::initializeJsInterop(DartDOMData::current(), patches, exception); |
| 386 ASSERT(!exception); | 386 ASSERT(!exception); |
| 387 } | 387 } |
| 388 | 388 |
| 389 void DartApplicationLoader::callEntryPoint() | 389 void DartApplicationLoader::callEntryPoint() |
| 390 { | 390 { |
| 391 RELEASE_ASSERT(m_state == Ready); | 391 RELEASE_ASSERT(m_state == Ready); |
| 392 | 392 |
| 393 Timeline timeline(m_originDocument->frame(), String("callEntryPoint@") + m_s
criptUrlString); | |
| 394 | |
| 395 if (m_domEnabled) { | 393 if (m_domEnabled) { |
| 396 Vector<InteropPatchFile> patches; | 394 Vector<InteropPatchFile> patches; |
| 397 uint8_t* buffer; | 395 uint8_t* buffer; |
| 398 intptr_t size = 0; | 396 intptr_t size = 0; |
| 399 uint8_t* script_snapshot = NULL; | 397 uint8_t* script_snapshot = NULL; |
| 400 // Unfortunately we need to execute JsInterop::buildInteropPatchFiles be
fore calling | 398 // Unfortunately we need to execute JsInterop::buildInteropPatchFiles be
fore calling |
| 401 // Dart_FinalizeLoading but buildInteropPatchFiles requires Dart_Finaliz
eLoading | 399 // Dart_FinalizeLoading but buildInteropPatchFiles requires Dart_Finaliz
eLoading |
| 402 // to be called so we create a copy of the current isolate and execute t
he method | 400 // to be called so we create a copy of the current isolate and execute t
he method |
| 403 // in that isolate before applying the patch file to the application iso
late. | 401 // in that isolate before applying the patch file to the application iso
late. |
| 404 | 402 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 417 // unable to create the isolat e | 415 // unable to create the isolat e |
| 418 initializePlaceholderInteropClasses(); | 416 initializePlaceholderInteropClasses(); |
| 419 } else { | 417 } else { |
| 420 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); | 418 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); |
| 421 memmove(script_snapshot, buffer, size); | 419 memmove(script_snapshot, buffer, size); |
| 422 | 420 |
| 423 Dart_Isolate applicationIsolate = Dart_CurrentIsolate(); | 421 Dart_Isolate applicationIsolate = Dart_CurrentIsolate(); |
| 424 Dart_ExitIsolate(); | 422 Dart_ExitIsolate(); |
| 425 | 423 |
| 426 char* err = 0; | 424 char* err = 0; |
| 427 Dart_Isolate ALLOW_UNUSED isolate = DartController::createIsolate("j
s_interop_codegen_isolate", NULL, NULL, NULL, NULL, false, &err); | 425 Dart_Isolate isolate = DartController::createIsolate("js_interop_cod
egen_isolate", NULL, NULL, NULL, NULL, false, &err); |
| 426 ALLOW_UNUSED_LOCAL(isolate); |
| 428 { | 427 { |
| 429 ASSERT(!err); | 428 ASSERT(!err); |
| 430 ASSERT(Dart_CurrentIsolate() == isolate); | 429 ASSERT(Dart_CurrentIsolate() == isolate); |
| 431 DartApiScope apiScope; | 430 DartApiScope apiScope; |
| 432 result = Dart_LoadScriptFromSnapshot(script_snapshot, size); | 431 result = Dart_LoadScriptFromSnapshot(script_snapshot, size); |
| 433 ASSERT(!Dart_IsError(result)); | 432 ASSERT(!Dart_IsError(result)); |
| 434 Dart_FinalizeLoading(false); | 433 Dart_FinalizeLoading(false); |
| 435 Dart_Handle exception = 0; | 434 Dart_Handle exception = 0; |
| 436 JsInterop::buildInteropPatchFiles(DartDOMData::current(), &patch
es, exception); | 435 JsInterop::buildInteropPatchFiles(DartDOMData::current(), &patch
es, exception); |
| 437 if (exception) { | 436 if (exception) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 464 JsInterop::initializeJsInterop(domData, patches, exception); | 463 JsInterop::initializeJsInterop(domData, patches, exception); |
| 465 } | 464 } |
| 466 if (exception) { | 465 if (exception) { |
| 467 DartUtilities::reportProblem(m_originDocument, exception, m_scri
ptUrlString); | 466 DartUtilities::reportProblem(m_originDocument, exception, m_scri
ptUrlString); |
| 468 } | 467 } |
| 469 | 468 |
| 470 m_state = Running; | 469 m_state = Running; |
| 471 | 470 |
| 472 logObservatoryInformation(); | 471 logObservatoryInformation(); |
| 473 { | 472 { |
| 474 Timeline timeline(m_originDocument->frame(), String("notifyDebug
Server@") + m_scriptUrlString); | |
| 475 DartScriptDebugServer::shared().registerIsolate(Dart_CurrentIsol
ate(), m_originDocument->page()); | 473 DartScriptDebugServer::shared().registerIsolate(Dart_CurrentIsol
ate(), m_originDocument->page()); |
| 476 DartScriptDebugServer::shared().isolateLoaded(); | 474 DartScriptDebugServer::shared().isolateLoaded(); |
| 477 } | 475 } |
| 478 | 476 |
| 479 // FIXME: Settle on proper behavior here. We have not determined exa
ctly when | 477 // FIXME: Settle on proper behavior here. We have not determined exa
ctly when |
| 480 // or how often we'll call the entry point. | 478 // or how often we'll call the entry point. |
| 481 Dart_Handle entryPoint = Dart_NewStringFromCString("main"); | 479 Dart_Handle entryPoint = Dart_NewStringFromCString("main"); |
| 482 Dart_Handle main = Dart_LookupFunction(trampoline, entryPoint); | 480 Dart_Handle main = Dart_LookupFunction(trampoline, entryPoint); |
| 483 if (!Dart_IsNull(main)) { | 481 if (!Dart_IsNull(main)) { |
| 484 // FIXME: Avoid relooking up main. | 482 // FIXME: Avoid relooking up main. |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 | 768 |
| 771 void DartApplicationLoader::reportError(const String& error, const String& url) | 769 void DartApplicationLoader::reportError(const String& error, const String& url) |
| 772 { | 770 { |
| 773 if (m_state < Running) | 771 if (m_state < Running) |
| 774 m_state = Error; | 772 m_state = Error; |
| 775 m_loadCallback->reportError(error, url); | 773 m_loadCallback->reportError(error, url); |
| 776 } | 774 } |
| 777 | 775 |
| 778 | 776 |
| 779 } | 777 } |
| OLD | NEW |