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

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 1855193002: Move the call to enable the WebRTC event log from PeerConnectionFactory to PeerConnection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with existing WebRtcEventLogHandler. Created 4 years, 7 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 // Represents the browser side of the browser <--> renderer communication 5 // Represents the browser side of the browser <--> renderer communication
6 // channel. There will be one RenderProcessHost per renderer process. 6 // channel. There will be one RenderProcessHost per renderer process.
7 7
8 #include "content/browser/renderer_host/render_process_host_impl.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 #endif 239 #endif
240 240
241 namespace content { 241 namespace content {
242 namespace { 242 namespace {
243 243
244 const char kSiteProcessMapKeyName[] = "content_site_process_map"; 244 const char kSiteProcessMapKeyName[] = "content_site_process_map";
245 245
246 #ifdef ENABLE_WEBRTC 246 #ifdef ENABLE_WEBRTC
247 const base::FilePath::CharType kAecDumpFileNameAddition[] = 247 const base::FilePath::CharType kAecDumpFileNameAddition[] =
248 FILE_PATH_LITERAL("aec_dump"); 248 FILE_PATH_LITERAL("aec_dump");
249 const base::FilePath::CharType kEventLogFileNameAddition[] =
250 FILE_PATH_LITERAL("event_log");
251 #endif 249 #endif
252 250
253 void CacheShaderInfo(int32_t id, base::FilePath path) { 251 void CacheShaderInfo(int32_t id, base::FilePath path) {
254 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path); 252 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path);
255 } 253 }
256 254
257 void RemoveShaderInfo(int32_t id) { 255 void RemoveShaderInfo(int32_t id) {
258 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id); 256 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id);
259 } 257 }
260 258
(...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, 1726 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest,
1729 OnShutdownRequest) 1727 OnShutdownRequest)
1730 IPC_MESSAGE_HANDLER(RenderProcessHostMsg_SuddenTerminationChanged, 1728 IPC_MESSAGE_HANDLER(RenderProcessHostMsg_SuddenTerminationChanged,
1731 SuddenTerminationChanged) 1729 SuddenTerminationChanged)
1732 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, 1730 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction,
1733 OnUserMetricsRecordAction) 1731 OnUserMetricsRecordAction)
1734 IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK) 1732 IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK)
1735 #if defined(ENABLE_WEBRTC) 1733 #if defined(ENABLE_WEBRTC)
1736 IPC_MESSAGE_HANDLER(AecDumpMsg_RegisterAecDumpConsumer, 1734 IPC_MESSAGE_HANDLER(AecDumpMsg_RegisterAecDumpConsumer,
1737 OnRegisterAecDumpConsumer) 1735 OnRegisterAecDumpConsumer)
1738 IPC_MESSAGE_HANDLER(WebRTCEventLogMsg_RegisterEventLogConsumer,
1739 OnRegisterEventLogConsumer)
1740 IPC_MESSAGE_HANDLER(AecDumpMsg_UnregisterAecDumpConsumer, 1736 IPC_MESSAGE_HANDLER(AecDumpMsg_UnregisterAecDumpConsumer,
1741 OnUnregisterAecDumpConsumer) 1737 OnUnregisterAecDumpConsumer)
1742 IPC_MESSAGE_HANDLER(WebRTCEventLogMsg_UnregisterEventLogConsumer,
1743 OnUnregisterEventLogConsumer)
1744 #endif 1738 #endif
1745 // Adding single handlers for your service here is fine, but once your 1739 // Adding single handlers for your service here is fine, but once your
1746 // service needs more than one handler, please extract them into a new 1740 // service needs more than one handler, please extract them into a new
1747 // message filter and add that filter to CreateMessageFilters(). 1741 // message filter and add that filter to CreateMessageFilters().
1748 IPC_END_MESSAGE_MAP() 1742 IPC_END_MESSAGE_MAP()
1749 1743
1750 return true; 1744 return true;
1751 } 1745 }
1752 1746
1753 // Dispatch incoming messages to the appropriate IPC::Listener. 1747 // Dispatch incoming messages to the appropriate IPC::Listener.
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 // guaranteed during the lifetime of the closure. 1993 // guaranteed during the lifetime of the closure.
2000 if (audio_input_renderer_host_) { 1994 if (audio_input_renderer_host_) {
2001 // Not null if RenderProcessHostImpl::Init has already been called. 1995 // Not null if RenderProcessHostImpl::Init has already been called.
2002 BrowserThread::PostTask( 1996 BrowserThread::PostTask(
2003 BrowserThread::IO, FROM_HERE, 1997 BrowserThread::IO, FROM_HERE,
2004 base::Bind(&AudioInputRendererHost::DisableDebugRecording, 1998 base::Bind(&AudioInputRendererHost::DisableDebugRecording,
2005 audio_input_renderer_host_)); 1999 audio_input_renderer_host_));
2006 } 2000 }
2007 } 2001 }
2008 2002
2009 void RenderProcessHostImpl::EnableEventLogRecordings(
2010 const base::FilePath& file) {
2011 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2012
2013 // Enable Event log for each registered consumer.
2014 base::FilePath file_with_extensions = GetEventLogFilePathWithExtensions(file);
2015 for (int id : aec_dump_consumers_)
2016 EnableEventLogForId(file_with_extensions, id);
2017 }
2018
2019 void RenderProcessHostImpl::DisableEventLogRecordings() {
2020 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2021
2022 // Posting on the FILE thread and then replying back on the UI thread is only
2023 // for avoiding races between enable and disable. Nothing is done on the FILE
2024 // thread.
2025 BrowserThread::PostTaskAndReply(
2026 BrowserThread::FILE, FROM_HERE, base::Bind(&base::DoNothing),
2027 base::Bind(&RenderProcessHostImpl::SendDisableEventLogToRenderer,
2028 weak_factory_.GetWeakPtr()));
2029 }
2030
2031 void RenderProcessHostImpl::SetWebRtcLogMessageCallback( 2003 void RenderProcessHostImpl::SetWebRtcLogMessageCallback(
2032 base::Callback<void(const std::string&)> callback) { 2004 base::Callback<void(const std::string&)> callback) {
2033 #if defined(ENABLE_WEBRTC) 2005 #if defined(ENABLE_WEBRTC)
2034 BrowserMainLoop::GetInstance()->media_stream_manager()-> 2006 BrowserMainLoop::GetInstance()->media_stream_manager()->
2035 RegisterNativeLogCallback(GetID(), callback); 2007 RegisterNativeLogCallback(GetID(), callback);
2036 #endif 2008 #endif
2037 } 2009 }
2038 2010
2039 void RenderProcessHostImpl::ClearWebRtcLogMessageCallback() { 2011 void RenderProcessHostImpl::ClearWebRtcLogMessageCallback() {
2040 #if defined(ENABLE_WEBRTC) 2012 #if defined(ENABLE_WEBRTC)
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
2648 } 2620 }
2649 2621
2650 #if defined(ENABLE_WEBRTC) 2622 #if defined(ENABLE_WEBRTC)
2651 void RenderProcessHostImpl::OnRegisterAecDumpConsumer(int id) { 2623 void RenderProcessHostImpl::OnRegisterAecDumpConsumer(int id) {
2652 BrowserThread::PostTask( 2624 BrowserThread::PostTask(
2653 BrowserThread::UI, FROM_HERE, 2625 BrowserThread::UI, FROM_HERE,
2654 base::Bind(&RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread, 2626 base::Bind(&RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread,
2655 weak_factory_.GetWeakPtr(), id)); 2627 weak_factory_.GetWeakPtr(), id));
2656 } 2628 }
2657 2629
2658 void RenderProcessHostImpl::OnRegisterEventLogConsumer(int id) {
2659 BrowserThread::PostTask(
2660 BrowserThread::UI, FROM_HERE,
2661 base::Bind(&RenderProcessHostImpl::RegisterEventLogConsumerOnUIThread,
2662 weak_factory_.GetWeakPtr(), id));
2663 }
2664
2665 void RenderProcessHostImpl::OnUnregisterAecDumpConsumer(int id) { 2630 void RenderProcessHostImpl::OnUnregisterAecDumpConsumer(int id) {
2666 BrowserThread::PostTask( 2631 BrowserThread::PostTask(
2667 BrowserThread::UI, FROM_HERE, 2632 BrowserThread::UI, FROM_HERE,
2668 base::Bind(&RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread, 2633 base::Bind(&RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread,
2669 weak_factory_.GetWeakPtr(), id)); 2634 weak_factory_.GetWeakPtr(), id));
2670 } 2635 }
2671 2636
2672 void RenderProcessHostImpl::OnUnregisterEventLogConsumer(int id) {
2673 BrowserThread::PostTask(
2674 BrowserThread::UI, FROM_HERE,
2675 base::Bind(&RenderProcessHostImpl::UnregisterEventLogConsumerOnUIThread,
2676 weak_factory_.GetWeakPtr(), id));
2677 }
2678
2679 void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) { 2637 void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) {
2680 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2638 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2681 aec_dump_consumers_.push_back(id); 2639 aec_dump_consumers_.push_back(id);
2682 2640
2683 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { 2641 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) {
2684 base::FilePath file_with_extensions = GetAecDumpFilePathWithExtensions( 2642 base::FilePath file_with_extensions = GetAecDumpFilePathWithExtensions(
2685 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()); 2643 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath());
2686 EnableAecDumpForId(file_with_extensions, id); 2644 EnableAecDumpForId(file_with_extensions, id);
2687 } 2645 }
2688 } 2646 }
2689 2647
2690 void RenderProcessHostImpl::RegisterEventLogConsumerOnUIThread(int id) {
2691 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2692 aec_dump_consumers_.push_back(id);
2693
2694 if (WebRTCInternals::GetInstance()->IsEventLogRecordingsEnabled()) {
2695 base::FilePath file_with_extensions = GetEventLogFilePathWithExtensions(
2696 WebRTCInternals::GetInstance()->GetEventLogRecordingsFilePath());
2697 EnableEventLogForId(file_with_extensions, id);
2698 }
2699 }
2700
2701 void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) { 2648 void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) {
2702 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2649 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2703 for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); 2650 for (std::vector<int>::iterator it = aec_dump_consumers_.begin();
2704 it != aec_dump_consumers_.end(); ++it) { 2651 it != aec_dump_consumers_.end(); ++it) {
2705 if (*it == id) { 2652 if (*it == id) {
2706 aec_dump_consumers_.erase(it); 2653 aec_dump_consumers_.erase(it);
2707 break; 2654 break;
2708 } 2655 }
2709 } 2656 }
2710 } 2657 }
2711 2658
2712 void RenderProcessHostImpl::UnregisterEventLogConsumerOnUIThread(int id) {
2713 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2714 for (std::vector<int>::iterator it = aec_dump_consumers_.begin();
2715 it != aec_dump_consumers_.end(); ++it) {
2716 if (*it == id) {
2717 aec_dump_consumers_.erase(it);
2718 break;
2719 }
2720 }
2721 }
2722
2723 void RenderProcessHostImpl::EnableAecDumpForId(const base::FilePath& file, 2659 void RenderProcessHostImpl::EnableAecDumpForId(const base::FilePath& file,
2724 int id) { 2660 int id) {
2725 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2661 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2726 BrowserThread::PostTaskAndReplyWithResult( 2662 BrowserThread::PostTaskAndReplyWithResult(
2727 BrowserThread::FILE, FROM_HERE, 2663 BrowserThread::FILE, FROM_HERE,
2728 base::Bind(&CreateFileForProcess, file.AddExtension(IntToStringType(id))), 2664 base::Bind(&CreateFileForProcess, file.AddExtension(IntToStringType(id))),
2729 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer, 2665 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer,
2730 weak_factory_.GetWeakPtr(), id)); 2666 weak_factory_.GetWeakPtr(), id));
2731 } 2667 }
2732 2668
2733 void RenderProcessHostImpl::EnableEventLogForId(const base::FilePath& file,
2734 int id) {
2735 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2736 BrowserThread::PostTaskAndReplyWithResult(
2737 BrowserThread::FILE, FROM_HERE,
2738 base::Bind(&CreateFileForProcess, file.AddExtension(IntToStringType(id))),
2739 base::Bind(&RenderProcessHostImpl::SendEventLogFileToRenderer,
2740 weak_factory_.GetWeakPtr(), id));
2741 }
2742
2743 void RenderProcessHostImpl::SendAecDumpFileToRenderer( 2669 void RenderProcessHostImpl::SendAecDumpFileToRenderer(
2744 int id, 2670 int id,
2745 IPC::PlatformFileForTransit file_for_transit) { 2671 IPC::PlatformFileForTransit file_for_transit) {
2746 if (file_for_transit == IPC::InvalidPlatformFileForTransit()) 2672 if (file_for_transit == IPC::InvalidPlatformFileForTransit())
2747 return; 2673 return;
2748 Send(new AecDumpMsg_EnableAecDump(id, file_for_transit)); 2674 Send(new AecDumpMsg_EnableAecDump(id, file_for_transit));
2749 } 2675 }
2750 2676
2751 void RenderProcessHostImpl::SendEventLogFileToRenderer(
2752 int id,
2753 IPC::PlatformFileForTransit file_for_transit) {
2754 if (file_for_transit == IPC::InvalidPlatformFileForTransit())
2755 return;
2756 Send(new WebRTCEventLogMsg_EnableEventLog(id, file_for_transit));
2757 }
2758
2759 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { 2677 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() {
2760 Send(new AecDumpMsg_DisableAecDump()); 2678 Send(new AecDumpMsg_DisableAecDump());
2761 } 2679 }
2762 2680
2763 void RenderProcessHostImpl::SendDisableEventLogToRenderer() {
2764 Send(new WebRTCEventLogMsg_DisableEventLog());
2765 }
2766
2767 base::FilePath RenderProcessHostImpl::GetAecDumpFilePathWithExtensions( 2681 base::FilePath RenderProcessHostImpl::GetAecDumpFilePathWithExtensions(
2768 const base::FilePath& file) { 2682 const base::FilePath& file) {
2769 return file.AddExtension(IntToStringType(base::GetProcId(GetHandle()))) 2683 return file.AddExtension(IntToStringType(base::GetProcId(GetHandle())))
2770 .AddExtension(kAecDumpFileNameAddition); 2684 .AddExtension(kAecDumpFileNameAddition);
2771 } 2685 }
2772
2773 base::FilePath RenderProcessHostImpl::GetEventLogFilePathWithExtensions(
2774 const base::FilePath& file) {
2775 return file.AddExtension(IntToStringType(base::GetProcId(GetHandle())))
2776 .AddExtension(kEventLogFileNameAddition);
2777 }
2778 #endif // defined(ENABLE_WEBRTC) 2686 #endif // defined(ENABLE_WEBRTC)
2779 2687
2780 void RenderProcessHostImpl::GetAudioOutputControllers( 2688 void RenderProcessHostImpl::GetAudioOutputControllers(
2781 const GetAudioOutputControllersCallback& callback) const { 2689 const GetAudioOutputControllersCallback& callback) const {
2782 audio_renderer_host()->GetOutputControllers(callback); 2690 audio_renderer_host()->GetOutputControllers(callback);
2783 } 2691 }
2784 2692
2785 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { 2693 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() {
2786 return bluetooth_dispatcher_host_.get(); 2694 return bluetooth_dispatcher_host_.get();
2787 } 2695 }
2788 2696
2789 void RenderProcessHostImpl::RecomputeAndUpdateWebKitPreferences() { 2697 void RenderProcessHostImpl::RecomputeAndUpdateWebKitPreferences() {
2790 // We are updating all widgets including swapped out ones. 2698 // We are updating all widgets including swapped out ones.
2791 std::unique_ptr<RenderWidgetHostIterator> widgets( 2699 std::unique_ptr<RenderWidgetHostIterator> widgets(
2792 RenderWidgetHostImpl::GetAllRenderWidgetHosts()); 2700 RenderWidgetHostImpl::GetAllRenderWidgetHosts());
2793 while (RenderWidgetHost* widget = widgets->GetNextHost()) { 2701 while (RenderWidgetHost* widget = widgets->GetNextHost()) {
2794 RenderViewHost* rvh = RenderViewHost::From(widget); 2702 RenderViewHost* rvh = RenderViewHost::From(widget);
2795 if (!rvh) 2703 if (!rvh)
2796 continue; 2704 continue;
2797 2705
2798 // Skip widgets in other processes. 2706 // Skip widgets in other processes.
2799 if (rvh->GetProcess()->GetID() != GetID()) 2707 if (rvh->GetProcess()->GetID() != GetID())
2800 continue; 2708 continue;
2801 2709
2802 rvh->OnWebkitPreferencesChanged(); 2710 rvh->OnWebkitPreferencesChanged();
2803 } 2711 }
2804 } 2712 }
2805 2713
2806 } // namespace content 2714 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698