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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 // FIXME: http://dartbug.com/13920 | |
357 // Hacky way to find out if it's spawnFunction or spawnUri. | 358 // Hacky way to find out if it's spawnFunction or spawnUri. |
358 Dart_Handle parentIsolateRootLibrary = Dart_RootLibrary(); | 359 Dart_Handle parentIsolateRootLibrary = Dart_RootLibrary(); |
359 if (Dart_IsError(parentIsolateRootLibrary)) { | 360 if (Dart_IsError(parentIsolateRootLibrary)) { |
360 *errorMsg = strdup(Dart_GetError(parentIsolateRootLibrary)); | 361 *errorMsg = strdup(Dart_GetError(parentIsolateRootLibrary)); |
361 return 0; | 362 return 0; |
362 } | 363 } |
363 Dart_Handle parentIsolateURLHandle = Dart_LibraryUrl(parentIsolateRootLi brary); | 364 Dart_Handle parentIsolateURLHandle = Dart_LibraryUrl(parentIsolateRootLi brary); |
364 if (Dart_IsError(parentIsolateURLHandle)) { | 365 if (Dart_IsError(parentIsolateURLHandle)) { |
365 *errorMsg = strdup(Dart_GetError(parentIsolateURLHandle)); | 366 *errorMsg = strdup(Dart_GetError(parentIsolateURLHandle)); |
366 return 0; | 367 return 0; |
367 } | 368 } |
368 const char * parentIsolateURL = 0; | 369 const char * parentIsolateURL = 0; |
369 Dart_Handle result = Dart_StringToCString(parentIsolateURLHandle, &paren tIsolateURL); | 370 Dart_Handle result = Dart_StringToCString(parentIsolateURLHandle, &paren tIsolateURL); |
370 if (Dart_IsError(result)) { | 371 if (Dart_IsError(result)) { |
371 *errorMsg = strdup(Dart_GetError(result)); | 372 *errorMsg = strdup(Dart_GetError(result)); |
372 return 0; | 373 return 0; |
373 } | 374 } |
374 | 375 |
375 needAsyncLoader = strcmp(scriptURL, parentIsolateURL); | 376 isSpawnUri = strcmp(scriptURL, parentIsolateURL); |
376 } | 377 } |
377 | 378 |
378 DartDOMData* parentDOMData = static_cast<DartDOMData*>(data); | 379 DartDOMData* parentDOMData = static_cast<DartDOMData*>(data); |
379 ScriptExecutionContext* context = parentDOMData->scriptExecutionContext(); | 380 ScriptExecutionContext* context = parentDOMData->scriptExecutionContext(); |
381 | |
382 if (parentDOMData->isDOMEnabled() && !isSpawnUri) { | |
383 // spawnFunction is not allowed from a DOM enabled isolate | |
384 DartUtilities::reportProblem(context, "spawnFunction is not supported fr om a dom-enabled isolate. Please use spawnUri instead."); | |
ricow1
2013/10/11 11:08:37
Why don't we throw an exception here? This is mess
| |
385 } | |
386 | |
380 ASSERT(context->isDocument()); | 387 ASSERT(context->isDocument()); |
381 Document* document = static_cast<Document*>(context); | 388 Document* document = static_cast<Document*>(context); |
382 | 389 |
383 Dart_Isolate isolate = createIsolate(scriptURL, entryPoint, document, false, errorMsg); | 390 Dart_Isolate isolate = createIsolate(scriptURL, entryPoint, document, false, errorMsg); |
384 if (!isolate) | 391 if (!isolate) |
385 return 0; | 392 return 0; |
386 | 393 |
387 if (needAsyncLoader) { | 394 if (isSpawnUri) { |
388 // We need to request the sources asynchronously. | 395 // We need to request the sources asynchronously. |
389 RefPtr<DartSpawnLoadCallback> callback = adoptRef(new DartSpawnLoadCallb ack(isolate, scriptURL, document)); | 396 RefPtr<DartSpawnLoadCallback> callback = adoptRef(new DartSpawnLoadCallb ack(isolate, scriptURL, document)); |
390 // A DartAsyncLoader will delete itself once all resources are fetched. | 397 // A DartAsyncLoader will delete itself once all resources are fetched. |
391 DartAsyncLoader* asyncLoader = new DartAsyncLoader(scriptURL, callback); | 398 DartAsyncLoader* asyncLoader = new DartAsyncLoader(scriptURL, callback); |
392 asyncLoader->fetchScriptResource(scriptURL); | 399 asyncLoader->fetchScriptResource(scriptURL); |
393 } else { | 400 } else { |
394 // FIXME: avoid copying parent snapshot. | 401 // FIXME: avoid copying parent snapshot. |
395 ASSERT(DartDOMData::current()->applicationSnapshot()->isEmpty()); | 402 ASSERT(DartDOMData::current()->applicationSnapshot()->isEmpty()); |
396 DartDOMData::current()->applicationSnapshot()->append(*parentDOMData->ap plicationSnapshot()); | 403 DartDOMData::current()->applicationSnapshot()->append(*parentDOMData->ap plicationSnapshot()); |
397 | 404 |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
892 scriptState = new DartScriptState(isolate, libraryId, v8Context); | 899 scriptState = new DartScriptState(isolate, libraryId, v8Context); |
893 libraryIdMap->add(libraryId, scriptState); | 900 libraryIdMap->add(libraryId, scriptState); |
894 } else { | 901 } else { |
895 scriptState = libraryIter->value; | 902 scriptState = libraryIter->value; |
896 } | 903 } |
897 result.append(scriptState); | 904 result.append(scriptState); |
898 } | 905 } |
899 } | 906 } |
900 | 907 |
901 } | 908 } |
OLD | NEW |