| 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 "content/browser/media/webrtc_internals.h" | 5 #include "content/browser/media/webrtc_internals.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "content/browser/media/audio_debug_controller.h" |
| 8 #include "content/browser/media/webrtc_internals_ui_observer.h" | 9 #include "content/browser/media/webrtc_internals_ui_observer.h" |
| 9 #include "content/browser/web_contents/web_contents_view.h" | 10 #include "content/browser/web_contents/web_contents_view.h" |
| 10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 11 #include "content/public/browser/content_browser_client.h" | 12 #include "content/public/browser/content_browser_client.h" |
| 12 #include "content/public/browser/power_save_blocker.h" | 13 #include "content/public/browser/power_save_blocker.h" |
| 13 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
| 14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 15 | 16 |
| 16 using base::ProcessId; | 17 using base::ProcessId; |
| 17 using std::string; | 18 using std::string; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 264 |
| 264 void WebRTCInternals::DisableAudioDebugRecordings() { | 265 void WebRTCInternals::DisableAudioDebugRecordings() { |
| 265 #if defined(ENABLE_WEBRTC) | 266 #if defined(ENABLE_WEBRTC) |
| 266 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 267 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 267 audio_debug_recordings_ = false; | 268 audio_debug_recordings_ = false; |
| 268 | 269 |
| 269 // Tear down the dialog since the user has unchecked the audio debug | 270 // Tear down the dialog since the user has unchecked the audio debug |
| 270 // recordings box. | 271 // recordings box. |
| 271 select_file_dialog_ = NULL; | 272 select_file_dialog_ = NULL; |
| 272 | 273 |
| 273 for (RenderProcessHost::iterator i( | 274 AudioDebugController::GetInstance()->DisableAudioDebugRecording(); |
| 274 content::RenderProcessHost::AllHostsIterator()); | |
| 275 !i.IsAtEnd(); i.Advance()) { | |
| 276 i.GetCurrentValue()->DisableAudioDebugRecordings(); | |
| 277 } | |
| 278 #endif | 275 #endif |
| 279 } | 276 } |
| 280 | 277 |
| 281 bool WebRTCInternals::IsAudioDebugRecordingsEnabled() const { | 278 bool WebRTCInternals::IsAudioDebugRecordingsEnabled() const { |
| 282 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 279 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 283 return audio_debug_recordings_; | 280 return audio_debug_recordings_; |
| 284 } | 281 } |
| 285 | 282 |
| 286 const base::FilePath& WebRTCInternals::GetAudioDebugRecordingsFilePath() const { | 283 const base::FilePath& WebRTCInternals::GetAudioDebugRecordingsFilePath() const { |
| 287 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 284 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 update.SetInteger("rid", render_process_id); | 376 update.SetInteger("rid", render_process_id); |
| 380 SendUpdate("removeGetUserMediaForRenderer", &update); | 377 SendUpdate("removeGetUserMediaForRenderer", &update); |
| 381 } | 378 } |
| 382 } | 379 } |
| 383 | 380 |
| 384 #if defined(ENABLE_WEBRTC) | 381 #if defined(ENABLE_WEBRTC) |
| 385 void WebRTCInternals::EnableAudioDebugRecordingsOnAllRenderProcessHosts() { | 382 void WebRTCInternals::EnableAudioDebugRecordingsOnAllRenderProcessHosts() { |
| 386 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 383 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 387 | 384 |
| 388 audio_debug_recordings_ = true; | 385 audio_debug_recordings_ = true; |
| 389 for (RenderProcessHost::iterator i( | 386 AudioDebugController::GetInstance()->EnableAudioDebugRecording( |
| 390 content::RenderProcessHost::AllHostsIterator()); | 387 audio_debug_recordings_file_path_); |
| 391 !i.IsAtEnd(); i.Advance()) { | |
| 392 i.GetCurrentValue()->EnableAudioDebugRecordings( | |
| 393 audio_debug_recordings_file_path_); | |
| 394 } | |
| 395 } | 388 } |
| 396 #endif | 389 #endif |
| 397 | 390 |
| 398 void WebRTCInternals::CreateOrReleasePowerSaveBlocker() { | 391 void WebRTCInternals::CreateOrReleasePowerSaveBlocker() { |
| 399 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 392 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 400 | 393 |
| 401 if (peer_connection_data_.empty() && power_save_blocker_) { | 394 if (peer_connection_data_.empty() && power_save_blocker_) { |
| 402 DVLOG(1) << ("Releasing the block on application suspension since no " | 395 DVLOG(1) << ("Releasing the block on application suspension since no " |
| 403 "PeerConnections are active anymore."); | 396 "PeerConnections are active anymore."); |
| 404 power_save_blocker_.reset(); | 397 power_save_blocker_.reset(); |
| 405 } else if (!peer_connection_data_.empty() && !power_save_blocker_) { | 398 } else if (!peer_connection_data_.empty() && !power_save_blocker_) { |
| 406 DVLOG(1) << ("Preventing the application from being suspended while one or " | 399 DVLOG(1) << ("Preventing the application from being suspended while one or " |
| 407 "more PeerConnections are active."); | 400 "more PeerConnections are active."); |
| 408 power_save_blocker_ = | 401 power_save_blocker_ = |
| 409 content::PowerSaveBlocker::Create( | 402 content::PowerSaveBlocker::Create( |
| 410 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, | 403 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, |
| 411 PowerSaveBlocker::kReasonOther, | 404 PowerSaveBlocker::kReasonOther, |
| 412 "WebRTC has active PeerConnections").Pass(); | 405 "WebRTC has active PeerConnections").Pass(); |
| 413 } | 406 } |
| 414 } | 407 } |
| 415 | 408 |
| 416 } // namespace content | 409 } // namespace content |
| OLD | NEW |