| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/workers/WorkerBackingThread.h" | 5 #include "core/workers/WorkerBackingThread.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
| 9 #include "bindings/core/v8/V8GCController.h" | 9 #include "bindings/core/v8/V8GCController.h" |
| 10 #include "bindings/core/v8/V8IdleTaskRunner.h" | 10 #include "bindings/core/v8/V8IdleTaskRunner.h" |
| 11 #include "bindings/core/v8/V8Initializer.h" | 11 #include "bindings/core/v8/V8Initializer.h" |
| 12 #include "bindings/core/v8/V8PerIsolateData.h" | 12 #include "bindings/core/v8/V8PerIsolateData.h" |
| 13 #include "core/inspector/WorkerThreadDebugger.h" | 13 #include "core/inspector/WorkerThreadDebugger.h" |
| 14 #include "platform/CrossThreadFunctional.h" | 14 #include "platform/CrossThreadFunctional.h" |
| 15 #include "platform/RuntimeEnabledFeatures.h" | 15 #include "platform/RuntimeEnabledFeatures.h" |
| 16 #include "platform/WebThreadSupportingGC.h" | 16 #include "platform/WebThreadSupportingGC.h" |
| 17 #include "platform/scheduler/child/webthread_impl_for_worker_scheduler.h" |
| 18 #include "platform/scheduler/child/worker_global_scope_scheduler.h" |
| 17 #include "platform/wtf/PtrUtil.h" | 19 #include "platform/wtf/PtrUtil.h" |
| 18 #include "public/platform/Platform.h" | 20 #include "public/platform/Platform.h" |
| 19 #include "public/platform/WebTraceLocation.h" | 21 #include "public/platform/WebTraceLocation.h" |
| 20 | 22 |
| 21 namespace blink { | 23 namespace blink { |
| 22 | 24 |
| 23 #define DEFINE_STATIC_LOCAL_WITH_LOCK(type, name, arguments) \ | 25 #define DEFINE_STATIC_LOCAL_WITH_LOCK(type, name, arguments) \ |
| 24 ASSERT(IsolatesMutex().Locked()); \ | 26 ASSERT(IsolatesMutex().Locked()); \ |
| 25 static type& name = *new type arguments | 27 static type& name = *new type arguments |
| 26 | 28 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // This statement runs only in tests. | 93 // This statement runs only in tests. |
| 92 V8GCController::CollectAllGarbageForTesting(isolate_); | 94 V8GCController::CollectAllGarbageForTesting(isolate_); |
| 93 } | 95 } |
| 94 backing_thread_->Shutdown(); | 96 backing_thread_->Shutdown(); |
| 95 | 97 |
| 96 RemoveWorkerIsolate(isolate_); | 98 RemoveWorkerIsolate(isolate_); |
| 97 V8PerIsolateData::Destroy(isolate_); | 99 V8PerIsolateData::Destroy(isolate_); |
| 98 isolate_ = nullptr; | 100 isolate_ = nullptr; |
| 99 } | 101 } |
| 100 | 102 |
| 103 std::unique_ptr<scheduler::WorkerGlobalScopeScheduler> |
| 104 WorkerBackingThread::CreateGlobalScopeScheduler() { |
| 105 scheduler::WebThreadImplForWorkerScheduler& web_thread_for_worker = |
| 106 static_cast<scheduler::WebThreadImplForWorkerScheduler&>( |
| 107 BackingThread().PlatformThread()); |
| 108 return WTF::MakeUnique<scheduler::WorkerGlobalScopeScheduler>( |
| 109 web_thread_for_worker.GetWorkerScheduler()); |
| 110 } |
| 111 |
| 101 // static | 112 // static |
| 102 void WorkerBackingThread::MemoryPressureNotificationToWorkerThreadIsolates( | 113 void WorkerBackingThread::MemoryPressureNotificationToWorkerThreadIsolates( |
| 103 v8::MemoryPressureLevel level) { | 114 v8::MemoryPressureLevel level) { |
| 104 MutexLocker lock(IsolatesMutex()); | 115 MutexLocker lock(IsolatesMutex()); |
| 105 for (v8::Isolate* isolate : Isolates()) | 116 for (v8::Isolate* isolate : Isolates()) |
| 106 isolate->MemoryPressureNotification(level); | 117 isolate->MemoryPressureNotification(level); |
| 107 } | 118 } |
| 108 | 119 |
| 109 // static | 120 // static |
| 110 void WorkerBackingThread::SetRAILModeOnWorkerThreadIsolates( | 121 void WorkerBackingThread::SetRAILModeOnWorkerThreadIsolates( |
| 111 v8::RAILMode rail_mode) { | 122 v8::RAILMode rail_mode) { |
| 112 MutexLocker lock(IsolatesMutex()); | 123 MutexLocker lock(IsolatesMutex()); |
| 113 for (v8::Isolate* isolate : Isolates()) | 124 for (v8::Isolate* isolate : Isolates()) |
| 114 isolate->SetRAILMode(rail_mode); | 125 isolate->SetRAILMode(rail_mode); |
| 115 } | 126 } |
| 116 | 127 |
| 117 } // namespace blink | 128 } // namespace blink |
| OLD | NEW |