| 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 #ifndef AudioWorkletThread_h | 5 #ifndef AudioWorkletThread_h |
| 6 #define AudioWorkletThread_h | 6 #define AudioWorkletThread_h |
| 7 | 7 |
| 8 #include "core/workers/WorkerLoaderProxy.h" | |
| 9 #include "core/workers/WorkerThread.h" | 8 #include "core/workers/WorkerThread.h" |
| 10 #include "core/workers/WorkletThreadHolder.h" | 9 #include "core/workers/WorkletThreadHolder.h" |
| 11 #include "modules/ModulesExport.h" | 10 #include "modules/ModulesExport.h" |
| 12 #include <memory> | 11 #include <memory> |
| 13 | 12 |
| 14 namespace blink { | 13 namespace blink { |
| 15 | 14 |
| 16 class WorkerReportingProxy; | 15 class WorkerReportingProxy; |
| 17 | 16 |
| 18 // AudioWorkletThread is a per-frame singleton object that represents the | 17 // AudioWorkletThread is a per-frame singleton object that represents the |
| 19 // backing thread for the processing of AudioWorkletNode/AudioWorkletProcessor. | 18 // backing thread for the processing of AudioWorkletNode/AudioWorkletProcessor. |
| 20 // It is supposed to run an instance of V8 isolate. | 19 // It is supposed to run an instance of V8 isolate. |
| 21 | 20 |
| 22 class MODULES_EXPORT AudioWorkletThread final : public WorkerThread { | 21 class MODULES_EXPORT AudioWorkletThread final : public WorkerThread { |
| 23 public: | 22 public: |
| 24 static std::unique_ptr<AudioWorkletThread> Create( | 23 static std::unique_ptr<AudioWorkletThread> Create(ThreadableLoadingContext*, |
| 25 PassRefPtr<WorkerLoaderProxy>, | 24 WorkerReportingProxy&); |
| 26 WorkerReportingProxy&); | |
| 27 ~AudioWorkletThread() override; | 25 ~AudioWorkletThread() override; |
| 28 | 26 |
| 29 WorkerBackingThread& GetWorkerBackingThread() override; | 27 WorkerBackingThread& GetWorkerBackingThread() override; |
| 30 | 28 |
| 31 // The backing thread is cleared by clearSharedBackingThread(). | 29 // The backing thread is cleared by clearSharedBackingThread(). |
| 32 void ClearWorkerBackingThread() override {} | 30 void ClearWorkerBackingThread() override {} |
| 33 | 31 |
| 34 // This may block the main thread. | 32 // This may block the main thread. |
| 35 static void CollectAllGarbage(); | 33 static void CollectAllGarbage(); |
| 36 | 34 |
| 37 static void EnsureSharedBackingThread(); | 35 static void EnsureSharedBackingThread(); |
| 38 static void ClearSharedBackingThread(); | 36 static void ClearSharedBackingThread(); |
| 39 | 37 |
| 40 static void CreateSharedBackingThreadForTest(); | 38 static void CreateSharedBackingThreadForTest(); |
| 41 | 39 |
| 42 protected: | 40 protected: |
| 43 WorkerOrWorkletGlobalScope* CreateWorkerGlobalScope( | 41 WorkerOrWorkletGlobalScope* CreateWorkerGlobalScope( |
| 44 std::unique_ptr<WorkerThreadStartupData>) final; | 42 std::unique_ptr<WorkerThreadStartupData>) final; |
| 45 | 43 |
| 46 bool IsOwningBackingThread() const override { return false; } | 44 bool IsOwningBackingThread() const override { return false; } |
| 47 | 45 |
| 48 private: | 46 private: |
| 49 AudioWorkletThread(PassRefPtr<WorkerLoaderProxy>, WorkerReportingProxy&); | 47 AudioWorkletThread(ThreadableLoadingContext*, WorkerReportingProxy&); |
| 50 }; | 48 }; |
| 51 | 49 |
| 52 } // namespace blink | 50 } // namespace blink |
| 53 | 51 |
| 54 #endif // AudioWorkletThread_h | 52 #endif // AudioWorkletThread_h |
| OLD | NEW |