Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_H_ | 5 #ifndef MEDIA_MIDI_MIDI_MANAGER_H_ |
| 6 #define MEDIA_MIDI_MIDI_MANAGER_H_ | 6 #define MEDIA_MIDI_MIDI_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 void ReceiveMidiData(uint32 port_index, | 134 void ReceiveMidiData(uint32 port_index, |
| 135 const uint8* data, | 135 const uint8* data, |
| 136 size_t length, | 136 size_t length, |
| 137 base::TimeTicks time) { | 137 base::TimeTicks time) { |
| 138 ReceiveMidiData(port_index, data, length, | 138 ReceiveMidiData(port_index, data, length, |
| 139 (time - base::TimeTicks()).InSecondsF()); | 139 (time - base::TimeTicks()).InSecondsF()); |
| 140 } | 140 } |
| 141 | 141 |
| 142 size_t clients_size_for_testing() const { return clients_.size(); } | 142 size_t clients_size_for_testing() const { return clients_.size(); } |
| 143 size_t pending_clients_size_for_testing() const { | 143 size_t pending_clients_size_for_testing() const { |
| 144 return pending_clients_.size(); | 144 return pending_clients_size_; |
| 145 } | 145 } |
| 146 | 146 |
| 147 private: | 147 private: |
| 148 void CompleteInitializationInternal(MidiResult result); | 148 void CompleteInitializationInternal(MidiResult result); |
| 149 | 149 |
| 150 // Keeps track of all clients who wish to receive MIDI data. | 150 // Keeps track of all clients who wish to receive MIDI data. |
| 151 typedef std::set<MidiManagerClient*> ClientList; | 151 typedef std::set<MidiManagerClient*> ClientList; |
| 152 ClientList clients_; | 152 ClientList clients_; |
| 153 | 153 |
| 154 // Keeps track of all clients who are waiting for CompleteStartSession(). | 154 // Keeps track of all clients who are waiting for CompleteStartSession(). |
| 155 typedef std::map<int, MidiManagerClient*> PendingClientMap; | 155 typedef std::map<MidiManagerClient*, std::vector<int> > PendingClientMap; |
|
yhirano
2014/06/11 12:11:57
[opt] You can use std::multimap<K, V> instead of s
Takashi Toyoshima
2014/06/12 04:41:02
Done.
| |
| 156 PendingClientMap pending_clients_; | 156 PendingClientMap pending_clients_; |
| 157 size_t pending_clients_size_; | |
| 157 | 158 |
| 158 // Keeps a SingleThreadTaskRunner of the thread that calls StartSession in | 159 // Keeps a SingleThreadTaskRunner of the thread that calls StartSession in |
| 159 // order to invoke CompleteStartSession() on the thread. | 160 // order to invoke CompleteStartSession() on the thread. |
| 160 scoped_refptr<base::SingleThreadTaskRunner> session_thread_runner_; | 161 scoped_refptr<base::SingleThreadTaskRunner> session_thread_runner_; |
| 161 | 162 |
| 162 // Keeps true if platform dependent initialization is already completed. | 163 // Keeps true if platform dependent initialization is already completed. |
| 163 bool initialized_; | 164 bool initialized_; |
| 164 | 165 |
| 165 // Keeps the platform dependent initialization result if initialization is | 166 // Keeps the platform dependent initialization result if initialization is |
| 166 // completed. Otherwise keeps MIDI_NOT_SUPPORTED. | 167 // completed. Otherwise keeps MIDI_NOT_SUPPORTED. |
| 167 MidiResult result_; | 168 MidiResult result_; |
| 168 | 169 |
| 169 // Protects access to |clients_|, |pending_clients_|, |initialized_|, and | 170 // Protects access to |clients_|, |pending_clients_|, |initialized_|, and |
| 170 // |result_|. | 171 // |result_|. |
| 171 base::Lock lock_; | 172 base::Lock lock_; |
| 172 | 173 |
| 173 MidiPortInfoList input_ports_; | 174 MidiPortInfoList input_ports_; |
| 174 MidiPortInfoList output_ports_; | 175 MidiPortInfoList output_ports_; |
| 175 | 176 |
| 176 DISALLOW_COPY_AND_ASSIGN(MidiManager); | 177 DISALLOW_COPY_AND_ASSIGN(MidiManager); |
| 177 }; | 178 }; |
| 178 | 179 |
| 179 } // namespace media | 180 } // namespace media |
| 180 | 181 |
| 181 #endif // MEDIA_MIDI_MIDI_MANAGER_H_ | 182 #endif // MEDIA_MIDI_MIDI_MANAGER_H_ |
| OLD | NEW |