Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_MIDI_MIDI_SERVICE_H_ | |
| 6 #define MEDIA_MIDI_MIDI_SERVICE_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <memory> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/macros.h" | |
| 14 #include "base/memory/ptr_util.h" | |
| 15 #include "base/synchronization/lock.h" | |
| 16 #include "media/midi/midi_export.h" | |
| 17 #include "media/midi/midi_manager.h" | |
| 18 | |
| 19 namespace midi { | |
| 20 | |
| 21 // Manages MidiManager backends. This class expects to be constructed and | |
| 22 // destructed on the browser main thread, but methods can be called on both | |
| 23 // the main thread and the I/O thread. | |
| 24 class MIDI_EXPORT MidiService final { | |
| 25 public: | |
| 26 // |MidiManager| can be explicitly specified in the constructor for testing. | |
| 27 explicit MidiService(std::unique_ptr<MidiManager> manager_ = | |
|
yhirano
2016/12/13 11:28:00
|manager_| should be |manager|.
Takashi Toyoshima
2016/12/13 12:08:02
Done.
| |
| 28 base::WrapUnique<MidiManager>(nullptr)); | |
|
yhirano
2016/12/13 11:28:00
Does |= nullptr| work? (It works on my local env).
Takashi Toyoshima
2016/12/13 12:08:02
Hum... I may have misread a compiler error. It see
| |
| 29 ~MidiService(); | |
| 30 | |
| 31 // Called on the browser main thread to notify the I/O thread will stop and | |
| 32 // the instance will be destructed on the main thread soon. | |
| 33 void Shutdown(); | |
| 34 | |
| 35 // A client calls StartSession() to receive and send MIDI data. | |
| 36 void StartSession(MidiManagerClient* client); | |
| 37 | |
| 38 // A client calls EndSession() to stop receiving MIDI data. | |
| 39 void EndSession(MidiManagerClient* client); | |
| 40 | |
| 41 // A client calls DispatchSendMidiData() to send MIDI data. | |
| 42 virtual void DispatchSendMidiData(MidiManagerClient* client, | |
| 43 uint32_t port_index, | |
| 44 const std::vector<uint8_t>& data, | |
| 45 double timestamp); | |
| 46 | |
| 47 std::unique_ptr<MidiManager> manager_; | |
| 48 base::Lock lock_; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(MidiService); | |
| 51 }; | |
| 52 | |
| 53 } // namespace midi | |
| 54 | |
| 55 #endif // MEDIA_MIDI_MIDI_SERVICE_H_ | |
| OLD | NEW |