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 AudioWorkletMessagingProxy_h | 5 #ifndef AudioWorkletMessagingProxy_h |
6 #define AudioWorkletMessagingProxy_h | 6 #define AudioWorkletMessagingProxy_h |
7 | 7 |
8 #include <memory> | 8 #include "core/CoreExport.h" |
9 #include "core/workers/ThreadedWorkletMessagingProxy.h" | 9 #include "core/loader/WorkletScriptLoader.h" |
10 #include "platform/wtf/Allocator.h" | 10 #include "core/workers/ThreadedMessagingProxyBase.h" |
11 #include "core/workers/WorkletGlobalScopeProxy.h" | |
12 #include "core/workers/WorkletPendingTasks.h" | |
13 #include "platform/wtf/WeakPtr.h" | |
11 | 14 |
12 namespace blink { | 15 namespace blink { |
13 | 16 |
14 class ExecutionContext; | 17 class AudioWorkletHandler; |
15 class WorkerThread; | 18 class AudioWorkletObjectProxy; |
19 class ScriptSourceCode; | |
20 class WaitableEvent; | |
21 class WebThreadSupportingGC; | |
16 | 22 |
17 class AudioWorkletMessagingProxy final : public ThreadedWorkletMessagingProxy { | 23 // NOTE: Currently this class is a duplication of ThreadedWorkletMessagingProxy, |
18 USING_FAST_MALLOC(AudioWorkletMessagingProxy); | 24 // because it needs to have the ownership of the worker thread. |
25 // | |
26 // When rebasing the code, make sure to copy the behavior of | |
27 // |ThreadedWorkletMessagingProxy| instead of inheriting from it. Think of this | |
28 // class is a composition of |ThreadedWorkletMessagingProxy| and | |
29 // |AudioWorkletMessagingProxy|. This is because we need a direct access of | |
30 // |worklet_object_proxy| from BaseAudioContext. | |
19 | 31 |
32 class CORE_EXPORT AudioWorkletMessagingProxy | |
33 : public ThreadedMessagingProxyBase, | |
34 public WorkletGlobalScopeProxy { | |
20 public: | 35 public: |
21 AudioWorkletMessagingProxy(ExecutionContext*, WorkerClients*); | 36 AudioWorkletMessagingProxy(ExecutionContext*, WorkerClients*); |
22 | 37 |
38 // WorkletGlobalScopeProxy implementation. | |
39 void FetchAndInvokeScript(const KURL& module_url_record, | |
40 WebURLRequest::FetchCredentialsMode, | |
41 RefPtr<WebTaskRunner> outside_settings_task_runner, | |
42 WorkletPendingTasks*) final; | |
43 void TerminateWorkletGlobalScope() final; | |
44 void Initialize(); | |
45 | |
46 // This blocks the main thread until the rendering thread completes the | |
47 // creation of AudioWorkletProcessor. | |
48 void CreateProcessorInstance(const String& name, | |
49 AudioWorkletHandler*, | |
50 WaitableEvent*); | |
51 | |
52 // This returns the rendering thread so it can be passed to AudioDestination. | |
53 WebThreadSupportingGC* GetRenderingThread(); | |
54 | |
23 protected: | 55 protected: |
24 ~AudioWorkletMessagingProxy() override; | 56 ~AudioWorkletMessagingProxy(); |
57 | |
58 AudioWorkletObjectProxy& WorkletObjectProxy() { | |
59 return *worklet_object_proxy_; | |
60 } | |
25 | 61 |
26 std::unique_ptr<WorkerThread> CreateWorkerThread(double origin_time) override; | 62 std::unique_ptr<WorkerThread> CreateWorkerThread(double origin_time) override; |
63 | |
64 private: | |
65 friend class AudioWorkletMessagingProxyForTest; | |
66 class LoaderClient; | |
67 | |
68 void NotifyLoadingFinished(WorkletScriptLoader*); | |
69 void EvaluateScript(const ScriptSourceCode&); | |
70 | |
71 std::unique_ptr<AudioWorkletObjectProxy> worklet_object_proxy_; | |
nhiroki
2017/06/07 14:43:52
If having the AudioWorkletObjectProxy is the only
| |
72 HashSet<Persistent<WorkletScriptLoader>> loaders_; | |
73 WeakPtrFactory<AudioWorkletMessagingProxy> weak_ptr_factory_; | |
27 }; | 74 }; |
28 | 75 |
29 } // namespace blink | 76 } // namespace blink |
30 | 77 |
31 #endif // AudioWorkletMessagingProxy_h | 78 #endif // AudioWorkletMessagingProxy_h |
OLD | NEW |