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

Side by Side Diff: Source/modules/webmidi/MIDIAccessInitializer.h

Issue 1148383012: Oilpan: prefer eager finalization over prefinalizers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: expand&improve comments Created 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 MIDIAccessInitializer_h 5 #ifndef MIDIAccessInitializer_h
6 #define MIDIAccessInitializer_h 6 #define MIDIAccessInitializer_h
7 7
8 #include "bindings/core/v8/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "modules/ModulesExport.h" 10 #include "modules/ModulesExport.h"
11 #include "modules/webmidi/MIDIAccessor.h" 11 #include "modules/webmidi/MIDIAccessor.h"
12 #include "modules/webmidi/MIDIAccessorClient.h" 12 #include "modules/webmidi/MIDIAccessorClient.h"
13 #include "modules/webmidi/MIDIPort.h" 13 #include "modules/webmidi/MIDIPort.h"
14 #include "wtf/OwnPtr.h" 14 #include "wtf/OwnPtr.h"
15 #include "wtf/Vector.h" 15 #include "wtf/Vector.h"
16 16
17 namespace blink { 17 namespace blink {
18 18
19 class MIDIOptions; 19 class MIDIOptions;
20 class ScriptState; 20 class ScriptState;
21 21
22 class MODULES_EXPORT MIDIAccessInitializer : public ScriptPromiseResolver, publi c MIDIAccessorClient { 22 class MODULES_EXPORT MIDIAccessInitializer : public ScriptPromiseResolver, publi c MIDIAccessorClient {
23 WILL_BE_USING_PRE_FINALIZER(MIDIAccessInitializer, dispose);
24 public: 23 public:
25 struct PortDescriptor { 24 struct PortDescriptor {
26 String id; 25 String id;
27 String manufacturer; 26 String manufacturer;
28 String name; 27 String name;
29 MIDIPort::TypeCode type; 28 MIDIPort::TypeCode type;
30 String version; 29 String version;
31 MIDIAccessor::MIDIPortState state; 30 MIDIAccessor::MIDIPortState state;
32 31
33 PortDescriptor(const String& id, const String& manufacturer, const Strin g& name, MIDIPort::TypeCode type, const String& version, MIDIAccessor::MIDIPortS tate state) 32 PortDescriptor(const String& id, const String& manufacturer, const Strin g& name, MIDIPort::TypeCode type, const String& version, MIDIAccessor::MIDIPortS tate state)
34 : id(id) 33 : id(id)
35 , manufacturer(manufacturer) 34 , manufacturer(manufacturer)
36 , name(name) 35 , name(name)
37 , type(type) 36 , type(type)
38 , version(version) 37 , version(version)
39 , state(state) { } 38 , state(state) { }
40 }; 39 };
41 40
42 static ScriptPromise start(ScriptState* scriptState, const MIDIOptions& opti ons) 41 static ScriptPromise start(ScriptState* scriptState, const MIDIOptions& opti ons)
43 { 42 {
44 RefPtrWillBeRawPtr<MIDIAccessInitializer> resolver = adoptRefWillBeNoop( new MIDIAccessInitializer(scriptState, options)); 43 RefPtrWillBeRawPtr<MIDIAccessInitializer> resolver = adoptRefWillBeNoop( new MIDIAccessInitializer(scriptState, options));
45 resolver->keepAliveWhilePending(); 44 resolver->keepAliveWhilePending();
46 resolver->suspendIfNeeded(); 45 resolver->suspendIfNeeded();
47 return resolver->start(); 46 return resolver->start();
48 } 47 }
49 48
50 ~MIDIAccessInitializer() override; 49 ~MIDIAccessInitializer() override;
51 50
51 // Eager finalization to allow dispose() operation access
52 // other (non eager) heap objects.
53 EAGERLY_FINALIZE();
54
52 // MIDIAccessorClient 55 // MIDIAccessorClient
53 void didAddInputPort(const String& id, const String& manufacturer, const Str ing& name, const String& version, MIDIAccessor::MIDIPortState) override; 56 void didAddInputPort(const String& id, const String& manufacturer, const Str ing& name, const String& version, MIDIAccessor::MIDIPortState) override;
54 void didAddOutputPort(const String& id, const String& manufacturer, const St ring& name, const String& version, MIDIAccessor::MIDIPortState) override; 57 void didAddOutputPort(const String& id, const String& manufacturer, const St ring& name, const String& version, MIDIAccessor::MIDIPortState) override;
55 void didSetInputPortState(unsigned portIndex, MIDIAccessor::MIDIPortState) o verride; 58 void didSetInputPortState(unsigned portIndex, MIDIAccessor::MIDIPortState) o verride;
56 void didSetOutputPortState(unsigned portIndex, MIDIAccessor::MIDIPortState) override; 59 void didSetOutputPortState(unsigned portIndex, MIDIAccessor::MIDIPortState) override;
57 void didStartSession(bool success, const String& error, const String& messag e) override; 60 void didStartSession(bool success, const String& error, const String& messag e) override;
58 void didReceiveMIDIData(unsigned portIndex, const unsigned char* data, size_ t length, double timeStamp) override { } 61 void didReceiveMIDIData(unsigned portIndex, const unsigned char* data, size_ t length, double timeStamp) override { }
59 62
60 void resolveSysexPermission(bool allowed); 63 void resolveSysexPermission(bool allowed);
61 SecurityOrigin* securityOrigin() const; 64 SecurityOrigin* securityOrigin() const;
(...skipping 10 matching lines...) Expand all
72 OwnPtr<MIDIAccessor> m_accessor; 75 OwnPtr<MIDIAccessor> m_accessor;
73 Vector<PortDescriptor> m_portDescriptors; 76 Vector<PortDescriptor> m_portDescriptors;
74 bool m_requestSysex; 77 bool m_requestSysex;
75 bool m_hasBeenDisposed; 78 bool m_hasBeenDisposed;
76 bool m_sysexPermissionResolved; 79 bool m_sysexPermissionResolved;
77 }; 80 };
78 81
79 } // namespace blink 82 } // namespace blink
80 83
81 #endif // MIDIAccessInitializer_h 84 #endif // MIDIAccessInitializer_h
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerRegistration.cpp ('k') | Source/modules/webmidi/MIDIAccessInitializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698