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

Unified Diff: media/midi/midi_service.h

Issue 2566673002: Web MIDI: introduce MidiService class (Closed)
Patch Set: lock Created 4 years 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
« no previous file with comments | « media/midi/midi_manager.h ('k') | media/midi/midi_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/midi/midi_service.h
diff --git a/media/midi/midi_service.h b/media/midi/midi_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..040ca0378e56d5c3428b725e2c30520f8365547b
--- /dev/null
+++ b/media/midi/midi_service.h
@@ -0,0 +1,55 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_MIDI_MIDI_SERVICE_H_
+#define MEDIA_MIDI_MIDI_SERVICE_H_
+
+#include <stdint.h>
+
+#include <memory>
+#include <vector>
+
+#include "base/macros.h"
+#include "base/synchronization/lock.h"
+#include "media/midi/midi_export.h"
+
+namespace midi {
+
+class MidiManager;
+class MidiManagerClient;
+
+// Manages MidiManager backends. This class expects to be constructed and
+// destructed on the browser main thread, but methods can be called on both
+// the main thread and the I/O thread.
+class MIDI_EXPORT MidiService {
yhirano 2016/12/13 04:02:30 +final
Takashi Toyoshima 2016/12/13 05:57:00 Done.
+ public:
+ // |MidiManager| can be explicitly specified in the constructor for testing.
+ explicit MidiService(MidiManager* manager_ = nullptr);
yhirano 2016/12/13 04:02:30 Can this parameter be a std::unique_ptr?
Takashi Toyoshima 2016/12/13 05:57:00 Done.
+ ~MidiService();
+
+ // Called on the browser main thread to notify the I/O thread will stop and
+ // the instance will be destructed on the main thread soon.
+ void Shutdown();
+
+ // A client calls StartSession() to receive and send MIDI data.
+ void StartSession(MidiManagerClient* client);
+
+ // A client calls EndSession() to stop receiving MIDI data.
+ void EndSession(MidiManagerClient* client);
+
+ // A client calls DispatchSendMidiData() to send MIDI data.
+ virtual void DispatchSendMidiData(MidiManagerClient* client,
+ uint32_t port_index,
+ const std::vector<uint8_t>& data,
+ double timestamp);
+
+ std::unique_ptr<MidiManager> manager_;
+ base::Lock lock_;
+
+ DISALLOW_COPY_AND_ASSIGN(MidiService);
+};
+
+} // namespace midi
+
+#endif // MEDIA_MIDI_MIDI_SERVICE_H_
« no previous file with comments | « media/midi/midi_manager.h ('k') | media/midi/midi_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698