Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1174)

Unified Diff: third_party/WebKit/Source/modules/webaudio/AudioWorkletMessagingProxy.h

Issue 2793593002: AudioWorklet prototype
Patch Set: Rebase after ThreadedWorkletMessaginProxy change Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 ae16cf6910446937d5e32d7011dc206e0dfeb4f6..acfd56473ef94392947fbeb1511eb61a9e360cad 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioWorkletMessagingProxy.h
+++ b/third_party/WebKit/Source/modules/webaudio/AudioWorkletMessagingProxy.h
@@ -5,25 +5,72 @@
#ifndef AudioWorkletMessagingProxy_h
#define AudioWorkletMessagingProxy_h
-#include <memory>
-#include "core/workers/ThreadedWorkletMessagingProxy.h"
-#include "platform/wtf/Allocator.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;
-class AudioWorkletMessagingProxy final : public ThreadedWorkletMessagingProxy {
- USING_FAST_MALLOC(AudioWorkletMessagingProxy);
+// 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 {
public:
AudioWorkletMessagingProxy(ExecutionContext*, WorkerClients*);
+ // WorkletGlobalScopeProxy implementation.
+ void FetchAndInvokeScript(const KURL& module_url_record,
+ WebURLRequest::FetchCredentialsMode,
+ RefPtr<WebTaskRunner> outside_settings_task_runner,
+ WorkletPendingTasks*) final;
+ void TerminateWorkletGlobalScope() final;
+ void Initialize();
+
+ // 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:
- ~AudioWorkletMessagingProxy() override;
+ ~AudioWorkletMessagingProxy();
+
+ AudioWorkletObjectProxy& WorkletObjectProxy() {
+ return *worklet_object_proxy_;
+ }
std::unique_ptr<WorkerThread> CreateWorkerThread(double origin_time) override;
+
+ private:
+ friend class AudioWorkletMessagingProxyForTest;
+ class LoaderClient;
+
+ void NotifyLoadingFinished(WorkletScriptLoader*);
+ void EvaluateScript(const ScriptSourceCode&);
+
+ std::unique_ptr<AudioWorkletObjectProxy> worklet_object_proxy_;
nhiroki 2017/06/07 14:43:52 If having the AudioWorkletObjectProxy is the only
+ HashSet<Persistent<WorkletScriptLoader>> loaders_;
+ WeakPtrFactory<AudioWorkletMessagingProxy> weak_ptr_factory_;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698