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

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

Issue 2673423002: Web MIDI: add dynamic MidiManager instantiation support for Linux (Closed)
Patch Set: update metrics 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
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 MidiManager* MidiManager::Create() { 65 MidiManager* MidiManager::Create() {
66 ReportUsage(Usage::CREATED_ON_UNSUPPORTED_PLATFORMS); 66 ReportUsage(Usage::CREATED_ON_UNSUPPORTED_PLATFORMS);
67 return new MidiManager; 67 return new MidiManager;
68 } 68 }
69 #endif 69 #endif
70 70
71 void MidiManager::Shutdown() { 71 void MidiManager::Shutdown() {
72 UMA_HISTOGRAM_ENUMERATION("Media.Midi.ResultOnShutdown", 72 UMA_HISTOGRAM_ENUMERATION("Media.Midi.ResultOnShutdown",
73 static_cast<int>(result_), 73 static_cast<int>(result_),
74 static_cast<int>(Result::MAX) + 1); 74 static_cast<int>(Result::MAX) + 1);
75 base::AutoLock auto_lock(lock_); 75 bool shutdown_synchronously = false;
76 if (session_thread_runner_) { 76 {
77 session_thread_runner_->PostTask( 77 base::AutoLock auto_lock(lock_);
78 FROM_HERE, base::Bind(&MidiManager::ShutdownOnSessionThread, 78 if (session_thread_runner_) {
79 base::Unretained(this))); 79 if (session_thread_runner_->BelongsToCurrentThread()) {
80 session_thread_runner_ = nullptr; 80 shutdown_synchronously = true;
81 } else { 81 } else {
82 finalized_ = true; 82 session_thread_runner_->PostTask(
83 FROM_HERE, base::Bind(&MidiManager::ShutdownOnSessionThread,
84 base::Unretained(this)));
85 }
86 session_thread_runner_ = nullptr;
87 } else {
88 finalized_ = true;
89 }
83 } 90 }
91 if (shutdown_synchronously)
92 ShutdownOnSessionThread();
84 } 93 }
85 94
86 void MidiManager::StartSession(MidiManagerClient* client) { 95 void MidiManager::StartSession(MidiManagerClient* client) {
87 ReportUsage(Usage::SESSION_STARTED); 96 ReportUsage(Usage::SESSION_STARTED);
88 97
89 bool needs_initialization = false; 98 bool needs_initialization = false;
90 99
91 { 100 {
92 base::AutoLock auto_lock(lock_); 101 base::AutoLock auto_lock(lock_);
93 if (clients_.find(client) != clients_.end() || 102 if (clients_.find(client) != clients_.end() ||
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 Finalize(); 273 Finalize();
265 base::AutoLock auto_lock(lock_); 274 base::AutoLock auto_lock(lock_);
266 finalized_ = true; 275 finalized_ = true;
267 276
268 // Detach all clients so that they do not call MidiManager methods any more. 277 // Detach all clients so that they do not call MidiManager methods any more.
269 for (auto* client : clients_) 278 for (auto* client : clients_)
270 client->Detach(); 279 client->Detach();
271 } 280 }
272 281
273 } // namespace midi 282 } // namespace midi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698