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

Side by Side Diff: media/audio/audio_manager.cc

Issue 2705293003: Remove DumpWithoutCrashing() and keys from audio_manager (Closed)
Patch Set: remove unnecessary #includes 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/audio/audio_manager.h ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/audio/audio_manager.h" 5 #include "media/audio/audio_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/debug/alias.h"
15 #include "base/debug/crash_logging.h"
16 #include "base/debug/dump_without_crashing.h"
17 #include "base/logging.h" 14 #include "base/logging.h"
18 #include "base/macros.h" 15 #include "base/macros.h"
19 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
20 #include "base/metrics/histogram_macros.h" 17 #include "base/metrics/histogram_macros.h"
21 #include "base/power_monitor/power_monitor.h" 18 #include "base/power_monitor/power_monitor.h"
22 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
23 #include "build/build_config.h" 20 #include "build/build_config.h"
24 #include "media/audio/fake_audio_log_factory.h" 21 #include "media/audio/fake_audio_log_factory.h"
25 #include "media/base/media_switches.h" 22 #include "media/base/media_switches.h"
26 23
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 void InitializeCOMForTesting() { 91 void InitializeCOMForTesting() {
95 com_initializer_for_testing_.reset(new base::win::ScopedCOMInitializer()); 92 com_initializer_for_testing_.reset(new base::win::ScopedCOMInitializer());
96 } 93 }
97 #endif 94 #endif
98 95
99 #if defined(OS_LINUX) 96 #if defined(OS_LINUX)
100 void set_app_name(const std::string& app_name) { app_name_ = app_name; } 97 void set_app_name(const std::string& app_name) { app_name_ = app_name; }
101 const std::string& app_name() const { return app_name_; } 98 const std::string& app_name() const { return app_name_; }
102 #endif 99 #endif
103 100
104 void enable_crash_key_logging() { enable_crash_key_logging_ = true; }
105
106 private: 101 private:
107 // base::PowerObserver overrides. 102 // base::PowerObserver overrides.
108 // Disable hang detection when the system goes into the suspend state. 103 // Disable hang detection when the system goes into the suspend state.
109 void OnSuspend() override { 104 void OnSuspend() override {
110 base::AutoLock lock(hang_lock_); 105 base::AutoLock lock(hang_lock_);
111 hang_detection_enabled_ = false; 106 hang_detection_enabled_ = false;
112 failed_pings_ = successful_pings_ = 0; 107 failed_pings_ = successful_pings_ = 0;
113 } 108 }
114 // Reenable hang detection once the system comes out of the suspend state. 109 // Reenable hang detection once the system comes out of the suspend state.
115 void OnResume() override { 110 void OnResume() override {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return; 147 return;
153 } 148 }
154 149
155 DCHECK(io_task_running_); 150 DCHECK(io_task_running_);
156 const base::TimeTicks now = base::TimeTicks::Now(); 151 const base::TimeTicks now = base::TimeTicks::Now();
157 const base::TimeDelta tick_delta = now - last_audio_thread_timer_tick_; 152 const base::TimeDelta tick_delta = now - last_audio_thread_timer_tick_;
158 if (tick_delta > max_hung_task_time_) { 153 if (tick_delta > max_hung_task_time_) {
159 successful_pings_ = 0; 154 successful_pings_ = 0;
160 if (++failed_pings_ >= kMaxFailedPingsCount && 155 if (++failed_pings_ >= kMaxFailedPingsCount &&
161 audio_thread_status_ < THREAD_HUNG) { 156 audio_thread_status_ < THREAD_HUNG) {
162 if (enable_crash_key_logging_)
163 LogAudioDriverCrashKeys();
164 HistogramThreadStatus(THREAD_HUNG); 157 HistogramThreadStatus(THREAD_HUNG);
165 } 158 }
166 } else { 159 } else {
167 failed_pings_ = 0; 160 failed_pings_ = 0;
168 ++successful_pings_; 161 ++successful_pings_;
169 if (audio_thread_status_ == THREAD_NONE) { 162 if (audio_thread_status_ == THREAD_NONE) {
170 HistogramThreadStatus(THREAD_STARTED); 163 HistogramThreadStatus(THREAD_STARTED);
171 } else if (audio_thread_status_ == THREAD_HUNG && 164 } else if (audio_thread_status_ == THREAD_HUNG &&
172 successful_pings_ >= kMaxFailedPingsCount) { 165 successful_pings_ >= kMaxFailedPingsCount) {
173 // Require just as many successful pings to recover from failure. 166 // Require just as many successful pings to recover from failure.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 max_hung_task_time_ / 5); 201 max_hung_task_time_ / 5);
209 } 202 }
210 203
211 void HistogramThreadStatus(ThreadStatus status) { 204 void HistogramThreadStatus(ThreadStatus status) {
212 DCHECK(monitor_task_runner_->BelongsToCurrentThread()); 205 DCHECK(monitor_task_runner_->BelongsToCurrentThread());
213 audio_thread_status_ = status; 206 audio_thread_status_ = status;
214 UMA_HISTOGRAM_ENUMERATION("Media.AudioThreadStatus", audio_thread_status_, 207 UMA_HISTOGRAM_ENUMERATION("Media.AudioThreadStatus", audio_thread_status_,
215 THREAD_MAX + 1); 208 THREAD_MAX + 1);
216 } 209 }
217 210
218 void LogAudioDriverCrashKeys() {
219 DCHECK(monitor_task_runner_->BelongsToCurrentThread());
220 DCHECK(enable_crash_key_logging_);
221
222 #if defined(OS_WIN)
223 std::string driver_name, driver_version;
224 if (!CoreAudioUtil::GetDxDiagDetails(&driver_name, &driver_version))
225 return;
226
227 base::debug::ScopedCrashKey crash_key(
228 "hung-audio-thread-details",
229 base::StringPrintf("%s:%s", driver_name.c_str(),
230 driver_version.c_str()));
231
232 // Please forward crash reports to http://crbug.com/422522
233 base::debug::DumpWithoutCrashing();
234 #endif
235 }
236
237 FakeAudioLogFactory fake_log_factory_; 211 FakeAudioLogFactory fake_log_factory_;
238 212
239 const base::TimeDelta max_hung_task_time_ = base::TimeDelta::FromMinutes(1); 213 const base::TimeDelta max_hung_task_time_ = base::TimeDelta::FromMinutes(1);
240 scoped_refptr<base::SingleThreadTaskRunner> monitor_task_runner_; 214 scoped_refptr<base::SingleThreadTaskRunner> monitor_task_runner_;
241 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_; 215 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
242 216
243 base::Lock hang_lock_; 217 base::Lock hang_lock_;
244 bool hang_detection_enabled_ = true; 218 bool hang_detection_enabled_ = true;
245 base::TimeTicks last_audio_thread_timer_tick_; 219 base::TimeTicks last_audio_thread_timer_tick_;
246 uint32_t failed_pings_ = 0; 220 uint32_t failed_pings_ = 0;
247 bool io_task_running_ = false; 221 bool io_task_running_ = false;
248 bool audio_task_running_ = false; 222 bool audio_task_running_ = false;
249 ThreadStatus audio_thread_status_ = THREAD_NONE; 223 ThreadStatus audio_thread_status_ = THREAD_NONE;
250 bool enable_crash_key_logging_ = false;
251 uint32_t successful_pings_ = 0; 224 uint32_t successful_pings_ = 0;
252 225
253 #if defined(OS_WIN) 226 #if defined(OS_WIN)
254 std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer_for_testing_; 227 std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer_for_testing_;
255 #endif 228 #endif
256 229
257 #if defined(OS_LINUX) 230 #if defined(OS_LINUX)
258 std::string app_name_; 231 std::string app_name_;
259 #endif 232 #endif
260 233
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 if (GetHelper()->monitor_task_runner()) 329 if (GetHelper()->monitor_task_runner())
357 return; 330 return;
358 331
359 DCHECK(AudioManager::Get()); 332 DCHECK(AudioManager::Get());
360 DCHECK(task_runner); 333 DCHECK(task_runner);
361 DCHECK_NE(task_runner, AudioManager::Get()->GetTaskRunner()); 334 DCHECK_NE(task_runner, AudioManager::Get()->GetTaskRunner());
362 335
363 GetHelper()->StartHangTimer(std::move(task_runner)); 336 GetHelper()->StartHangTimer(std::move(task_runner));
364 } 337 }
365 338
366 // static
367 void AudioManager::EnableCrashKeyLoggingForAudioThreadHangs() {
368 CHECK(!g_last_created);
369 GetHelper()->enable_crash_key_logging();
370 }
371
372 #if defined(OS_LINUX) 339 #if defined(OS_LINUX)
373 // static 340 // static
374 void AudioManager::SetGlobalAppName(const std::string& app_name) { 341 void AudioManager::SetGlobalAppName(const std::string& app_name) {
375 GetHelper()->set_app_name(app_name); 342 GetHelper()->set_app_name(app_name);
376 } 343 }
377 344
378 // static 345 // static
379 const std::string& AudioManager::GetGlobalAppName() { 346 const std::string& AudioManager::GetGlobalAppName() {
380 return GetHelper()->app_name(); 347 return GetHelper()->app_name();
381 } 348 }
382 #endif 349 #endif
383 350
384 // static 351 // static
385 AudioManager* AudioManager::Get() { 352 AudioManager* AudioManager::Get() {
386 return g_last_created; 353 return g_last_created;
387 } 354 }
388 355
389 } // namespace media 356 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698