Chromium Code Reviews| Index: Source/modules/webmidi/MIDIAccess.h |
| diff --git a/Source/modules/webmidi/MIDIPort.h b/Source/modules/webmidi/MIDIAccess.h |
| similarity index 69% |
| copy from Source/modules/webmidi/MIDIPort.h |
| copy to Source/modules/webmidi/MIDIAccess.h |
| index 4352b2c2a7bb60456ec92969b0cd9d73aa175ecf..e3b8f68c7eb06b2e6a01850d0c69ea2b394d6143 100644 |
| --- a/Source/modules/webmidi/MIDIPort.h |
| +++ b/Source/modules/webmidi/MIDIAccess.h |
| @@ -28,65 +28,64 @@ |
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| -#ifndef MIDIPort_h |
| -#define MIDIPort_h |
| +#ifndef MIDIAccess_h |
| +#define MIDIAccess_h |
| #include "core/dom/ActiveDOMObject.h" |
| #include "core/dom/EventTarget.h" |
| +#include "modules/webmidi/MIDIPort.h" |
| #include "wtf/RefCounted.h" |
| #include "wtf/RefPtr.h" |
| #include "wtf/Vector.h" |
| namespace WebCore { |
| -class MIDIPort : public ActiveDOMObject, public RefCounted<MIDIPort>, public EventTarget { |
| -public: |
| - enum MIDIPortTypeCode { |
| - MIDIPortTypeInput, |
| - MIDIPortTypeOutput |
| - }; |
| - |
| - static PassRefPtr<MIDIPort> create(ScriptExecutionContext*, const String& id, const String& manufacturer, const String& name, MIDIPortTypeCode, const String& version); |
| - virtual ~MIDIPort(); |
| - |
| - 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; } |
| - |
| - using RefCounted<MIDIPort>::ref; |
| - using RefCounted<MIDIPort>::deref; |
| +class MIDIInput; |
| +class MIDIOutput; |
| +class Navigator; |
|
haraken
2013/04/26 17:33:25
Nit: This isn't needed.
|
| +class ScriptExecutionContext; |
| +class MIDIAccess : public ActiveDOMObject, public RefCounted<MIDIAccess>, public EventTarget { |
| +public: |
| + virtual ~MIDIAccess(); |
|
Chris Rogers
2013/04/29 19:22:09
small nit: I'd move this destructor after the crea
|
| + static PassRefPtr<MIDIAccess> create(ScriptExecutionContext*); |
| + |
| + const MIDIPortVector& getInputs(); |
| + const MIDIPortVector& getOutputs(); |
| + RefPtr<MIDIInput> getInput(PassRefPtr<MIDIPort>, ExceptionCode&); |
| + RefPtr<MIDIInput> getInput(const String&, ExceptionCode&); |
| + RefPtr<MIDIInput> getInput(short, ExceptionCode&); |
| + RefPtr<MIDIOutput> getOutput(PassRefPtr<MIDIPort>, ExceptionCode&); |
| + RefPtr<MIDIOutput> getOutput(const String&, ExceptionCode&); |
| + RefPtr<MIDIOutput> getOutput(short, ExceptionCode&); |
| + |
| + using RefCounted<MIDIAccess>::ref; |
| + using RefCounted<MIDIAccess>::deref; |
| + |
| + DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); |
| DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); |
| // EventTarget |
| - virtual const AtomicString& interfaceName() const OVERRIDE { return eventNames().interfaceForMIDIPort; } |
| + virtual const AtomicString& interfaceName() const OVERRIDE { return eventNames().interfaceForMIDIAccess; } |
| virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { return ActiveDOMObject::scriptExecutionContext(); } |
| // ActiveDOMObject |
| virtual bool canSuspend() const OVERRIDE { return true; } |
| -protected: |
| - MIDIPort(ScriptExecutionContext*, const String& id, const String& manufacturer, const String& name, MIDIPortTypeCode, const String& version); |
| - |
| private: |
| + explicit MIDIAccess(ScriptExecutionContext*); |
| + |
| // 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; |
| + MIDIPortVector m_inputs; |
| + MIDIPortVector m_outputs; |
| EventTargetData m_eventTargetData; |
| }; |
| -typedef Vector<RefPtr<MIDIPort> > MIDIPortVector; |
| - |
| } // namespace WebCore |
| -#endif // MIDIPort_h |
| +#endif // MIDIAccess_h |