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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioWorkletObjectProxy.cpp

Issue 2793593002: AudioWorklet prototype
Patch Set: Rebase after ThreadedWorkletMessaginProxy change Created 3 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "modules/webaudio/AudioWorkletObjectProxy.h"
6
7 #include <memory>
8 #include "bindings/core/v8/ScriptSourceCode.h"
9 #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
10 #include "core/workers/WorkerThread.h"
11 #include "modules/webaudio/AudioWorkletGlobalScope.h"
12 #include "modules/webaudio/AudioWorkletMessagingProxy.h"
13 #include "modules/webaudio/AudioWorkletNode.h"
14 #include "modules/webaudio/AudioWorkletProcessor.h"
15 #include "modules/webaudio/AudioWorkletProcessorDefinition.h"
16 #include "platform/wtf/PtrUtil.h"
17
18
19 namespace blink {
20
21 std::unique_ptr<AudioWorkletObjectProxy> AudioWorkletObjectProxy::Create(
22 const WeakPtr<AudioWorkletMessagingProxy>& messaging_proxy_weak_ptr,
23 ParentFrameTaskRunners* parent_frame_task_runners) {
24 DCHECK(messaging_proxy_weak_ptr);
25 return WTF::WrapUnique(new AudioWorkletObjectProxy(
26 messaging_proxy_weak_ptr, parent_frame_task_runners));
27 }
28
29 AudioWorkletObjectProxy::~AudioWorkletObjectProxy() {}
30
31 void AudioWorkletObjectProxy::EvaluateScript(const String& source,
32 const KURL& script_url,
33 WorkerThread* worker_thread) {
34 AudioWorkletGlobalScope* global_scope =
35 ToAudioWorkletGlobalScope(worker_thread->GlobalScope());
36 global_scope->ScriptController()->Evaluate(
37 ScriptSourceCode(source, script_url));
38 }
39
40 void AudioWorkletObjectProxy::CreateProcessorInstance(
41 const String& name,
42 AudioWorkletHandler* handler,
43 WaitableEvent* done,
44 WorkerThread* worker_thread) {
45 AudioWorkletGlobalScope* global_scope =
46 ToAudioWorkletGlobalScope(worker_thread->GlobalScope());
47 ScriptState* script_state =
48 global_scope->ScriptController()->GetScriptState();
49
50 ScriptState::Scope scope(script_state);
51
52 AudioWorkletProcessor* processor = global_scope->CreateInstance(name);
53 handler->SetProcessor(processor);
54
55 done->Signal();
56 }
57
58 AudioWorkletObjectProxy::AudioWorkletObjectProxy(
59 const WeakPtr<AudioWorkletMessagingProxy>& messaging_proxy_weak_ptr,
60 ParentFrameTaskRunners* parent_frame_task_runners)
61 : ThreadedObjectProxyBase(parent_frame_task_runners),
62 messaging_proxy_weak_ptr_(messaging_proxy_weak_ptr) {}
63
64 WeakPtr<ThreadedMessagingProxyBase>
65 AudioWorkletObjectProxy::MessagingProxyWeakPtr() {
66 return messaging_proxy_weak_ptr_;
67 }
68
69 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698