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