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

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

Issue 13843021: Web MIDI: implement MIDIPort (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: (rebase) Created 7 years, 8 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/MIDIPort.h
diff --git a/Source/modules/mediasource/SourceBufferList.h b/Source/modules/webmidi/MIDIPort.h
similarity index 53%
copy from Source/modules/mediasource/SourceBufferList.h
copy to Source/modules/webmidi/MIDIPort.h
index 7c5b2156c6e21f9e49cdd7af05ddddc055c0231f..4352b2c2a7bb60456ec92969b0cd9d73aa175ecf 100644
--- a/Source/modules/mediasource/SourceBufferList.h
+++ b/Source/modules/webmidi/MIDIPort.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,59 +28,65 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SourceBufferList_h
-#define SourceBufferList_h
+#ifndef MIDIPort_h
+#define MIDIPort_h
+#include "core/dom/ActiveDOMObject.h"
#include "core/dom/EventTarget.h"
#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
#include "wtf/Vector.h"
namespace WebCore {
-class SourceBuffer;
-class GenericEventQueue;
-
-class SourceBufferList : public RefCounted<SourceBufferList>, public EventTarget {
+class MIDIPort : public ActiveDOMObject, public RefCounted<MIDIPort>, public EventTarget {
public:
- static PassRefPtr<SourceBufferList> create(ScriptExecutionContext* context, GenericEventQueue* asyncEventQueue)
- {
- return adoptRef(new SourceBufferList(context, asyncEventQueue));
- }
- virtual ~SourceBufferList() { }
+ enum MIDIPortTypeCode {
+ MIDIPortTypeInput,
+ MIDIPortTypeOutput
+ };
- unsigned long length() const;
- SourceBuffer* item(unsigned index) const;
+ static PassRefPtr<MIDIPort> create(ScriptExecutionContext*, const String& id, const String& manufacturer, const String& name, MIDIPortTypeCode, const String& version);
+ virtual ~MIDIPort();
- void add(PassRefPtr<SourceBuffer>);
- bool remove(SourceBuffer*);
- void clear();
+ String id() const { return m_id; }
+ String manufacturer() const { return m_manufacturer; }
+ String name() const { return m_name; }
+ String type() const;
+ String version() const { return m_version; }
- // EventTarget interface
- virtual const AtomicString& interfaceName() const OVERRIDE;
- virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE;
+ using RefCounted<MIDIPort>::ref;
+ using RefCounted<MIDIPort>::deref;
- using RefCounted<SourceBufferList>::ref;
- using RefCounted<SourceBufferList>::deref;
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect);
-protected:
- virtual EventTargetData* eventTargetData() OVERRIDE;
- virtual EventTargetData* ensureEventTargetData() OVERRIDE;
+ // EventTarget
+ virtual const AtomicString& interfaceName() const OVERRIDE { return eventNames().interfaceForMIDIPort; }
+ virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { return ActiveDOMObject::scriptExecutionContext(); }
-private:
- SourceBufferList(ScriptExecutionContext*, GenericEventQueue*);
+ // ActiveDOMObject
+ virtual bool canSuspend() const OVERRIDE { return true; }
- void createAndFireEvent(const AtomicString&);
+protected:
+ MIDIPort(ScriptExecutionContext*, const String& id, const String& manufacturer, const String& name, MIDIPortTypeCode, const String& version);
+private:
+ // EventTarget
virtual void refEventTarget() OVERRIDE { ref(); }
virtual void derefEventTarget() OVERRIDE { deref(); }
-
+ virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetData; }
+ virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventTargetData; }
+
+ String m_id;
+ String m_manufacturer;
+ String m_name;
+ MIDIPortTypeCode m_type;
+ String m_version;
EventTargetData m_eventTargetData;
- ScriptExecutionContext* m_scriptExecutionContext;
- GenericEventQueue* m_asyncEventQueue;
-
- Vector<RefPtr<SourceBuffer> > m_list;
};
+typedef Vector<RefPtr<MIDIPort> > MIDIPortVector;
+
} // namespace WebCore
-#endif
+#endif // MIDIPort_h

Powered by Google App Engine
This is Rietveld 408576698