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

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

Issue 155503003: Fix for bug 16534 do not Enter the same isolate on two different threads. (Closed) Base URL: svn://svn.chromium.org/blink/branches/dart/1700/
Patch Set: Created 6 years, 10 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 if (Dart_IsError(result)) 351 if (Dart_IsError(result))
352 DartUtilities::reportProblem(context, result); 352 DartUtilities::reportProblem(context, result);
353 } 353 }
354 354
355 private: 355 private:
356 RefPtr<ThreadSafeDartIsolateWrapper> m_destinationIsolate; 356 RefPtr<ThreadSafeDartIsolateWrapper> m_destinationIsolate;
357 }; 357 };
358 358
359 static void messageNotifyCallback(Dart_Isolate destinationIsolate) 359 static void messageNotifyCallback(Dart_Isolate destinationIsolate)
360 { 360 {
361 DartIsolateScope scope(destinationIsolate); 361 DartDOMData* domData = static_cast<DartDOMData*>(Dart_IsolateData(destinatio nIsolate));
362 DartDOMData* domData = DartDOMData::current();
363 ASSERT(domData->isDOMEnabled()); 362 ASSERT(domData->isDOMEnabled());
364 ExecutionContext* destinationContext = domData->scriptExecutionContext(); 363 ExecutionContext* destinationContext = domData->scriptExecutionContext();
365 destinationContext->postTask(adoptPtr(new MessageNotifyTask(domData->threadS afeIsolateWrapper()))); 364 destinationContext->postTask(adoptPtr(new MessageNotifyTask(domData->threadS afeIsolateWrapper())));
366 } 365 }
367 366
368 class SpawnUriErrorEventDispatcher : public DartErrorEventDispatcher { 367 class SpawnUriErrorEventDispatcher : public DartErrorEventDispatcher {
369 public: 368 public:
370 // TODO(antonm): this is used to dispatch DOM error event. Most probably we need 369 // TODO(antonm): this is used to dispatch DOM error event. Most probably we need
371 // nothing like that for spawnDomUri, but need to double check. 370 // nothing like that for spawnDomUri, but need to double check.
372 void dispatchErrorEvent() { } 371 void dispatchErrorEvent() { }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 } 473 }
475 474
476 static char* skipBlackSpace(char* p) 475 static char* skipBlackSpace(char* p)
477 { 476 {
478 for (; *p != '\0' && !isspace(*p); p++) { } 477 for (; *p != '\0' && !isspace(*p); p++) { }
479 return p; 478 return p;
480 } 479 }
481 480
482 static void setDartFlags(const char* str) 481 static void setDartFlags(const char* str)
483 { 482 {
484 const char* disableProfiler = "--no-profile";
485
486 if (!str) { 483 if (!str) {
487 Dart_SetVMFlags(1, &disableProfiler); 484 Dart_SetVMFlags(0, 0);
488 return; 485 return;
489 } 486 }
490 487
491 size_t length = strlen(str); 488 size_t length = strlen(str);
492 char* copy = new char[length + 1]; 489 char* copy = new char[length + 1];
493 memmove(copy, str, length); 490 memmove(copy, str, length);
494 copy[length] = '\0'; 491 copy[length] = '\0';
495 492
496 // Strip leading white space. 493 // Strip leading white space.
497 char* start = skipWhiteSpace(copy); 494 char* start = skipWhiteSpace(copy);
498 495
499 // Count the number of 'arguments'. 496 // Count the number of 'arguments'.
500 int argc = 0; 497 int argc = 0;
501 for (char* p = start; *p != '\0'; argc++) { 498 for (char* p = start; *p != '\0'; argc++) {
502 p = skipBlackSpace(p); 499 p = skipBlackSpace(p);
503 p = skipWhiteSpace(p); 500 p = skipWhiteSpace(p);
504 } 501 }
505 502
506 // Allocate argument array. 503 // Allocate argument array.
507 const char** argv = new const char*[argc + 1]; 504 const char** argv = new const char*[argc];
508 505
509 // Split the flags string into arguments. 506 // Split the flags string into arguments.
510 argc = 0; 507 argc = 0;
511 for (char* p = start; *p != '\0'; argc++) { 508 for (char* p = start; *p != '\0'; argc++) {
512 argv[argc] = p; 509 argv[argc] = p;
513 p = skipBlackSpace(p); 510 p = skipBlackSpace(p);
514 if (*p != '\0') 511 if (*p != '\0')
515 *p++ = '\0'; // 0-terminate argument 512 *p++ = '\0'; // 0-terminate argument
516 p = skipWhiteSpace(p); 513 p = skipWhiteSpace(p);
517 } 514 }
518 argv[argc] = disableProfiler;
519 515
520 // Set the flags. 516 // Set the flags.
521 Dart_SetVMFlags(argc + 1, argv); 517 Dart_SetVMFlags(argc, argv);
522 518
523 delete[] argv; 519 delete[] argv;
524 delete[] copy; 520 delete[] copy;
525 } 521 }
526 522
527 namespace { 523 namespace {
528 524
529 #if OS(LINUX) 525 #if OS(LINUX)
530 526
531 static void* openFileCallback(const char* name, bool write) 527 static void* openFileCallback(const char* name, bool write)
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 Dart_Handle libraryIdHandle = Dart_ListGetAt(libraryIdList, i); 872 Dart_Handle libraryIdHandle = Dart_ListGetAt(libraryIdList, i);
877 Dart_Handle exception = 0; 873 Dart_Handle exception = 0;
878 intptr_t libraryId = DartUtilities::toInteger(libraryIdHandle, exception ); 874 intptr_t libraryId = DartUtilities::toInteger(libraryIdHandle, exception );
879 ASSERT(!exception); 875 ASSERT(!exception);
880 DartScriptState* scriptState = lookupScriptStateFromLibraryIdMap(isolate , v8Context, libraryIdMap, libraryId); 876 DartScriptState* scriptState = lookupScriptStateFromLibraryIdMap(isolate , v8Context, libraryIdMap, libraryId);
881 result.append(scriptState); 877 result.append(scriptState);
882 } 878 }
883 } 879 }
884 880
885 } 881 }
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