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

Unified Diff: Source/modules/webmidi/MIDIAccess.h

Issue 311733004: Introduce KeepAliveWhilePending to ScriptPromiseResolverWithContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@refactor-webmidi-initialization
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/webmidi/MIDIAccess.h
diff --git a/Source/modules/webmidi/MIDIAccess.h b/Source/modules/webmidi/MIDIAccess.h
index 215480e91c8ed5d1684ac75aca73534910ce9900..b543ec989f5eee934603c48f05db5b311e95954e 100644
--- a/Source/modules/webmidi/MIDIAccess.h
+++ b/Source/modules/webmidi/MIDIAccess.h
@@ -35,29 +35,32 @@
#include "bindings/v8/ScriptWrappable.h"
#include "core/dom/ActiveDOMObject.h"
#include "modules/EventTargetModules.h"
+#include "modules/webmidi/MIDIAccessInitializer.h"
#include "modules/webmidi/MIDIAccessor.h"
#include "modules/webmidi/MIDIAccessorClient.h"
#include "modules/webmidi/MIDIInput.h"
#include "modules/webmidi/MIDIOutput.h"
-#include "platform/AsyncMethodRunner.h"
#include "platform/heap/Handle.h"
#include "wtf/RefCounted.h"
#include "wtf/RefPtr.h"
-#include "wtf/WeakPtr.h"
+#include "wtf/Vector.h"
namespace WebCore {
class ExecutionContext;
-class MIDIAccessInitializer;
struct MIDIOptions;
class MIDIAccess FINAL : public RefCountedWillBeRefCountedGarbageCollected<MIDIAccess>, public ScriptWrappable, public ActiveDOMObject, public EventTargetWithInlineData, public MIDIAccessorClient {
REFCOUNTED_EVENT_TARGET(MIDIAccess);
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MIDIAccess);
public:
+ static PassRefPtrWillBeRawPtr<MIDIAccess> create(PassOwnPtr<MIDIAccessor> accessor, bool sysexEnabled, const Vector<MIDIAccessInitializer::PortDescriptor>& ports, ExecutionContext* executionContext)
+ {
+ RefPtrWillBeRawPtr<MIDIAccess> access = adoptRefWillBeRefCountedGarbageCollected(new MIDIAccess(accessor, sysexEnabled, ports, executionContext));
+ access->suspendIfNeeded();
+ return access;
+ }
virtual ~MIDIAccess();
- // Returns a promise object that will be resolved with this MIDIAccess.
- static ScriptPromise request(const MIDIOptions&, ScriptState*);
MIDIInputVector inputs() const { return m_inputs; }
MIDIOutputVector outputs() const { return m_outputs; }
@@ -73,7 +76,6 @@ public:
// ActiveDOMObject
virtual void stop() OVERRIDE;
- virtual bool hasPendingActivity() const OVERRIDE;
// MIDIAccessorClient
virtual void didAddInputPort(const String& id, const String& manufacturer, const String& name, const String& version) OVERRIDE;
@@ -89,21 +91,15 @@ public:
// |timeStampInMilliseconds| is in the same time coordinate system as performance.now().
void sendMIDIData(unsigned portIndex, const unsigned char* data, size_t length, double timeStampInMilliseconds);
- // Initialize this object before exposing it to JavaScript.
- void initialize(PassOwnPtr<MIDIAccessor>, bool sysexEnabled);
-
virtual void trace(Visitor*) OVERRIDE;
private:
- MIDIAccess(const MIDIOptions&, ExecutionContext*);
+ MIDIAccess(PassOwnPtr<MIDIAccessor>, bool sysexEnabled, const Vector<MIDIAccessInitializer::PortDescriptor>&, ExecutionContext*);
- MIDIInputVector m_inputs;
- MIDIOutputVector m_outputs;
OwnPtr<MIDIAccessor> m_accessor;
bool m_sysexEnabled;
-
- // FIXME: Stop owning initializer in this class.
- OwnPtr<MIDIAccessInitializer> m_initializer;
+ MIDIInputVector m_inputs;
+ MIDIOutputVector m_outputs;
};
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698