Add some instrumentation for jank in URLRequest::Start.
[chromium-blink-merge.git] / media / midi / midi_manager_win.h
blob73c1fe57972d3173153d4638fc79f9a0376d75dc
1 // Copyright 2013 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.
5 #ifndef MEDIA_MIDI_MIDI_MANAGER_WIN_H_
6 #define MEDIA_MIDI_MIDI_MANAGER_WIN_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/thread.h"
13 #include "base/time/time.h"
14 #include "media/midi/midi_manager.h"
16 namespace media {
18 class MidiServiceWinDelegate {
19 public:
20 virtual ~MidiServiceWinDelegate() {}
21 virtual void OnCompleteInitialization(MidiResult result) = 0;
22 virtual void OnAddInputPort(MidiPortInfo info) = 0;
23 virtual void OnAddOutputPort(MidiPortInfo info) = 0;
24 virtual void OnSetInputPortState(uint32 port_index, MidiPortState state) = 0;
25 virtual void OnSetOutputPortState(uint32 port_index, MidiPortState state) = 0;
26 virtual void OnReceiveMidiData(uint32 port_index,
27 const std::vector<uint8>& data,
28 base::TimeTicks time) = 0;
31 class MidiServiceWin {
32 public:
33 virtual ~MidiServiceWin() {}
34 // This method may return before the initialization is completed.
35 virtual void InitializeAsync(MidiServiceWinDelegate* delegate) = 0;
36 // This method may return before the specified data is actually sent.
37 virtual void SendMidiDataAsync(uint32 port_number,
38 const std::vector<uint8>& data,
39 base::TimeTicks time) = 0;
42 class MidiManagerWin final : public MidiManager, public MidiServiceWinDelegate {
43 public:
44 MidiManagerWin() {}
45 ~MidiManagerWin() override { midi_service_.reset(); }
47 // MidiManager overrides:
48 void StartInitialization() final;
49 void DispatchSendMidiData(MidiManagerClient* client,
50 uint32 port_index,
51 const std::vector<uint8>& data,
52 double timestamp) final;
54 // MidiServiceWinDelegate overrides:
55 void OnCompleteInitialization(MidiResult result) final {
56 CompleteInitialization(result);
58 void OnAddInputPort(MidiPortInfo info) final { AddInputPort(info); }
59 void OnAddOutputPort(MidiPortInfo info) final { AddOutputPort(info); }
60 void OnSetInputPortState(uint32 port_index, MidiPortState state) final {
61 SetInputPortState(port_index, state);
63 void OnSetOutputPortState(uint32 port_index, MidiPortState state) final {
64 SetOutputPortState(port_index, state);
66 void OnReceiveMidiData(uint32 port_index,
67 const std::vector<uint8>& data,
68 base::TimeTicks time) final {
69 ReceiveMidiData(port_index, &data[0], data.size(), time);
72 private:
73 scoped_ptr<MidiServiceWin> midi_service_;
74 DISALLOW_COPY_AND_ASSIGN(MidiManagerWin);
77 } // namespace media
79 #endif // MEDIA_MIDI_MIDI_MANAGER_WIN_H_