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/webrtc/webrtc_internals.h" | 5 #include "content/browser/webrtc/webrtc_internals.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "content/browser/renderer_host/render_process_host_impl.h" | 14 #include "content/browser/renderer_host/render_process_host_impl.h" |
15 #include "content/browser/web_contents/web_contents_view.h" | 15 #include "content/browser/web_contents/web_contents_view.h" |
16 #include "content/browser/webrtc/webrtc_internals_ui_observer.h" | 16 #include "content/browser/webrtc/webrtc_internals_ui_observer.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/content_browser_client.h" | 18 #include "content/public/browser/content_browser_client.h" |
19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
20 #include "device/power_save_blocker/power_save_blocker.h" | 20 #include "device/power_save_blocker/power_save_blocker.h" |
21 #include "ipc/ipc_platform_file.h" | 21 #include "ipc/ipc_platform_file.h" |
22 #include "media/audio/audio_manager.h" | |
22 #include "media/media_features.h" | 23 #include "media/media_features.h" |
23 | 24 |
24 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
25 #define IntToStringType base::IntToString16 | 26 #define IntToStringType base::IntToString16 |
26 #else | 27 #else |
27 #define IntToStringType base::IntToString | 28 #define IntToStringType base::IntToString |
28 #endif | 29 #endif |
29 | 30 |
30 using base::ProcessId; | 31 using base::ProcessId; |
31 using std::string; | 32 using std::string; |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 #endif | 317 #endif |
317 } | 318 } |
318 | 319 |
319 void WebRTCInternals::DisableAudioDebugRecordings() { | 320 void WebRTCInternals::DisableAudioDebugRecordings() { |
320 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 321 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
321 #if BUILDFLAG(ENABLE_WEBRTC) | 322 #if BUILDFLAG(ENABLE_WEBRTC) |
322 audio_debug_recordings_ = false; | 323 audio_debug_recordings_ = false; |
323 | 324 |
324 // Tear down the dialog since the user has unchecked the audio debug | 325 // Tear down the dialog since the user has unchecked the audio debug |
325 // recordings box. | 326 // recordings box. |
326 select_file_dialog_ = NULL; | 327 select_file_dialog_ = nullptr; |
327 | 328 |
328 for (RenderProcessHost::iterator i( | 329 for (RenderProcessHost::iterator i( |
329 content::RenderProcessHost::AllHostsIterator()); | 330 content::RenderProcessHost::AllHostsIterator()); |
330 !i.IsAtEnd(); i.Advance()) { | 331 !i.IsAtEnd(); i.Advance()) { |
331 i.GetCurrentValue()->DisableAudioDebugRecordings(); | 332 i.GetCurrentValue()->DisableAudioDebugRecordings(); |
332 } | 333 } |
334 | |
335 // AudioManager is deleted on the audio thread, and the AudioManager outlives | |
336 // this object, so it's safe to post unretained. | |
337 media::AudioManager::Get()->GetTaskRunner()->PostTask( | |
DaleCurtis
2017/01/19 17:44:34
Ditto on reuse.
Henrik Grunell
2017/01/20 10:38:55
Done.
| |
338 FROM_HERE, base::Bind(&media::AudioManager::DisableOutputDebugRecording, | |
339 base::Unretained(media::AudioManager::Get()))); | |
333 #endif | 340 #endif |
334 } | 341 } |
335 | 342 |
336 bool WebRTCInternals::IsAudioDebugRecordingsEnabled() const { | 343 bool WebRTCInternals::IsAudioDebugRecordingsEnabled() const { |
337 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 344 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
338 return audio_debug_recordings_; | 345 return audio_debug_recordings_; |
339 } | 346 } |
340 | 347 |
341 const base::FilePath& WebRTCInternals::GetAudioDebugRecordingsFilePath() const { | 348 const base::FilePath& WebRTCInternals::GetAudioDebugRecordingsFilePath() const { |
342 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 349 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
484 update->SetInteger("rid", render_process_id); | 491 update->SetInteger("rid", render_process_id); |
485 SendUpdate("removeGetUserMediaForRenderer", std::move(update)); | 492 SendUpdate("removeGetUserMediaForRenderer", std::move(update)); |
486 } | 493 } |
487 } | 494 } |
488 | 495 |
489 #if BUILDFLAG(ENABLE_WEBRTC) | 496 #if BUILDFLAG(ENABLE_WEBRTC) |
490 void WebRTCInternals::EnableAudioDebugRecordingsOnAllRenderProcessHosts() { | 497 void WebRTCInternals::EnableAudioDebugRecordingsOnAllRenderProcessHosts() { |
491 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 498 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
492 | 499 |
493 audio_debug_recordings_ = true; | 500 audio_debug_recordings_ = true; |
501 | |
494 for (RenderProcessHost::iterator i( | 502 for (RenderProcessHost::iterator i( |
495 content::RenderProcessHost::AllHostsIterator()); | 503 content::RenderProcessHost::AllHostsIterator()); |
496 !i.IsAtEnd(); i.Advance()) { | 504 !i.IsAtEnd(); i.Advance()) { |
497 i.GetCurrentValue()->EnableAudioDebugRecordings( | 505 i.GetCurrentValue()->EnableAudioDebugRecordings( |
498 audio_debug_recordings_file_path_); | 506 audio_debug_recordings_file_path_); |
499 } | 507 } |
508 | |
509 // AudioManager is deleted on the audio thread, and the AudioManager outlives | |
510 // this object, so it's safe to post unretained. | |
511 media::AudioManager::Get()->GetTaskRunner()->PostTask( | |
DaleCurtis
2017/01/19 17:44:34
Ditto.
Henrik Grunell
2017/01/20 10:38:55
Done.
| |
512 FROM_HERE, base::Bind(&media::AudioManager::EnableOutputDebugRecording, | |
513 base::Unretained(media::AudioManager::Get()), | |
514 audio_debug_recordings_file_path_)); | |
500 } | 515 } |
501 | 516 |
502 void WebRTCInternals::EnableEventLogRecordingsOnAllRenderProcessHosts() { | 517 void WebRTCInternals::EnableEventLogRecordingsOnAllRenderProcessHosts() { |
503 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 518 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
504 | 519 |
505 event_log_recordings_ = true; | 520 event_log_recordings_ = true; |
506 for (RenderProcessHost::iterator i( | 521 for (RenderProcessHost::iterator i( |
507 content::RenderProcessHost::AllHostsIterator()); | 522 content::RenderProcessHost::AllHostsIterator()); |
508 !i.IsAtEnd(); i.Advance()) | 523 !i.IsAtEnd(); i.Advance()) |
509 i.GetCurrentValue()->StartWebRTCEventLog(event_log_recordings_file_path_); | 524 i.GetCurrentValue()->StartWebRTCEventLog(event_log_recordings_file_path_); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 563 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
549 while (!pending_updates_.empty()) { | 564 while (!pending_updates_.empty()) { |
550 const auto& update = pending_updates_.front(); | 565 const auto& update = pending_updates_.front(); |
551 for (auto& observer : observers_) | 566 for (auto& observer : observers_) |
552 observer.OnUpdate(update.command(), update.value()); | 567 observer.OnUpdate(update.command(), update.value()); |
553 pending_updates_.pop(); | 568 pending_updates_.pop(); |
554 } | 569 } |
555 } | 570 } |
556 | 571 |
557 } // namespace content | 572 } // namespace content |
OLD | NEW |