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

Unified Diff: third_party/WebKit/Source/modules/webaudio/AudioWorkletObjectProxy.cpp

Issue 2793593002: AudioWorklet prototype
Patch Set: Merge changes, AudioParam bug fix Created 3 years, 5 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/AudioWorkletObjectProxy.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioWorkletObjectProxy.cpp b/third_party/WebKit/Source/modules/webaudio/AudioWorkletObjectProxy.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8777c5f86d914a350b35b03cec4719fa2b7a166e
--- /dev/null
+++ b/third_party/WebKit/Source/modules/webaudio/AudioWorkletObjectProxy.cpp
@@ -0,0 +1,69 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "modules/webaudio/AudioWorkletObjectProxy.h"
+
+#include <memory>
+#include "bindings/core/v8/ScriptSourceCode.h"
+#include "bindings/core/v8/WorkerOrWorkletScriptController.h"
+#include "core/workers/WorkerThread.h"
+#include "modules/webaudio/AudioWorkletGlobalScope.h"
+#include "modules/webaudio/AudioWorkletMessagingProxy.h"
+#include "modules/webaudio/AudioWorkletNode.h"
+#include "modules/webaudio/AudioWorkletProcessor.h"
+#include "modules/webaudio/AudioWorkletProcessorDefinition.h"
+#include "platform/wtf/PtrUtil.h"
+
+
+namespace blink {
+
+std::unique_ptr<AudioWorkletObjectProxy> AudioWorkletObjectProxy::Create(
+ AudioWorkletMessagingProxy* messaging_proxy_weak_ptr,
+ ParentFrameTaskRunners* parent_frame_task_runners) {
+ DCHECK(messaging_proxy_weak_ptr);
+ return WTF::WrapUnique(new AudioWorkletObjectProxy(
+ messaging_proxy_weak_ptr, parent_frame_task_runners));
+}
+
+AudioWorkletObjectProxy::~AudioWorkletObjectProxy() {}
+
+void AudioWorkletObjectProxy::EvaluateScript(const String& source,
+ const KURL& script_url,
+ WorkerThread* worker_thread) {
+ AudioWorkletGlobalScope* global_scope =
+ ToAudioWorkletGlobalScope(worker_thread->GlobalScope());
+ global_scope->ScriptController()->Evaluate(
+ ScriptSourceCode(source, script_url));
+}
+
+void AudioWorkletObjectProxy::CreateProcessorInstance(
+ const String& name,
+ AudioWorkletHandler* handler,
+ WaitableEvent* done,
+ WorkerThread* worker_thread) {
+ AudioWorkletGlobalScope* global_scope =
+ ToAudioWorkletGlobalScope(worker_thread->GlobalScope());
+ ScriptState* script_state =
+ global_scope->ScriptController()->GetScriptState();
+
+ ScriptState::Scope scope(script_state);
+
+ AudioWorkletProcessor* processor = global_scope->CreateInstance(name);
+ handler->SetProcessorOnRenderingThread(processor);
+
+ done->Signal();
+}
+
+AudioWorkletObjectProxy::AudioWorkletObjectProxy(
+ AudioWorkletMessagingProxy* messaging_proxy_weak_ptr,
+ ParentFrameTaskRunners* parent_frame_task_runners)
+ : ThreadedObjectProxyBase(parent_frame_task_runners),
+ messaging_proxy_weak_ptr_(messaging_proxy_weak_ptr) {}
+
+CrossThreadWeakPersistent<ThreadedMessagingProxyBase>
+AudioWorkletObjectProxy::MessagingProxyWeakPtr() {
+ return messaging_proxy_weak_ptr_;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698