All instances of addresses as void* are changed to uintptr_t in
[chromium-blink-merge.git] / media / midi / usb_midi_device_android.h
blobc4fd1ad29db502ff0c820c061133c4c60685ed7e
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_USB_MIDI_DEVICE_ANDROID_H_
6 #define MEDIA_MIDI_USB_MIDI_DEVICE_ANDROID_H_
8 #include <jni.h>
9 #include <string>
10 #include <vector>
12 #include "base/android/scoped_java_ref.h"
13 #include "base/basictypes.h"
14 #include "base/callback.h"
15 #include "media/midi/usb_midi_device.h"
16 #include "media/midi/usb_midi_export.h"
18 namespace media {
19 namespace midi {
21 class USB_MIDI_EXPORT UsbMidiDeviceAndroid : public UsbMidiDevice {
22 public:
23 typedef base::android::ScopedJavaLocalRef<jobject> ObjectRef;
25 static scoped_ptr<Factory> CreateFactory();
27 UsbMidiDeviceAndroid(ObjectRef raw_device, UsbMidiDeviceDelegate* delegate);
28 ~UsbMidiDeviceAndroid() override;
30 // UsbMidiDevice implementation.
31 std::vector<uint8> GetDescriptors() override;
32 std::string GetManufacturer() override;
33 std::string GetProductName() override;
34 std::string GetDeviceVersion() override;
35 void Send(int endpoint_number, const std::vector<uint8>& data) override;
37 // Called by the Java world.
38 void OnData(JNIEnv* env,
39 jobject caller,
40 jint endpoint_number,
41 jbyteArray data);
43 static bool RegisterUsbMidiDevice(JNIEnv* env);
45 private:
46 void GetDescriptorsInternal();
47 void InitDeviceInfo();
48 std::vector<uint8> GetStringDescriptor(int index);
49 std::string GetString(int index, const std::string& backup);
51 // The actual device object.
52 base::android::ScopedJavaGlobalRef<jobject> raw_device_;
53 UsbMidiDeviceDelegate* delegate_;
55 std::vector<uint8> descriptors_;
56 std::string manufacturer_;
57 std::string product_;
58 std::string device_version_;
60 DISALLOW_IMPLICIT_CONSTRUCTORS(UsbMidiDeviceAndroid);
63 } // namespace midi
64 } // namespace media
66 #endif // MEDIA_MIDI_USB_MIDI_DEVICE_ANDROID_H_