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

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

Issue 2686043003: [not for review] Web MIDI: new backend to support dynamic instantiation on Windows (Closed)
Patch Set: not for review (rebase/rename/LazyInstance) Created 3 years, 10 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/dynamically_initialized_midi_manager_win.cc ('k') | media/midi/midi_manager_win.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"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 const std::vector<uint8_t>& data, 178 const std::vector<uint8_t>& data,
179 double timestamp) { 179 double timestamp) {
180 NOTREACHED(); 180 NOTREACHED();
181 } 181 }
182 182
183 void MidiManager::StartInitialization() { 183 void MidiManager::StartInitialization() {
184 CompleteInitialization(Result::NOT_SUPPORTED); 184 CompleteInitialization(Result::NOT_SUPPORTED);
185 } 185 }
186 186
187 void MidiManager::CompleteInitialization(Result result) { 187 void MidiManager::CompleteInitialization(Result result) {
188 base::AutoLock auto_lock(lock_); 188 bool complete_asynchronously = false;
189 if (session_thread_runner_) { 189 {
190 session_thread_runner_->PostTask( 190 base::AutoLock auto_lock(lock_);
191 FROM_HERE, base::Bind(&MidiManager::CompleteInitializationInternal, 191 if (session_thread_runner_) {
192 base::Unretained(this), result)); 192 if (session_thread_runner_->BelongsToCurrentThread()) {
193 complete_asynchronously = true;
194 } else {
195 session_thread_runner_->PostTask(
196 FROM_HERE, base::Bind(&MidiManager::CompleteInitializationInternal,
197 base::Unretained(this), result));
198 }
199 }
193 } 200 }
201 if (complete_asynchronously)
202 CompleteInitializationInternal(result);
194 } 203 }
195 204
196 void MidiManager::AddInputPort(const MidiPortInfo& info) { 205 void MidiManager::AddInputPort(const MidiPortInfo& info) {
197 ReportUsage(Usage::INPUT_PORT_ADDED); 206 ReportUsage(Usage::INPUT_PORT_ADDED);
198 base::AutoLock auto_lock(lock_); 207 base::AutoLock auto_lock(lock_);
199 input_ports_.push_back(info); 208 input_ports_.push_back(info);
200 for (auto* client : clients_) 209 for (auto* client : clients_)
201 client->AddInputPort(info); 210 client->AddInputPort(info);
202 } 211 }
203 212
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 Finalize(); 283 Finalize();
275 base::AutoLock auto_lock(lock_); 284 base::AutoLock auto_lock(lock_);
276 finalized_ = true; 285 finalized_ = true;
277 286
278 // Detach all clients so that they do not call MidiManager methods any more. 287 // Detach all clients so that they do not call MidiManager methods any more.
279 for (auto* client : clients_) 288 for (auto* client : clients_)
280 client->Detach(); 289 client->Detach();
281 } 290 }
282 291
283 } // namespace midi 292 } // namespace midi
OLDNEW
« no previous file with comments | « media/midi/dynamically_initialized_midi_manager_win.cc ('k') | media/midi/midi_manager_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698