Don't send a SHChangeNotify for creating an app icon when creating a shortcut.
[chromium-blink-merge.git] / media / midi / midi_manager_usb.h
blobea9b5890e595dc7d005e02fb763fcfacaf98673a
1 // Copyright 2014 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_USB_H_
6 #define MEDIA_MIDI_MIDI_MANAGER_USB_H_
8 #include <utility>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/bind.h"
13 #include "base/callback.h"
14 #include "base/containers/hash_tables.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/time/time.h"
17 #include "media/base/media_export.h"
18 #include "media/midi/midi_manager.h"
19 #include "media/midi/usb_midi_device.h"
20 #include "media/midi/usb_midi_input_stream.h"
21 #include "media/midi/usb_midi_jack.h"
22 #include "media/midi/usb_midi_output_stream.h"
24 namespace media {
26 // MidiManager for USB-MIDI.
27 class MEDIA_EXPORT MidiManagerUsb : public MidiManager,
28 public UsbMidiDeviceDelegate,
29 public UsbMidiInputStream::Delegate {
30 public:
31 explicit MidiManagerUsb(scoped_ptr<UsbMidiDevice::Factory> device_factory);
32 ~MidiManagerUsb() override;
34 // MidiManager implementation.
35 void StartInitialization() override;
36 void DispatchSendMidiData(MidiManagerClient* client,
37 uint32 port_index,
38 const std::vector<uint8>& data,
39 double timestamp) override;
41 // UsbMidiDeviceDelegate implementation.
42 void ReceiveUsbMidiData(UsbMidiDevice* device,
43 int endpoint_number,
44 const uint8* data,
45 size_t size,
46 base::TimeTicks time) override;
47 void OnDeviceAttached(scoped_ptr<UsbMidiDevice> device) override;
48 void OnDeviceDetached(size_t index) override;
50 // UsbMidiInputStream::Delegate implementation.
51 void OnReceivedData(size_t jack_index,
52 const uint8* data,
53 size_t size,
54 base::TimeTicks time) override;
56 const ScopedVector<UsbMidiOutputStream>& output_streams() const {
57 return output_streams_;
59 const UsbMidiInputStream* input_stream() const { return input_stream_.get(); }
61 // Initializes this object.
62 // When the initialization finishes, |callback| will be called with the
63 // result.
64 // When this factory is destroyed during the operation, the operation
65 // will be canceled silently (i.e. |callback| will not be called).
66 // The function is public just for unit tests. Do not call this function
67 // outside code for testing.
68 void Initialize(base::Callback<void(MidiResult result)> callback);
70 private:
71 void OnEnumerateDevicesDone(bool result, UsbMidiDevice::Devices* devices);
72 bool AddPorts(UsbMidiDevice* device, int device_id);
74 scoped_ptr<UsbMidiDevice::Factory> device_factory_;
75 ScopedVector<UsbMidiDevice> devices_;
76 ScopedVector<UsbMidiOutputStream> output_streams_;
77 scoped_ptr<UsbMidiInputStream> input_stream_;
79 base::Callback<void(MidiResult result)> initialize_callback_;
81 // A map from <endpoint_number, cable_number> to the index of input jacks.
82 base::hash_map<std::pair<int, int>, size_t> input_jack_dictionary_;
84 DISALLOW_COPY_AND_ASSIGN(MidiManagerUsb);
87 } // namespace media
89 #endif // MEDIA_MIDI_MIDI_MANAGER_USB_H_