Index: third_party/WebKit/Source/modules/webaudio/AudioWorkletMessagingProxy.h |
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioWorkletMessagingProxy.h b/third_party/WebKit/Source/modules/webaudio/AudioWorkletMessagingProxy.h |
index 0fe739bce91097b24fb31b8bb8bb896fcf648772..f08b32afca8807d7c46088588b06071a0ad0852c 100644 |
--- a/third_party/WebKit/Source/modules/webaudio/AudioWorkletMessagingProxy.h |
+++ b/third_party/WebKit/Source/modules/webaudio/AudioWorkletMessagingProxy.h |
@@ -6,21 +6,75 @@ |
#define AudioWorkletMessagingProxy_h |
#include <memory> |
-#include "core/workers/ThreadedWorkletMessagingProxy.h" |
+#include "core/CoreExport.h" |
+#include "core/loader/WorkletScriptLoader.h" |
+#include "core/workers/ThreadedMessagingProxyBase.h" |
+#include "core/workers/WorkletGlobalScopeProxy.h" |
+#include "core/workers/WorkletPendingTasks.h" |
+#include "platform/wtf/WeakPtr.h" |
namespace blink { |
-class ExecutionContext; |
-class WorkerThread; |
+class AudioWorkletHandler; |
+class AudioWorkletObjectProxy; |
+class ScriptSourceCode; |
+class WaitableEvent; |
+class WebThreadSupportingGC; |
+ |
+// NOTE: Currently this class is a duplication of ThreadedWorkletMessagingProxy, |
+// because it needs to have the ownership of the worker thread. |
+// |
+// When rebasing the code, make sure to copy the behavior of |
+// |ThreadedWorkletMessagingProxy| instead of inheriting from it. Think of this |
+// class is a composition of |ThreadedWorkletMessagingProxy| and |
+// |AudioWorkletMessagingProxy|. This is because we need a direct access of |
+// |worklet_object_proxy| from BaseAudioContext. |
+ |
+class CORE_EXPORT AudioWorkletMessagingProxy |
+ : public ThreadedMessagingProxyBase, |
+ public WorkletGlobalScopeProxy { |
+ USING_GARBAGE_COLLECTED_MIXIN(AudioWorkletMessagingProxy); |
-class AudioWorkletMessagingProxy final : public ThreadedWorkletMessagingProxy { |
public: |
AudioWorkletMessagingProxy(ExecutionContext*, WorkerClients*); |
- private: |
- ~AudioWorkletMessagingProxy() override; |
+ // WorkletGlobalScopeProxy implementation. |
+ void FetchAndInvokeScript(const KURL& module_url_record, |
+ WebURLRequest::FetchCredentialsMode, |
+ RefPtr<WebTaskRunner> outside_settings_task_runner, |
+ WorkletPendingTasks*) final; |
+ void WorkletObjectDestroyed() final; |
+ void TerminateWorkletGlobalScope() final; |
+ |
+ void Initialize(); |
+ |
+ DECLARE_VIRTUAL_TRACE(); |
+ |
+ // This blocks the main thread until the rendering thread completes the |
+ // creation of AudioWorkletProcessor. |
+ void CreateProcessorInstance(const String& name, |
+ AudioWorkletHandler*, |
+ WaitableEvent*); |
+ // This returns the rendering thread so it can be passed to AudioDestination. |
+ WebThreadSupportingGC* GetRenderingThread(); |
+ |
+ protected: |
std::unique_ptr<WorkerThread> CreateWorkerThread(double origin_time) override; |
+ |
+ AudioWorkletObjectProxy& WorkletObjectProxy() { |
+ return *worklet_object_proxy_; |
+ } |
+ |
+ private: |
+ friend class AudioWorkletMessagingProxyForTest; |
+ class LoaderClient; |
+ |
+ void NotifyLoadingFinished(WorkletScriptLoader*); |
+ void EvaluateScript(const ScriptSourceCode&); |
+ |
+ std::unique_ptr<AudioWorkletObjectProxy> worklet_object_proxy_; |
+ HeapHashSet<Member<WorkletScriptLoader>> loaders_; |
}; |
} // namespace blink |