| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "modules/webmidi/MIDIAccessor.h" | 31 #include "modules/webmidi/MIDIAccessor.h" |
| 32 | 32 |
| 33 #include <memory> | 33 #include <memory> |
| 34 #include "modules/webmidi/MIDIAccessorClient.h" | 34 #include "modules/webmidi/MIDIAccessorClient.h" |
| 35 #include "platform/wtf/PtrUtil.h" | 35 #include "platform/wtf/PtrUtil.h" |
| 36 #include "platform/wtf/text/WTFString.h" | 36 #include "platform/wtf/text/WTFString.h" |
| 37 #include "public/platform/Platform.h" | 37 #include "public/platform/Platform.h" |
| 38 #include "public/platform/modules/webmidi/WebMIDIAccessor.h" | |
| 39 | 38 |
| 40 using blink::WebString; | 39 using blink::WebString; |
| 41 using midi::mojom::PortState; | 40 using midi::mojom::PortState; |
| 42 using midi::mojom::Result; | 41 using midi::mojom::Result; |
| 43 | 42 |
| 44 namespace blink { | 43 namespace blink { |
| 45 | 44 |
| 46 // Factory method | 45 // Factory method |
| 47 std::unique_ptr<MIDIAccessor> MIDIAccessor::Create(MIDIAccessorClient* client) { | 46 std::unique_ptr<MIDIAccessor> MIDIAccessor::Create(MIDIAccessorClient* client) { |
| 48 return WTF::WrapUnique(new MIDIAccessor(client)); | 47 return WTF::WrapUnique(new MIDIAccessor(client)); |
| 49 } | 48 } |
| 50 | 49 |
| 51 MIDIAccessor::MIDIAccessor(MIDIAccessorClient* client) : client_(client) { | 50 MIDIAccessor::MIDIAccessor(MIDIAccessorClient* client) : client_(client) { |
| 52 DCHECK(client); | 51 DCHECK(client); |
| 53 | 52 |
| 54 accessor_ = Platform::Current()->CreateMIDIAccessor(this); | 53 accessor_ = WTF::WrapUnique(Platform::Current()->CreateMIDIAccessor(this)); |
| 55 | 54 |
| 56 DCHECK(accessor_); | 55 DCHECK(accessor_); |
| 57 } | 56 } |
| 58 | 57 |
| 59 void MIDIAccessor::StartSession() { | 58 void MIDIAccessor::StartSession() { |
| 60 accessor_->StartSession(); | 59 accessor_->StartSession(); |
| 61 } | 60 } |
| 62 | 61 |
| 63 void MIDIAccessor::SendMIDIData(unsigned port_index, | 62 void MIDIAccessor::SendMIDIData(unsigned port_index, |
| 64 const unsigned char* data, | 63 const unsigned char* data, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 } | 95 } |
| 97 | 96 |
| 98 void MIDIAccessor::DidReceiveMIDIData(unsigned port_index, | 97 void MIDIAccessor::DidReceiveMIDIData(unsigned port_index, |
| 99 const unsigned char* data, | 98 const unsigned char* data, |
| 100 size_t length, | 99 size_t length, |
| 101 double time_stamp) { | 100 double time_stamp) { |
| 102 client_->DidReceiveMIDIData(port_index, data, length, time_stamp); | 101 client_->DidReceiveMIDIData(port_index, data, length, time_stamp); |
| 103 } | 102 } |
| 104 | 103 |
| 105 } // namespace blink | 104 } // namespace blink |
| OLD | NEW |