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 #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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 25 matching lines...) Expand all Loading... | |
36 | 36 |
37 void ReportUsage(Usage usage) { | 37 void ReportUsage(Usage usage) { |
38 UMA_HISTOGRAM_ENUMERATION("Media.Midi.Usage", | 38 UMA_HISTOGRAM_ENUMERATION("Media.Midi.Usage", |
39 static_cast<Sample>(usage), | 39 static_cast<Sample>(usage), |
40 static_cast<Sample>(Usage::MAX) + 1); | 40 static_cast<Sample>(Usage::MAX) + 1); |
41 } | 41 } |
42 | 42 |
43 } // namespace | 43 } // namespace |
44 | 44 |
45 MidiManager::MidiManager() | 45 MidiManager::MidiManager() |
46 : initialized_(false), result_(Result::NOT_INITIALIZED) { | 46 : initialized_(false), |
47 shutted_down_(false), | |
48 result_(Result::NOT_INITIALIZED) { | |
47 ReportUsage(Usage::CREATED); | 49 ReportUsage(Usage::CREATED); |
48 } | 50 } |
49 | 51 |
50 MidiManager::~MidiManager() { | 52 MidiManager::~MidiManager() { |
51 UMA_HISTOGRAM_ENUMERATION("Media.Midi.ResultOnShutdown", | 53 // Make sure that Shutdown() is called to clean up resources allocated on |
52 static_cast<Sample>(result_), | 54 // the Chrome_IOThread. |
53 static_cast<Sample>(Result::MAX) + 1); | 55 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
| |
54 } | 56 } |
55 | 57 |
56 #if !defined(OS_MACOSX) && !defined(OS_WIN) && \ | 58 #if !defined(OS_MACOSX) && !defined(OS_WIN) && \ |
57 !(defined(USE_ALSA) && defined(USE_UDEV)) && !defined(OS_ANDROID) | 59 !(defined(USE_ALSA) && defined(USE_UDEV)) && !defined(OS_ANDROID) |
58 MidiManager* MidiManager::Create() { | 60 MidiManager* MidiManager::Create() { |
59 ReportUsage(Usage::CREATED_ON_UNSUPPORTED_PLATFORMS); | 61 ReportUsage(Usage::CREATED_ON_UNSUPPORTED_PLATFORMS); |
60 return new MidiManager; | 62 return new MidiManager; |
61 } | 63 } |
62 #endif | 64 #endif |
63 | 65 |
66 void MidiManager::Shutdown() { | |
67 shutted_down_ = true; | |
68 UMA_HISTOGRAM_ENUMERATION("Media.Midi.ResultOnShutdown", | |
69 static_cast<int>(result_), | |
70 static_cast<int>(Result::MAX) + 1); | |
71 if (session_thread_runner_) { | |
72 session_thread_runner_->PostTask( | |
73 FROM_HERE, base::Bind(&MidiManager::Finalize, base::Unretained(this))); | |
74 } | |
75 } | |
76 | |
64 void MidiManager::StartSession(MidiManagerClient* client) { | 77 void MidiManager::StartSession(MidiManagerClient* client) { |
65 ReportUsage(Usage::SESSION_STARTED); | 78 ReportUsage(Usage::SESSION_STARTED); |
66 | 79 |
67 bool session_is_ready; | 80 bool session_is_ready; |
68 bool session_needs_initialization = false; | 81 bool session_needs_initialization = false; |
69 bool too_many_pending_clients_exist = false; | 82 bool too_many_pending_clients_exist = false; |
70 | 83 |
71 { | 84 { |
72 base::AutoLock auto_lock(lock_); | 85 base::AutoLock auto_lock(lock_); |
73 session_is_ready = initialized_; | 86 session_is_ready = initialized_; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 lock_.AssertAcquired(); | 250 lock_.AssertAcquired(); |
238 | 251 |
239 for (const auto& info : input_ports_) | 252 for (const auto& info : input_ports_) |
240 client->AddInputPort(info); | 253 client->AddInputPort(info); |
241 for (const auto& info : output_ports_) | 254 for (const auto& info : output_ports_) |
242 client->AddOutputPort(info); | 255 client->AddOutputPort(info); |
243 } | 256 } |
244 | 257 |
245 } // namespace midi | 258 } // namespace midi |
246 } // namespace media | 259 } // namespace media |
OLD | NEW |