| Index: Source/bindings/dart/DartController.cpp
|
| diff --git a/Source/bindings/dart/DartController.cpp b/Source/bindings/dart/DartController.cpp
|
| index 7890130f63e4ac3bdf5df39313e70033bb3914bc..c1f4ffc716d8e3f506711cae8a3cf82daba36c1d 100644
|
| --- a/Source/bindings/dart/DartController.cpp
|
| +++ b/Source/bindings/dart/DartController.cpp
|
| @@ -36,6 +36,7 @@
|
|
|
|
|
| #include "DartDocument.h"
|
| +#include "DartService.h"
|
| #include "DartWindow.h"
|
| #include "HTMLNames.h"
|
| #include "bindings/dart/DartApplicationLoader.h"
|
| @@ -222,16 +223,35 @@ Dart_Isolate DartController::createIsolate(const char* scriptURL, const char* en
|
| return isolate;
|
| }
|
|
|
| +
|
| void DartController::createDOMEnabledIsolateIfNeeded(const String& scriptURL, const String& entryPoint, Document* document)
|
| {
|
| if (m_isolate) {
|
| Dart_EnterIsolate(m_isolate);
|
| return;
|
| }
|
| +
|
| + const bool shouldStartService = !getenv("DARTIUM_VMSERVICE");
|
| +
|
| // FIXME: proper error reporting.
|
| char* errorMessage = 0;
|
| m_isolate = createIsolate(scriptURL.utf8().data(), entryPoint.utf8().data(), document, true, &errorMessage);
|
| ASSERT(m_isolate);
|
| + if (shouldStartService) {
|
| + // createIsolate exits with current isolate set to m_isolate, we need to
|
| + // exit it so we can startup the service.
|
| + Dart_ExitIsolate();
|
| +
|
| + bool r = DartService::Start(document);
|
| + ASSERT(r);
|
| + ASSERT(!Dart_CurrentIsolate());
|
| +
|
| + Dart_EnterIsolate(m_isolate);
|
| + Dart_EnterScope();
|
| + DartService::SendIsolateStartupMessage();
|
| + Dart_ExitScope();
|
| + }
|
| +
|
| }
|
|
|
| void DartController::shutdownIsolate(Dart_Isolate isolate)
|
| @@ -246,6 +266,8 @@ void DartController::shutdownIsolate(Dart_Isolate isolate)
|
| for (DartIsolateDestructionObservers::iterator it = observers->begin(); it != observers->end(); ++it)
|
| (*it)->isolateDestroyed();
|
| Dart_ShutdownIsolate();
|
| + // Stop the service.
|
| + DartService::Stop();
|
| delete domData;
|
| }
|
|
|
| @@ -414,6 +436,12 @@ Dart_Isolate DartController::createPureIsolateCallback(const char* scriptURL, co
|
| Document* document = static_cast<Document*>(context);
|
|
|
| Dart_Isolate isolate = createIsolate(scriptURL, entryPoint, document, false, errorMsg);
|
| + {
|
| + Dart_EnterScope();
|
| + DartService::SendIsolateStartupMessage();
|
| + Dart_ExitScope();
|
| + }
|
| +
|
| if (!isolate) {
|
| // This triggers an exception in the caller.
|
| *errorMsg = strdup("Isolate spawn failed.");
|
| @@ -561,7 +589,7 @@ void DartController::initVMIfNeeded()
|
|
|
| // FIXME(antonm): implement proper shutdown callback.
|
| // FIXME(antonm): implement proper unhandled exception callback.
|
| - Dart_Initialize(&createPureIsolateCallback, 0, 0, 0, openFileCallback, readFileCallback, writeFileCallback, closeFileCallback, generateEntropy);
|
| + Dart_Initialize(&createPureIsolateCallback, 0, 0, DartService::VmServiceShutdownCallback, openFileCallback, readFileCallback, writeFileCallback, closeFileCallback, generateEntropy);
|
| hasBeenInitialized = true;
|
| }
|
|
|
|
|