Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 * | 24 * |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "core/workers/WorkerThread.h" | 27 #include "core/workers/WorkerThread.h" |
| 28 | 28 |
| 29 #include "bindings/core/v8/Microtask.h" | 29 #include "bindings/core/v8/Microtask.h" |
| 30 #include "bindings/core/v8/ScriptSourceCode.h" | 30 #include "bindings/core/v8/ScriptSourceCode.h" |
| 31 #include "bindings/core/v8/V8GCController.h" | 31 #include "bindings/core/v8/V8GCController.h" |
| 32 #include "bindings/core/v8/V8IdleTaskRunner.h" | 32 #include "bindings/core/v8/V8IdleTaskRunner.h" |
| 33 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 33 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
| 34 #include "core/inspector/ConsoleMessageStorage.h" | |
| 34 #include "core/inspector/InspectorInstrumentation.h" | 35 #include "core/inspector/InspectorInstrumentation.h" |
| 35 #include "core/inspector/InspectorTaskRunner.h" | 36 #include "core/inspector/InspectorTaskRunner.h" |
| 36 #include "core/inspector/WorkerInspectorController.h" | 37 #include "core/inspector/WorkerInspectorController.h" |
| 37 #include "core/inspector/WorkerThreadDebugger.h" | 38 #include "core/inspector/WorkerThreadDebugger.h" |
| 38 #include "core/origin_trials/OriginTrialContext.h" | 39 #include "core/origin_trials/OriginTrialContext.h" |
| 39 #include "core/workers/WorkerBackingThread.h" | 40 #include "core/workers/WorkerBackingThread.h" |
| 40 #include "core/workers/WorkerClients.h" | 41 #include "core/workers/WorkerClients.h" |
| 41 #include "core/workers/WorkerGlobalScope.h" | 42 #include "core/workers/WorkerGlobalScope.h" |
| 42 #include "core/workers/WorkerReportingProxy.h" | 43 #include "core/workers/WorkerReportingProxy.h" |
| 43 #include "core/workers/WorkerThreadStartupData.h" | 44 #include "core/workers/WorkerThreadStartupData.h" |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 485 if (isOwningBackingThread()) | 486 if (isOwningBackingThread()) |
| 486 workerBackingThread().initialize(); | 487 workerBackingThread().initialize(); |
| 487 | 488 |
| 488 if (shouldAttachThreadDebugger()) | 489 if (shouldAttachThreadDebugger()) |
| 489 V8PerIsolateData::from(isolate())->setThreadDebugger(wrapUnique(new WorkerThreadDebugger(this, isolate()))); | 490 V8PerIsolateData::from(isolate())->setThreadDebugger(wrapUnique(new WorkerThreadDebugger(this, isolate()))); |
| 490 m_microtaskRunner = wrapUnique(new WorkerMicrotaskRunner(this)); | 491 m_microtaskRunner = wrapUnique(new WorkerMicrotaskRunner(this)); |
| 491 workerBackingThread().backingThread().addTaskObserver(m_microtaskRunner. get()); | 492 workerBackingThread().backingThread().addTaskObserver(m_microtaskRunner. get()); |
| 492 | 493 |
| 493 // Optimize for memory usage instead of latency for the worker isolate. | 494 // Optimize for memory usage instead of latency for the worker isolate. |
| 494 isolate()->IsolateInBackgroundNotification(); | 495 isolate()->IsolateInBackgroundNotification(); |
| 496 m_consoleMessageStorage = new ConsoleMessageStorage(); | |
| 495 m_globalScope = createWorkerGlobalScope(std::move(startupData)); | 497 m_globalScope = createWorkerGlobalScope(std::move(startupData)); |
| 496 m_workerInspectorController = WorkerInspectorController::create(this); | 498 m_workerInspectorController = WorkerInspectorController::create(this); |
| 497 if (m_globalScope->isWorkerGlobalScope()) | 499 if (m_globalScope->isWorkerGlobalScope()) |
| 498 toWorkerGlobalScope(m_globalScope)->scriptLoaded(sourceCode.length() , cachedMetaData.get() ? cachedMetaData->size() : 0); | 500 toWorkerGlobalScope(m_globalScope)->scriptLoaded(sourceCode.length() , cachedMetaData.get() ? cachedMetaData->size() : 0); |
| 499 | 501 |
| 500 // Notify proxy that a new WorkerOrWorkletGlobalScope has been created | 502 // Notify proxy that a new WorkerOrWorkletGlobalScope has been created |
| 501 // and started. | 503 // and started. |
| 502 m_workerReportingProxy.workerGlobalScopeStarted(m_globalScope.get()); | 504 m_workerReportingProxy.workerGlobalScopeStarted(m_globalScope.get()); |
| 503 | 505 |
| 504 WorkerOrWorkletScriptController* scriptController = m_globalScope->scrip tController(); | 506 WorkerOrWorkletScriptController* scriptController = m_globalScope->scrip tController(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 } | 558 } |
| 557 | 559 |
| 558 m_inspectorTaskRunner->kill(); | 560 m_inspectorTaskRunner->kill(); |
| 559 workerReportingProxy().willDestroyWorkerGlobalScope(); | 561 workerReportingProxy().willDestroyWorkerGlobalScope(); |
| 560 InspectorInstrumentation::allAsyncTasksCanceled(globalScope()); | 562 InspectorInstrumentation::allAsyncTasksCanceled(globalScope()); |
| 561 globalScope()->dispose(); | 563 globalScope()->dispose(); |
| 562 if (m_workerInspectorController) { | 564 if (m_workerInspectorController) { |
| 563 m_workerInspectorController->dispose(); | 565 m_workerInspectorController->dispose(); |
| 564 m_workerInspectorController.clear(); | 566 m_workerInspectorController.clear(); |
| 565 } | 567 } |
| 568 if (m_consoleMessageStorage) | |
|
yhirano
2016/08/09 06:33:06
Why don't you clear the pointer unconditionally?
ikilpatrick
2016/08/09 14:13:58
Done.
| |
| 569 m_consoleMessageStorage.clear(); | |
| 566 workerBackingThread().backingThread().removeTaskObserver(m_microtaskRunner.g et()); | 570 workerBackingThread().backingThread().removeTaskObserver(m_microtaskRunner.g et()); |
| 567 } | 571 } |
| 568 | 572 |
| 569 void WorkerThread::performShutdownOnWorkerThread() | 573 void WorkerThread::performShutdownOnWorkerThread() |
| 570 { | 574 { |
| 571 DCHECK(isCurrentThread()); | 575 DCHECK(isCurrentThread()); |
| 572 #if DCHECK_IS_ON | 576 #if DCHECK_IS_ON |
| 573 { | 577 { |
| 574 MutexLocker lock(m_threadStateMutex); | 578 MutexLocker lock(m_threadStateMutex); |
| 575 DCHECK(m_terminated); | 579 DCHECK(m_terminated); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 659 (*task)(); | 663 (*task)(); |
| 660 } | 664 } |
| 661 | 665 |
| 662 WorkerThread::ExitCode WorkerThread::getExitCode() | 666 WorkerThread::ExitCode WorkerThread::getExitCode() |
| 663 { | 667 { |
| 664 MutexLocker lock(m_threadStateMutex); | 668 MutexLocker lock(m_threadStateMutex); |
| 665 return m_exitCode; | 669 return m_exitCode; |
| 666 } | 670 } |
| 667 | 671 |
| 668 } // namespace blink | 672 } // namespace blink |
| OLD | NEW |