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

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

Issue 26397003: Disable spawnFunction from dom enabled isolates (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Created 7 years, 2 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 Dart_IsolateMakeRunnable(m_isolate); 343 Dart_IsolateMakeRunnable(m_isolate);
344 } 344 }
345 345
346 private: 346 private:
347 Dart_Isolate m_isolate; 347 Dart_Isolate m_isolate;
348 String m_url; 348 String m_url;
349 }; 349 };
350 350
351 Dart_Isolate DartController::createPureIsolateCallback(const char* scriptURL, co nst char* entryPoint, void* data, char** errorMsg) 351 Dart_Isolate DartController::createPureIsolateCallback(const char* scriptURL, co nst char* entryPoint, void* data, char** errorMsg)
352 { 352 {
353 bool needAsyncLoader = false; 353 bool isSpawnUri = false;
354 354
355 { 355 {
356 DartApiScope apiScope; 356 DartApiScope apiScope;
357 // Hacky way to find out if it's spawnFunction or spawnUri. 357 // Hacky way to find out if it's spawnFunction or isSpawnUri.
siva 2013/10/08 23:46:32 why does this comment have to change? spawnUri mak
vsm 2013/10/09 04:48:35 Fixed - bad search and replace.
358 Dart_Handle parentIsolateRootLibrary = Dart_RootLibrary(); 358 Dart_Handle parentIsolateRootLibrary = Dart_RootLibrary();
359 if (Dart_IsError(parentIsolateRootLibrary)) { 359 if (Dart_IsError(parentIsolateRootLibrary)) {
360 *errorMsg = strdup(Dart_GetError(parentIsolateRootLibrary)); 360 *errorMsg = strdup(Dart_GetError(parentIsolateRootLibrary));
361 return 0; 361 return 0;
362 } 362 }
363 Dart_Handle parentIsolateURLHandle = Dart_LibraryUrl(parentIsolateRootLi brary); 363 Dart_Handle parentIsolateURLHandle = Dart_LibraryUrl(parentIsolateRootLi brary);
364 if (Dart_IsError(parentIsolateURLHandle)) { 364 if (Dart_IsError(parentIsolateURLHandle)) {
365 *errorMsg = strdup(Dart_GetError(parentIsolateURLHandle)); 365 *errorMsg = strdup(Dart_GetError(parentIsolateURLHandle));
366 return 0; 366 return 0;
367 } 367 }
368 const char * parentIsolateURL = 0; 368 const char * parentIsolateURL = 0;
369 Dart_Handle result = Dart_StringToCString(parentIsolateURLHandle, &paren tIsolateURL); 369 Dart_Handle result = Dart_StringToCString(parentIsolateURLHandle, &paren tIsolateURL);
370 if (Dart_IsError(result)) { 370 if (Dart_IsError(result)) {
371 *errorMsg = strdup(Dart_GetError(result)); 371 *errorMsg = strdup(Dart_GetError(result));
372 return 0; 372 return 0;
373 } 373 }
374 374
375 needAsyncLoader = strcmp(scriptURL, parentIsolateURL); 375 isSpawnUri = strcmp(scriptURL, parentIsolateURL);
376 } 376 }
377 377
378 DartDOMData* parentDOMData = static_cast<DartDOMData*>(data); 378 DartDOMData* parentDOMData = static_cast<DartDOMData*>(data);
379 ScriptExecutionContext* context = parentDOMData->scriptExecutionContext(); 379 ScriptExecutionContext* context = parentDOMData->scriptExecutionContext();
380
381 if (parentDOMData->isDOMEnabled() && !isSpawnUri) {
382 // spawnFunction is not allowed from a DOM enabled isolate
383 DartUtilities::reportProblem(context, "spawnFunction is not supported fr om a dom-enabled isolate. Please use spawnUri instead.");
384 }
385
380 ASSERT(context->isDocument()); 386 ASSERT(context->isDocument());
381 Document* document = static_cast<Document*>(context); 387 Document* document = static_cast<Document*>(context);
382 388
383 Dart_Isolate isolate = createIsolate(scriptURL, entryPoint, document, false, errorMsg); 389 Dart_Isolate isolate = createIsolate(scriptURL, entryPoint, document, false, errorMsg);
384 if (!isolate) 390 if (!isolate)
385 return 0; 391 return 0;
386 392
387 if (needAsyncLoader) { 393 if (isSpawnUri) {
388 // We need to request the sources asynchronously. 394 // We need to request the sources asynchronously.
389 RefPtr<DartSpawnLoadCallback> callback = adoptRef(new DartSpawnLoadCallb ack(isolate, scriptURL, document)); 395 RefPtr<DartSpawnLoadCallback> callback = adoptRef(new DartSpawnLoadCallb ack(isolate, scriptURL, document));
390 // A DartAsyncLoader will delete itself once all resources are fetched. 396 // A DartAsyncLoader will delete itself once all resources are fetched.
391 DartAsyncLoader* asyncLoader = new DartAsyncLoader(scriptURL, callback); 397 DartAsyncLoader* asyncLoader = new DartAsyncLoader(scriptURL, callback);
392 asyncLoader->fetchScriptResource(scriptURL); 398 asyncLoader->fetchScriptResource(scriptURL);
393 } else { 399 } else {
394 // FIXME: avoid copying parent snapshot. 400 // FIXME: avoid copying parent snapshot.
395 ASSERT(DartDOMData::current()->applicationSnapshot()->isEmpty()); 401 ASSERT(DartDOMData::current()->applicationSnapshot()->isEmpty());
396 DartDOMData::current()->applicationSnapshot()->append(*parentDOMData->ap plicationSnapshot()); 402 DartDOMData::current()->applicationSnapshot()->append(*parentDOMData->ap plicationSnapshot());
397 403
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 scriptState = new DartScriptState(isolate, libraryId, v8Context); 898 scriptState = new DartScriptState(isolate, libraryId, v8Context);
893 libraryIdMap->add(libraryId, scriptState); 899 libraryIdMap->add(libraryId, scriptState);
894 } else { 900 } else {
895 scriptState = libraryIter->value; 901 scriptState = libraryIter->value;
896 } 902 }
897 result.append(scriptState); 903 result.append(scriptState);
898 } 904 }
899 } 905 }
900 906
901 } 907 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698