Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: media/midi/midi_manager.cc

Issue 2422163002: Web MIDI: use midi_service.mojom for media::midi::PortState (Closed)
Patch Set: gn --check fix Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/midi/midi_manager.h ('k') | media/midi/midi_manager_alsa.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "media/midi/midi_manager.h" 5 #include "media/midi/midi_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 14
15 namespace midi { 15 namespace midi {
16 16
17 namespace { 17 namespace {
18 18
19 using Sample = base::HistogramBase::Sample; 19 using Sample = base::HistogramBase::Sample;
20 using midi::mojom::PortState;
20 using midi::mojom::Result; 21 using midi::mojom::Result;
21 22
22 // If many users have more devices, this number will be increased. 23 // If many users have more devices, this number will be increased.
23 // But the number is expected to be big enough for now. 24 // But the number is expected to be big enough for now.
24 const Sample kMaxUmaDevices = 31; 25 const Sample kMaxUmaDevices = 31;
25 26
26 // Used to count events for usage histogram. 27 // Used to count events for usage histogram.
27 enum class Usage { 28 enum class Usage {
28 CREATED, 29 CREATED,
29 CREATED_ON_UNSUPPORTED_PLATFORMS, 30 CREATED_ON_UNSUPPORTED_PLATFORMS,
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 196 }
196 197
197 void MidiManager::AddOutputPort(const MidiPortInfo& info) { 198 void MidiManager::AddOutputPort(const MidiPortInfo& info) {
198 ReportUsage(Usage::OUTPUT_PORT_ADDED); 199 ReportUsage(Usage::OUTPUT_PORT_ADDED);
199 base::AutoLock auto_lock(lock_); 200 base::AutoLock auto_lock(lock_);
200 output_ports_.push_back(info); 201 output_ports_.push_back(info);
201 for (auto* client : clients_) 202 for (auto* client : clients_)
202 client->AddOutputPort(info); 203 client->AddOutputPort(info);
203 } 204 }
204 205
205 void MidiManager::SetInputPortState(uint32_t port_index, MidiPortState state) { 206 void MidiManager::SetInputPortState(uint32_t port_index, PortState state) {
206 base::AutoLock auto_lock(lock_); 207 base::AutoLock auto_lock(lock_);
207 DCHECK_LT(port_index, input_ports_.size()); 208 DCHECK_LT(port_index, input_ports_.size());
208 input_ports_[port_index].state = state; 209 input_ports_[port_index].state = state;
209 for (auto* client : clients_) 210 for (auto* client : clients_)
210 client->SetInputPortState(port_index, state); 211 client->SetInputPortState(port_index, state);
211 } 212 }
212 213
213 void MidiManager::SetOutputPortState(uint32_t port_index, MidiPortState state) { 214 void MidiManager::SetOutputPortState(uint32_t port_index, PortState state) {
214 base::AutoLock auto_lock(lock_); 215 base::AutoLock auto_lock(lock_);
215 DCHECK_LT(port_index, output_ports_.size()); 216 DCHECK_LT(port_index, output_ports_.size());
216 output_ports_[port_index].state = state; 217 output_ports_[port_index].state = state;
217 for (auto* client : clients_) 218 for (auto* client : clients_)
218 client->SetOutputPortState(port_index, state); 219 client->SetOutputPortState(port_index, state);
219 } 220 }
220 221
221 void MidiManager::ReceiveMidiData(uint32_t port_index, 222 void MidiManager::ReceiveMidiData(uint32_t port_index,
222 const uint8_t* data, 223 const uint8_t* data,
223 size_t length, 224 size_t length,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 Finalize(); 268 Finalize();
268 base::AutoLock auto_lock(lock_); 269 base::AutoLock auto_lock(lock_);
269 finalized_ = true; 270 finalized_ = true;
270 271
271 // Detach all clients so that they do not call MidiManager methods any more. 272 // Detach all clients so that they do not call MidiManager methods any more.
272 for (auto* client : clients_) 273 for (auto* client : clients_)
273 client->Detach(); 274 client->Detach();
274 } 275 }
275 276
276 } // namespace midi 277 } // namespace midi
OLDNEW
« no previous file with comments | « media/midi/midi_manager.h ('k') | media/midi/midi_manager_alsa.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698