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

Unified Diff: media/midi/midi_manager.cc

Issue 1315793008: Web MIDI: introduce MidiManager::Shutdown to shutdown gracefully (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: media/midi/midi_manager.cc
diff --git a/media/midi/midi_manager.cc b/media/midi/midi_manager.cc
index 6e8c1a266fa86502407d929db218eb1e85afc1f5..89dd8c80aac8ac7f896596a1721fa87fdc508b1e 100644
--- a/media/midi/midi_manager.cc
+++ b/media/midi/midi_manager.cc
@@ -43,14 +43,16 @@ void ReportUsage(Usage usage) {
} // namespace
MidiManager::MidiManager()
- : initialized_(false), result_(Result::NOT_INITIALIZED) {
+ : initialized_(false),
+ shutted_down_(false),
+ result_(Result::NOT_INITIALIZED) {
ReportUsage(Usage::CREATED);
}
MidiManager::~MidiManager() {
- UMA_HISTOGRAM_ENUMERATION("Media.Midi.ResultOnShutdown",
- static_cast<Sample>(result_),
- static_cast<Sample>(Result::MAX) + 1);
+ // Make sure that Shutdown() is called to clean up resources allocated on
+ // the Chrome_IOThread.
+ DCHECK(shutted_down_);
yhirano 2015/09/07 06:00:25 Shouldn't we check that it is correctly finalized?
Takashi Toyoshima 2015/09/07 19:04:39 We can do nothing here to recover even if Shutdown
yhirano 2015/09/08 04:59:37 What I'm worrying about is the case where the post
}
#if !defined(OS_MACOSX) && !defined(OS_WIN) && \
@@ -61,6 +63,17 @@ MidiManager* MidiManager::Create() {
}
#endif
+void MidiManager::Shutdown() {
+ shutted_down_ = true;
+ UMA_HISTOGRAM_ENUMERATION("Media.Midi.ResultOnShutdown",
+ static_cast<int>(result_),
+ static_cast<int>(Result::MAX) + 1);
+ if (session_thread_runner_) {
+ session_thread_runner_->PostTask(
+ FROM_HERE, base::Bind(&MidiManager::Finalize, base::Unretained(this)));
+ }
+}
+
void MidiManager::StartSession(MidiManagerClient* client) {
ReportUsage(Usage::SESSION_STARTED);

Powered by Google App Engine
This is Rietveld 408576698