| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_MIDI_MIDI_MANAGER_ANDROID_H_ | 5 #ifndef MEDIA_MIDI_MIDI_MANAGER_ANDROID_H_ |
| 6 #define MEDIA_MIDI_MIDI_MANAGER_ANDROID_H_ | 6 #define MEDIA_MIDI_MIDI_MANAGER_ANDROID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| 11 |
| 12 #include <memory> |
| 11 #include <vector> | 13 #include <vector> |
| 12 | 14 |
| 13 #include "base/android/scoped_java_ref.h" | 15 #include "base/android/scoped_java_ref.h" |
| 14 #include "base/containers/hash_tables.h" | 16 #include "base/containers/hash_tables.h" |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
| 17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 18 #include "media/midi/midi_input_port_android.h" | 19 #include "media/midi/midi_input_port_android.h" |
| 19 #include "media/midi/midi_manager.h" | 20 #include "media/midi/midi_manager.h" |
| 20 #include "media/midi/midi_scheduler.h" | 21 #include "media/midi/midi_scheduler.h" |
| 21 | 22 |
| 22 namespace media { | 23 namespace media { |
| 23 namespace midi { | 24 namespace midi { |
| 24 | 25 |
| 25 class MidiDeviceAndroid; | 26 class MidiDeviceAndroid; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 53 void OnAttached(JNIEnv* env, | 54 void OnAttached(JNIEnv* env, |
| 54 const base::android::JavaParamRef<jobject>& caller, | 55 const base::android::JavaParamRef<jobject>& caller, |
| 55 const base::android::JavaParamRef<jobject>& device); | 56 const base::android::JavaParamRef<jobject>& device); |
| 56 void OnDetached(JNIEnv* env, | 57 void OnDetached(JNIEnv* env, |
| 57 const base::android::JavaParamRef<jobject>& caller, | 58 const base::android::JavaParamRef<jobject>& caller, |
| 58 const base::android::JavaParamRef<jobject>& device); | 59 const base::android::JavaParamRef<jobject>& device); |
| 59 | 60 |
| 60 static bool Register(JNIEnv* env); | 61 static bool Register(JNIEnv* env); |
| 61 | 62 |
| 62 private: | 63 private: |
| 63 void AddDevice(scoped_ptr<MidiDeviceAndroid> device); | 64 void AddDevice(std::unique_ptr<MidiDeviceAndroid> device); |
| 64 void AddInputPortAndroid(MidiInputPortAndroid* port, | 65 void AddInputPortAndroid(MidiInputPortAndroid* port, |
| 65 MidiDeviceAndroid* device); | 66 MidiDeviceAndroid* device); |
| 66 void AddOutputPortAndroid(MidiOutputPortAndroid* port, | 67 void AddOutputPortAndroid(MidiOutputPortAndroid* port, |
| 67 MidiDeviceAndroid* device); | 68 MidiDeviceAndroid* device); |
| 68 | 69 |
| 69 ScopedVector<MidiDeviceAndroid> devices_; | 70 ScopedVector<MidiDeviceAndroid> devices_; |
| 70 // All ports held in |devices_|. Each device has ownership of ports, but we | 71 // All ports held in |devices_|. Each device has ownership of ports, but we |
| 71 // can store pointers here because a device will keep its ports while it is | 72 // can store pointers here because a device will keep its ports while it is |
| 72 // alive. | 73 // alive. |
| 73 std::vector<MidiInputPortAndroid*> all_input_ports_; | 74 std::vector<MidiInputPortAndroid*> all_input_ports_; |
| 74 // A dictionary from a port to its index. | 75 // A dictionary from a port to its index. |
| 75 // input_port_to_index_[all_input_ports_[i]] == i for each valid |i|. | 76 // input_port_to_index_[all_input_ports_[i]] == i for each valid |i|. |
| 76 base::hash_map<MidiInputPortAndroid*, size_t> input_port_to_index_; | 77 base::hash_map<MidiInputPortAndroid*, size_t> input_port_to_index_; |
| 77 | 78 |
| 78 // Ditto for output ports. | 79 // Ditto for output ports. |
| 79 std::vector<MidiOutputPortAndroid*> all_output_ports_; | 80 std::vector<MidiOutputPortAndroid*> all_output_ports_; |
| 80 base::hash_map<MidiOutputPortAndroid*, size_t> output_port_to_index_; | 81 base::hash_map<MidiOutputPortAndroid*, size_t> output_port_to_index_; |
| 81 | 82 |
| 82 base::android::ScopedJavaGlobalRef<jobject> raw_manager_; | 83 base::android::ScopedJavaGlobalRef<jobject> raw_manager_; |
| 83 scoped_ptr<MidiScheduler> scheduler_; | 84 std::unique_ptr<MidiScheduler> scheduler_; |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 } // namespace midi | 87 } // namespace midi |
| 87 } // namespace media | 88 } // namespace media |
| 88 | 89 |
| 89 #endif // MEDIA_MIDI_MIDI_MANAGER_ANDROID_H_ | 90 #endif // MEDIA_MIDI_MIDI_MANAGER_ANDROID_H_ |
| OLD | NEW |