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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioWorkletGlobalScope.h

Issue 2903703003: Use wrapper tracing for worklets. (Closed)
Patch Set: Separating in two CLs 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
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 AudioWorkletGlobalScope_h 5 #ifndef AudioWorkletGlobalScope_h
6 #define AudioWorkletGlobalScope_h 6 #define AudioWorkletGlobalScope_h
7 7
8 #include "bindings/core/v8/ScriptValue.h" 8 #include "bindings/core/v8/ScriptValue.h"
9 #include "core/dom/ExecutionContext.h" 9 #include "core/dom/ExecutionContext.h"
10 #include "core/workers/ThreadedWorkletGlobalScope.h" 10 #include "core/workers/ThreadedWorkletGlobalScope.h"
11 #include "modules/ModulesExport.h" 11 #include "modules/ModulesExport.h"
12 #include "platform/bindings/ScriptWrappable.h"
12 13
13 namespace blink { 14 namespace blink {
14 15
15 class AudioBuffer; 16 class AudioBuffer;
16 class AudioWorkletProcessor; 17 class AudioWorkletProcessor;
17 class AudioWorkletProcessorDefinition; 18 class AudioWorkletProcessorDefinition;
18 class ExceptionState; 19 class ExceptionState;
19 20
20 // This is constructed and destroyed on a worker thread, and all methods also 21 // This is constructed and destroyed on a worker thread, and all methods also
21 // must be called on the worker thread. 22 // must be called on the worker thread.
22 class MODULES_EXPORT AudioWorkletGlobalScope final 23 class MODULES_EXPORT AudioWorkletGlobalScope final
23 : public ThreadedWorkletGlobalScope { 24 : public ThreadedWorkletGlobalScope {
24 DEFINE_WRAPPERTYPEINFO(); 25 DEFINE_WRAPPERTYPEINFO();
25 26
26 public: 27 public:
27 static AudioWorkletGlobalScope* Create(const KURL&, 28 static AudioWorkletGlobalScope* Create(const KURL&,
28 const String& user_agent, 29 const String& user_agent,
29 PassRefPtr<SecurityOrigin>, 30 PassRefPtr<SecurityOrigin>,
30 v8::Isolate*, 31 v8::Isolate*,
31 WorkerThread*); 32 WorkerThread*);
32 ~AudioWorkletGlobalScope() override; 33 ~AudioWorkletGlobalScope() override;
33 void Dispose() final;
34 bool IsAudioWorkletGlobalScope() const final { return true; } 34 bool IsAudioWorkletGlobalScope() const final { return true; }
35 void registerProcessor(const String& name, 35 void registerProcessor(const String& name,
36 const ScriptValue& class_definition, 36 const ScriptValue& class_definition,
37 ExceptionState&); 37 ExceptionState&);
38 38
39 // Creates an instance of AudioWorkletProcessor from a registered name. This 39 // Creates an instance of AudioWorkletProcessor from a registered name. This
40 // function may return nullptr when 1) a definition cannot be found or 2) a 40 // function may return nullptr when 1) a definition cannot be found or 2) a
41 // new V8 object cannot be constructed for some reason. 41 // new V8 object cannot be constructed for some reason.
42 AudioWorkletProcessor* CreateInstance(const String& name); 42 AudioWorkletProcessor* CreateInstance(const String& name);
43 43
44 // Invokes the JS audio processing function from an instance of 44 // Invokes the JS audio processing function from an instance of
45 // AudioWorkletProcessor, along with given AudioBuffer from the audio graph. 45 // AudioWorkletProcessor, along with given AudioBuffer from the audio graph.
46 bool Process(AudioWorkletProcessor*, 46 bool Process(AudioWorkletProcessor*,
47 AudioBuffer* input_buffer, 47 AudioBuffer* input_buffer,
48 AudioBuffer* output_buffer); 48 AudioBuffer* output_buffer);
49 49
50 AudioWorkletProcessorDefinition* FindDefinition(const String& name); 50 AudioWorkletProcessorDefinition* FindDefinition(const String& name);
51 51
52 DECLARE_TRACE(); 52 DECLARE_TRACE();
53 DECLARE_TRACE_WRAPPERS();
53 54
54 private: 55 private:
55 AudioWorkletGlobalScope(const KURL&, 56 AudioWorkletGlobalScope(const KURL&,
56 const String& user_agent, 57 const String& user_agent,
57 PassRefPtr<SecurityOrigin>, 58 PassRefPtr<SecurityOrigin>,
58 v8::Isolate*, 59 v8::Isolate*,
59 WorkerThread*); 60 WorkerThread*);
60 61
61 typedef HeapHashMap<String, Member<AudioWorkletProcessorDefinition>> 62 typedef HeapHashMap<String,
63 TraceWrapperMember<AudioWorkletProcessorDefinition>>
62 ProcessorDefinitionMap; 64 ProcessorDefinitionMap;
63 typedef HeapVector<Member<AudioWorkletProcessor>> ProcessorInstances; 65 typedef HeapVector<TraceWrapperMember<AudioWorkletProcessor>>
66 ProcessorInstances;
64 67
65 ProcessorDefinitionMap processor_definition_map_; 68 ProcessorDefinitionMap processor_definition_map_;
66 ProcessorInstances processor_instances_; 69 ProcessorInstances processor_instances_;
67 }; 70 };
68 71
69 } // namespace blink 72 } // namespace blink
70 73
71 #endif // AudioWorkletGlobalScope_h 74 #endif // AudioWorkletGlobalScope_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698