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

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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
231 // FIXME: proper error reporting. 234 // FIXME: proper error reporting.
232 char* errorMessage = 0; 235 char* errorMessage = 0;
233 m_isolate = createIsolate(scriptURL.utf8().data(), entryPoint.utf8().data(), document, true, &errorMessage); 236 m_isolate = createIsolate(scriptURL.utf8().data(), entryPoint.utf8().data(), document, true, &errorMessage);
234 ASSERT(m_isolate); 237 ASSERT(m_isolate);
238 if (getenv("DARTIUM_VMSERVICE")) {
siva 2013/12/13 21:48:23 I am hoping this will be a stop gap arrangement un
239 // createIsolate exits with current isolate set to m_isolate, we need to
240 // exit it so we can startup the service.
241 Dart_ExitIsolate();
242
243 bool r = DartService::Start(document);
244 ASSERT(r);
245 ASSERT(!Dart_CurrentIsolate());
246
247 Dart_EnterIsolate(m_isolate);
248 Dart_EnterScope();
249 DartService::SendIsolateStartupMessage();
250 Dart_ExitScope();
251 }
252
235 } 253 }
236 254
237 void DartController::shutdownIsolate(Dart_Isolate isolate) 255 void DartController::shutdownIsolate(Dart_Isolate isolate)
238 { 256 {
239 DartDOMData* domData = DartDOMData::current(); 257 DartDOMData* domData = DartDOMData::current();
240 ASSERT(domData->isDOMEnabled()); 258 ASSERT(domData->isDOMEnabled());
241 // If the following assert triggers, we have hit dartbug.com/14183 259 // If the following assert triggers, we have hit dartbug.com/14183
242 // FIXME: keep the isolate alive until the recursion level is 0. 260 // FIXME: keep the isolate alive until the recursion level is 0.
243 ASSERT(!*(domData->recursion())); 261 ASSERT(!*(domData->recursion()));
244 DartDebugServer::shared().unregisterIsolate(isolate); 262 DartDebugServer::shared().unregisterIsolate(isolate);
245 DartIsolateDestructionObservers* observers = domData->isolateDestructionObse rvers(); 263 DartIsolateDestructionObservers* observers = domData->isolateDestructionObse rvers();
246 for (DartIsolateDestructionObservers::iterator it = observers->begin(); it ! = observers->end(); ++it) 264 for (DartIsolateDestructionObservers::iterator it = observers->begin(); it ! = observers->end(); ++it)
247 (*it)->isolateDestroyed(); 265 (*it)->isolateDestroyed();
248 Dart_ShutdownIsolate(); 266 Dart_ShutdownIsolate();
267 // Stop the service.
268 DartService::Stop();
249 delete domData; 269 delete domData;
250 } 270 }
251 271
252 DartController::DartController(Frame* frame) 272 DartController::DartController(Frame* frame)
253 : m_frame(frame) 273 : m_frame(frame)
254 , m_isolate(0) 274 , m_isolate(0)
255 , m_asyncLoader(0) 275 , m_asyncLoader(0)
256 , m_npObjectMap() 276 , m_npObjectMap()
257 { 277 {
258 // The DartController's constructor must be called in the Frame's 278 // The DartController's constructor must be called in the Frame's
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 // spawnFunction is not allowed from a DOM enabled isolate. 427 // spawnFunction is not allowed from a DOM enabled isolate.
408 // This triggers an exception in the caller. 428 // This triggers an exception in the caller.
409 *errorMsg = strdup("spawnFunction is not supported from a dom-enabled is olate. Please use spawnUri instead."); 429 *errorMsg = strdup("spawnFunction is not supported from a dom-enabled is olate. Please use spawnUri instead.");
410 return 0; 430 return 0;
411 } 431 }
412 432
413 ASSERT(context->isDocument()); 433 ASSERT(context->isDocument());
414 Document* document = static_cast<Document*>(context); 434 Document* document = static_cast<Document*>(context);
415 435
416 Dart_Isolate isolate = createIsolate(scriptURL, entryPoint, document, false, errorMsg); 436 Dart_Isolate isolate = createIsolate(scriptURL, entryPoint, document, false, errorMsg);
437 {
438 Dart_EnterScope();
439 DartService::SendIsolateStartupMessage();
440 Dart_ExitScope();
441 }
442
417 if (!isolate) { 443 if (!isolate) {
418 // This triggers an exception in the caller. 444 // This triggers an exception in the caller.
419 *errorMsg = strdup("Isolate spawn failed."); 445 *errorMsg = strdup("Isolate spawn failed.");
420 return 0; 446 return 0;
421 } 447 }
422 448
423 // FIXME: If a spawnFunction, we should not need to request resources again. But, it's not clear 449 // 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. 450 // we need this callback in the first place for spawnFunction.
425 451
426 // We need to request the sources asynchronously. 452 // We need to request the sources asynchronously.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
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