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 18 matching lines...) Expand all Loading... | |
| 29 | 29 |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "bindings/dart/DartController.h" | 31 #include "bindings/dart/DartController.h" |
| 32 | 32 |
| 33 #if OS(ANDROID) | 33 #if OS(ANDROID) |
| 34 #include <sys/system_properties.h> | 34 #include <sys/system_properties.h> |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 | 37 |
| 38 #include "DartDocument.h" | 38 #include "DartDocument.h" |
| 39 #include "DartService.h" | |
| 39 #include "DartWindow.h" | 40 #include "DartWindow.h" |
| 40 #include "HTMLNames.h" | 41 #include "HTMLNames.h" |
| 41 #include "bindings/dart/DartApplicationLoader.h" | 42 #include "bindings/dart/DartApplicationLoader.h" |
| 42 #include "bindings/dart/DartAsyncLoader.h" | 43 #include "bindings/dart/DartAsyncLoader.h" |
| 43 #include "bindings/dart/DartDOMData.h" | 44 #include "bindings/dart/DartDOMData.h" |
| 44 #include "bindings/dart/DartDOMWrapper.h" | 45 #include "bindings/dart/DartDOMWrapper.h" |
| 45 #include "bindings/dart/DartDebugServer.h" | 46 #include "bindings/dart/DartDebugServer.h" |
| 46 #include "bindings/dart/DartGCController.h" | 47 #include "bindings/dart/DartGCController.h" |
| 47 #include "bindings/dart/DartIsolateDestructionObserver.h" | 48 #include "bindings/dart/DartIsolateDestructionObserver.h" |
| 48 #include "bindings/dart/DartJsInterop.h" | 49 #include "bindings/dart/DartJsInterop.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 // so weak handles strong, see the corresponding logic in | 216 // so weak handles strong, see the corresponding logic in |
| 216 // DartGCController. | 217 // DartGCController. |
| 217 domData->setReachableWeakHandle(Dart_NewWeakPersistentHandle(localHandle , 0, 0)); | 218 domData->setReachableWeakHandle(Dart_NewWeakPersistentHandle(localHandle , 0, 0)); |
| 218 | 219 |
| 219 DartDebugServer::shared().registerIsolate(isolate); | 220 DartDebugServer::shared().registerIsolate(isolate); |
| 220 } | 221 } |
| 221 | 222 |
| 222 return isolate; | 223 return isolate; |
| 223 } | 224 } |
| 224 | 225 |
| 226 | |
| 225 void DartController::createDOMEnabledIsolateIfNeeded(const String& scriptURL, co nst String& entryPoint, Document* document) | 227 void DartController::createDOMEnabledIsolateIfNeeded(const String& scriptURL, co nst String& entryPoint, Document* document) |
| 226 { | 228 { |
| 227 if (m_isolate) { | 229 if (m_isolate) { |
| 228 Dart_EnterIsolate(m_isolate); | 230 Dart_EnterIsolate(m_isolate); |
| 229 return; | 231 return; |
| 230 } | 232 } |
| 233 | |
| 234 bool shouldStartService = !getenv("DARTIUM_VMSERVICE"); | |
|
Jacob
2013/12/05 22:59:58
remove this local variable and include this direct
Cutch
2013/12/05 23:09:37
Done.
| |
| 235 | |
| 231 // FIXME: proper error reporting. | 236 // FIXME: proper error reporting. |
| 232 char* errorMessage = 0; | 237 char* errorMessage = 0; |
| 233 m_isolate = createIsolate(scriptURL.utf8().data(), entryPoint.utf8().data(), document, true, &errorMessage); | 238 m_isolate = createIsolate(scriptURL.utf8().data(), entryPoint.utf8().data(), document, true, &errorMessage); |
| 234 ASSERT(m_isolate); | 239 ASSERT(m_isolate); |
| 240 if (shouldStartService) { | |
| 241 // createIsolate exits with current isolate set to m_isolate, we need to | |
| 242 // exit it so we can startup the service. | |
| 243 Dart_ExitIsolate(); | |
| 244 | |
| 245 bool r = DartService::Start(document); | |
| 246 ASSERT(r); | |
| 247 ASSERT(!Dart_CurrentIsolate()); | |
| 248 | |
| 249 Dart_EnterIsolate(m_isolate); | |
| 250 Dart_EnterScope(); | |
| 251 DartService::SendIsolateStartupMessage(); | |
| 252 Dart_ExitScope(); | |
| 253 } | |
| 254 | |
| 235 } | 255 } |
| 236 | 256 |
| 237 void DartController::shutdownIsolate(Dart_Isolate isolate) | 257 void DartController::shutdownIsolate(Dart_Isolate isolate) |
| 238 { | 258 { |
| 239 DartDOMData* domData = DartDOMData::current(); | 259 DartDOMData* domData = DartDOMData::current(); |
| 240 ASSERT(domData->isDOMEnabled()); | 260 ASSERT(domData->isDOMEnabled()); |
| 241 // If the following assert triggers, we have hit dartbug.com/14183 | 261 // If the following assert triggers, we have hit dartbug.com/14183 |
| 242 // FIXME: keep the isolate alive until the recursion level is 0. | 262 // FIXME: keep the isolate alive until the recursion level is 0. |
| 243 ASSERT(!*(domData->recursion())); | 263 ASSERT(!*(domData->recursion())); |
| 244 DartDebugServer::shared().unregisterIsolate(isolate); | 264 DartDebugServer::shared().unregisterIsolate(isolate); |
| 245 DartIsolateDestructionObservers* observers = domData->isolateDestructionObse rvers(); | 265 DartIsolateDestructionObservers* observers = domData->isolateDestructionObse rvers(); |
| 246 for (DartIsolateDestructionObservers::iterator it = observers->begin(); it ! = observers->end(); ++it) | 266 for (DartIsolateDestructionObservers::iterator it = observers->begin(); it ! = observers->end(); ++it) |
| 247 (*it)->isolateDestroyed(); | 267 (*it)->isolateDestroyed(); |
| 248 Dart_ShutdownIsolate(); | 268 Dart_ShutdownIsolate(); |
| 269 // Stop the service. | |
| 270 DartService::Stop(); | |
| 249 delete domData; | 271 delete domData; |
| 250 } | 272 } |
| 251 | 273 |
| 252 DartController::DartController(Frame* frame) | 274 DartController::DartController(Frame* frame) |
| 253 : m_frame(frame) | 275 : m_frame(frame) |
| 254 , m_isolate(0) | 276 , m_isolate(0) |
| 255 , m_asyncLoader(0) | 277 , m_asyncLoader(0) |
| 256 , m_npObjectMap() | 278 , m_npObjectMap() |
| 257 { | 279 { |
| 258 // The DartController's constructor must be called in the Frame's | 280 // The DartController's constructor must be called in the Frame's |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 // spawnFunction is not allowed from a DOM enabled isolate. | 429 // spawnFunction is not allowed from a DOM enabled isolate. |
| 408 // This triggers an exception in the caller. | 430 // This triggers an exception in the caller. |
| 409 *errorMsg = strdup("spawnFunction is not supported from a dom-enabled is olate. Please use spawnUri instead."); | 431 *errorMsg = strdup("spawnFunction is not supported from a dom-enabled is olate. Please use spawnUri instead."); |
| 410 return 0; | 432 return 0; |
| 411 } | 433 } |
| 412 | 434 |
| 413 ASSERT(context->isDocument()); | 435 ASSERT(context->isDocument()); |
| 414 Document* document = static_cast<Document*>(context); | 436 Document* document = static_cast<Document*>(context); |
| 415 | 437 |
| 416 Dart_Isolate isolate = createIsolate(scriptURL, entryPoint, document, false, errorMsg); | 438 Dart_Isolate isolate = createIsolate(scriptURL, entryPoint, document, false, errorMsg); |
| 439 { | |
| 440 Dart_EnterScope(); | |
| 441 DartService::SendIsolateStartupMessage(); | |
| 442 Dart_ExitScope(); | |
| 443 } | |
| 444 | |
| 417 if (!isolate) { | 445 if (!isolate) { |
| 418 // This triggers an exception in the caller. | 446 // This triggers an exception in the caller. |
| 419 *errorMsg = strdup("Isolate spawn failed."); | 447 *errorMsg = strdup("Isolate spawn failed."); |
| 420 return 0; | 448 return 0; |
| 421 } | 449 } |
| 422 | 450 |
| 423 // FIXME: If a spawnFunction, we should not need to request resources again. But, it's not clear | 451 // FIXME: If a spawnFunction, we should not need to request resources again. But, it's not clear |
| 424 // we need this callback in the first place for spawnFunction. | 452 // we need this callback in the first place for spawnFunction. |
| 425 | 453 |
| 426 // We need to request the sources asynchronously. | 454 // We need to request the sources asynchronously. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 554 int propLen = DartUtilities::getProp( | 582 int propLen = DartUtilities::getProp( |
| 555 "DART_FLAGS", flagsProp, DartUtilities::PROP_VALUE_MAX_LEN); | 583 "DART_FLAGS", flagsProp, DartUtilities::PROP_VALUE_MAX_LEN); |
| 556 if (propLen > 0) { | 584 if (propLen > 0) { |
| 557 setDartFlags(flagsProp); | 585 setDartFlags(flagsProp); |
| 558 } else { | 586 } else { |
| 559 setDartFlags(0); | 587 setDartFlags(0); |
| 560 } | 588 } |
| 561 | 589 |
| 562 // FIXME(antonm): implement proper shutdown callback. | 590 // FIXME(antonm): implement proper shutdown callback. |
| 563 // FIXME(antonm): implement proper unhandled exception callback. | 591 // FIXME(antonm): implement proper unhandled exception callback. |
| 564 Dart_Initialize(&createPureIsolateCallback, 0, 0, 0, openFileCallback, readF ileCallback, writeFileCallback, closeFileCallback, generateEntropy); | 592 Dart_Initialize(&createPureIsolateCallback, 0, 0, DartService::VmServiceShut downCallback, openFileCallback, readFileCallback, writeFileCallback, closeFileCa llback, generateEntropy); |
| 565 hasBeenInitialized = true; | 593 hasBeenInitialized = true; |
| 566 } | 594 } |
| 567 | 595 |
| 568 static bool checkForExpiration() | 596 static bool checkForExpiration() |
| 569 { | 597 { |
| 570 const time_t ExpirationTimeSecsSinceEpoch = | 598 const time_t ExpirationTimeSecsSinceEpoch = |
| 571 #include "bindings/dart/ExpirationTimeSecsSinceEpoch.time_t" | 599 #include "bindings/dart/ExpirationTimeSecsSinceEpoch.time_t" |
| 572 ; | 600 ; |
| 573 const char* override = getenv("DARTIUM_EXPIRATION_TIME"); | 601 const char* override = getenv("DARTIUM_EXPIRATION_TIME"); |
| 574 time_t expiration; | 602 time_t expiration; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 836 Dart_Handle libraryIdHandle = Dart_ListGetAt(libraryIdList, i); | 864 Dart_Handle libraryIdHandle = Dart_ListGetAt(libraryIdList, i); |
| 837 Dart_Handle exception = 0; | 865 Dart_Handle exception = 0; |
| 838 intptr_t libraryId = DartUtilities::toInteger(libraryIdHandle, exception ); | 866 intptr_t libraryId = DartUtilities::toInteger(libraryIdHandle, exception ); |
| 839 ASSERT(!exception); | 867 ASSERT(!exception); |
| 840 DartScriptState* scriptState = lookupScriptStateFromLibraryIdMap(isolate , v8Context, libraryIdMap, libraryId); | 868 DartScriptState* scriptState = lookupScriptStateFromLibraryIdMap(isolate , v8Context, libraryIdMap, libraryId); |
| 841 result.append(scriptState); | 869 result.append(scriptState); |
| 842 } | 870 } |
| 843 } | 871 } |
| 844 | 872 |
| 845 } | 873 } |
| OLD | NEW |