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

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

Issue 104433004: Enable VM service inside Dartium Renderer processes (Closed) Base URL: svn://svn.chromium.org/multivm/branches/1650/blink
Patch Set: Created 7 years 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
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 18 matching lines...) Expand all
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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 void DartController::createDOMEnabledIsolateIfNeeded(const String& scriptURL, co nst String& entryPoint, Document* document) 226 void DartController::createDOMEnabledIsolateIfNeeded(const String& scriptURL, co nst String& entryPoint, Document* document)
226 { 227 {
227 if (m_isolate) { 228 if (m_isolate) {
228 Dart_EnterIsolate(m_isolate); 229 Dart_EnterIsolate(m_isolate);
229 return; 230 return;
230 } 231 }
231 // FIXME: proper error reporting. 232 // FIXME: proper error reporting.
232 char* errorMessage = 0; 233 char* errorMessage = 0;
233 m_isolate = createIsolate(scriptURL.utf8().data(), entryPoint.utf8().data(), document, true, &errorMessage); 234 m_isolate = createIsolate(scriptURL.utf8().data(), entryPoint.utf8().data(), document, true, &errorMessage);
234 ASSERT(m_isolate); 235 ASSERT(m_isolate);
236 ASSERT(Dart_CurrentIsolate() == m_isolate);
Jacob 2013/12/04 20:39:52 why is this assert here?
Cutch 2013/12/04 21:20:50 It was just verifying my assumption. Removed.
237 Dart_ExitIsolate();
238
239 bool r = DartService::Start(document);
Jacob 2013/12/04 20:39:52 can you add a flag that controls whether the DartS
Cutch 2013/12/04 21:20:50 Done.
240 ASSERT(r);
241 ASSERT(Dart_CurrentIsolate());
242
243 Dart_EnterIsolate(m_isolate);
siva 2013/12/13 21:48:22 Why not move the EnterScope/ExitScope stuff to Sen
244 Dart_EnterScope();
245 DartService::SendIsolateStartupMessage();
246 Dart_ExitScope();
247
248 {
249 // The following is only used for testing and will be removed.
Jacob 2013/12/04 20:39:52 add a fixme for code that should be removed.
Cutch 2013/12/04 21:20:50 Done.
250 Dart_EnterScope();
251 Dart_Handle html =
252 Dart_LookupLibrary(Dart_NewStringFromCString("dart:html"));
253 ASSERT(!Dart_IsError(html));
254 Dart_Handle res = Dart_SetField(html,
255 Dart_NewStringFromCString("myPort"),
256 Dart_NewSendPort(DartService::GetRequestPort()));
257 ASSERT(!Dart_IsError(res));
258 Dart_ExitScope();
259 }
235 } 260 }
236 261
237 void DartController::shutdownIsolate(Dart_Isolate isolate) 262 void DartController::shutdownIsolate(Dart_Isolate isolate)
238 { 263 {
239 DartDOMData* domData = DartDOMData::current(); 264 DartDOMData* domData = DartDOMData::current();
240 ASSERT(domData->isDOMEnabled()); 265 ASSERT(domData->isDOMEnabled());
241 // If the following assert triggers, we have hit dartbug.com/14183 266 // If the following assert triggers, we have hit dartbug.com/14183
242 // FIXME: keep the isolate alive until the recursion level is 0. 267 // FIXME: keep the isolate alive until the recursion level is 0.
243 ASSERT(!*(domData->recursion())); 268 ASSERT(!*(domData->recursion()));
244 DartDebugServer::shared().unregisterIsolate(isolate); 269 DartDebugServer::shared().unregisterIsolate(isolate);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 308
284 // Due to synchronous dispatch, we may be in an isolate corresponding to ano ther frame. 309 // Due to synchronous dispatch, we may be in an isolate corresponding to ano ther frame.
285 // If so, save and restore. 310 // If so, save and restore.
286 Dart_Isolate currentIsolate = Dart_CurrentIsolate(); 311 Dart_Isolate currentIsolate = Dart_CurrentIsolate();
287 if (currentIsolate) 312 if (currentIsolate)
288 Dart_ExitIsolate(); 313 Dart_ExitIsolate();
289 314
290 if (m_isolate) { 315 if (m_isolate) {
291 Dart_EnterIsolate(m_isolate); 316 Dart_EnterIsolate(m_isolate);
292 DartUtilities::disposeWeakPersistentHandles(); 317 DartUtilities::disposeWeakPersistentHandles();
293
294 shutdownIsolate(m_isolate); 318 shutdownIsolate(m_isolate);
295 m_isolate = 0; 319 m_isolate = 0;
296 } 320 }
297 321
298 for (ScriptStatesMap::iterator it = m_scriptStates.begin(); it != m_scriptSt ates.end(); ++it) { 322 for (ScriptStatesMap::iterator it = m_scriptStates.begin(); it != m_scriptSt ates.end(); ++it) {
299 LibraryIdMap* libraryIdMap = it->value; 323 LibraryIdMap* libraryIdMap = it->value;
300 for (LibraryIdMap::iterator scriptStateIt = libraryIdMap->begin(); scrip tStateIt != libraryIdMap->end(); ++scriptStateIt) { 324 for (LibraryIdMap::iterator scriptStateIt = libraryIdMap->begin(); scrip tStateIt != libraryIdMap->end(); ++scriptStateIt) {
301 delete scriptStateIt->value; 325 delete scriptStateIt->value;
302 } 326 }
303 delete libraryIdMap; 327 delete libraryIdMap;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 if (parentDOMData->isDOMEnabled() && !isSpawnUri) { 430 if (parentDOMData->isDOMEnabled() && !isSpawnUri) {
407 // spawnFunction is not allowed from a DOM enabled isolate. 431 // spawnFunction is not allowed from a DOM enabled isolate.
408 // This triggers an exception in the caller. 432 // This triggers an exception in the caller.
409 *errorMsg = strdup("spawnFunction is not supported from a dom-enabled is olate. Please use spawnUri instead."); 433 *errorMsg = strdup("spawnFunction is not supported from a dom-enabled is olate. Please use spawnUri instead.");
410 return 0; 434 return 0;
411 } 435 }
412 436
413 ASSERT(context->isDocument()); 437 ASSERT(context->isDocument());
414 Document* document = static_cast<Document*>(context); 438 Document* document = static_cast<Document*>(context);
415 439
416 Dart_Isolate isolate = createIsolate(scriptURL, entryPoint, document, false, errorMsg); 440 Dart_Isolate isolate = createIsolate(scriptURL, entryPoint, document, false, errorMsg);
siva 2013/12/13 21:48:22 Ditto comment about Enter/Exit Scope
441 Dart_EnterScope();
442 DartService::SendIsolateStartupMessage();
Jacob 2013/12/04 20:39:52 put enterscope, exit scope in { } by convention
Cutch 2013/12/04 21:20:50 Done.
443 Dart_ExitScope();
417 if (!isolate) { 444 if (!isolate) {
418 // This triggers an exception in the caller. 445 // This triggers an exception in the caller.
419 *errorMsg = strdup("Isolate spawn failed."); 446 *errorMsg = strdup("Isolate spawn failed.");
420 return 0; 447 return 0;
421 } 448 }
422 449
423 // FIXME: If a spawnFunction, we should not need to request resources again. But, it's not clear 450 // 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. 451 // we need this callback in the first place for spawnFunction.
425 452
426 // We need to request the sources asynchronously. 453 // We need to request the sources asynchronously.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 return true; 569 return true;
543 } 570 }
544 return false; 571 return false;
545 } 572 }
546 573
547 void DartController::initVMIfNeeded() 574 void DartController::initVMIfNeeded()
548 { 575 {
549 static bool hasBeenInitialized = false; 576 static bool hasBeenInitialized = false;
550 if (hasBeenInitialized) 577 if (hasBeenInitialized)
551 return; 578 return;
552
553 char flagsProp[DartUtilities::PROP_VALUE_MAX_LEN]; 579 char flagsProp[DartUtilities::PROP_VALUE_MAX_LEN];
554 int propLen = DartUtilities::getProp( 580 int propLen = DartUtilities::getProp(
555 "DART_FLAGS", flagsProp, DartUtilities::PROP_VALUE_MAX_LEN); 581 "DART_FLAGS", flagsProp, DartUtilities::PROP_VALUE_MAX_LEN);
556 if (propLen > 0) { 582 if (propLen > 0) {
557 setDartFlags(flagsProp); 583 setDartFlags(flagsProp);
558 } else { 584 } else {
559 setDartFlags(0); 585 setDartFlags(0);
560 } 586 }
561 587
562 // FIXME(antonm): implement proper shutdown callback. 588 // FIXME(antonm): implement proper shutdown callback.
563 // FIXME(antonm): implement proper unhandled exception callback. 589 // FIXME(antonm): implement proper unhandled exception callback.
564 Dart_Initialize(&createPureIsolateCallback, 0, 0, 0, openFileCallback, readF ileCallback, writeFileCallback, closeFileCallback, generateEntropy); 590 Dart_Initialize(&createPureIsolateCallback, 0, 0, DartService::VmServiceShut downCallback, openFileCallback, readFileCallback, writeFileCallback, closeFileCa llback, generateEntropy);
siva 2013/12/13 21:48:22 You should have a generic shutdown callback and i
565 hasBeenInitialized = true; 591 hasBeenInitialized = true;
566 } 592 }
567 593
568 static bool checkForExpiration() 594 static bool checkForExpiration()
569 { 595 {
570 const time_t ExpirationTimeSecsSinceEpoch = 596 const time_t ExpirationTimeSecsSinceEpoch =
571 #include "bindings/dart/ExpirationTimeSecsSinceEpoch.time_t" 597 #include "bindings/dart/ExpirationTimeSecsSinceEpoch.time_t"
572 ; 598 ;
573 const char* override = getenv("DARTIUM_EXPIRATION_TIME"); 599 const char* override = getenv("DARTIUM_EXPIRATION_TIME");
574 time_t expiration; 600 time_t expiration;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 Dart_Handle libraryIdHandle = Dart_ListGetAt(libraryIdList, i); 862 Dart_Handle libraryIdHandle = Dart_ListGetAt(libraryIdList, i);
837 Dart_Handle exception = 0; 863 Dart_Handle exception = 0;
838 intptr_t libraryId = DartUtilities::toInteger(libraryIdHandle, exception ); 864 intptr_t libraryId = DartUtilities::toInteger(libraryIdHandle, exception );
839 ASSERT(!exception); 865 ASSERT(!exception);
840 DartScriptState* scriptState = lookupScriptStateFromLibraryIdMap(isolate , v8Context, libraryIdMap, libraryId); 866 DartScriptState* scriptState = lookupScriptStateFromLibraryIdMap(isolate , v8Context, libraryIdMap, libraryId);
841 result.append(scriptState); 867 result.append(scriptState);
842 } 868 }
843 } 869 }
844 870
845 } 871 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698