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

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: Removed content/public/ interface, used RenderProcessHost instead. 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 16 matching lines...) Expand all
2057 p2p_socket_dispatcher_host_, incoming, 2029 p2p_socket_dispatcher_host_, incoming,
2058 outgoing, packet_callback)); 2030 outgoing, packet_callback));
2059 2031
2060 if (stop_rtp_dump_callback_.is_null()) { 2032 if (stop_rtp_dump_callback_.is_null()) {
2061 stop_rtp_dump_callback_ = 2033 stop_rtp_dump_callback_ =
2062 base::Bind(&P2PSocketDispatcherHost::StopRtpDumpOnUIThread, 2034 base::Bind(&P2PSocketDispatcherHost::StopRtpDumpOnUIThread,
2063 p2p_socket_dispatcher_host_); 2035 p2p_socket_dispatcher_host_);
2064 } 2036 }
2065 return stop_rtp_dump_callback_; 2037 return stop_rtp_dump_callback_;
2066 } 2038 }
2039
2040 void RenderProcessHostImpl::RegisterEventLogHandler(
2041 const RenderProcessHost::EventLogStartFunc& start_logging_callback,
2042 const RenderProcessHost::EventLogStopFunc& stop_logging_callback) {
2043 eventlog_callback_handler_.RegisterEventLogHandler(start_logging_callback,
2044 stop_logging_callback);
2045 }
2046
2047 void RenderProcessHostImpl::RegisterPeerConnectionCallbacks(
2048 const RenderProcessHost::PeerConnectionAddedFunc& pc_added_callback,
2049 const RenderProcessHost::PeerConnectionRemovedFunc& pc_removed_callback) {
2050 eventlog_callback_handler_.RegisterPeerConnectionCallbacks(
2051 pc_added_callback, pc_removed_callback);
2052 }
2053
2054 void RenderProcessHostImpl::SignalStartEventLog(
2055 const base::FilePath& file_path) {
2056 eventlog_callback_handler_.StartEventLog(file_path);
2057 }
2058
2059 void RenderProcessHostImpl::SignalStopEventLog() {
2060 eventlog_callback_handler_.StopEventLog();
2061 }
2062
2063 void RenderProcessHostImpl::SignalPeerConnectionAdded(int connection_id) {
2064 eventlog_callback_handler_.PeerConnectionAdded(connection_id);
2065 }
2066
2067 void RenderProcessHostImpl::SignalPeerConnectionRemoved(int connection_id) {
2068 eventlog_callback_handler_.PeerConnectionRemoved(connection_id);
2069 }
2070
2067 #endif 2071 #endif
2068 2072
2069 IPC::ChannelProxy* RenderProcessHostImpl::GetChannel() { 2073 IPC::ChannelProxy* RenderProcessHostImpl::GetChannel() {
2070 return channel_.get(); 2074 return channel_.get();
2071 } 2075 }
2072 2076
2073 void RenderProcessHostImpl::AddFilter(BrowserMessageFilter* filter) { 2077 void RenderProcessHostImpl::AddFilter(BrowserMessageFilter* filter) {
2074 channel_->AddFilter(filter->GetFilter()); 2078 channel_->AddFilter(filter->GetFilter());
2075 } 2079 }
2076 2080
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
2648 } 2652 }
2649 2653
2650 #if defined(ENABLE_WEBRTC) 2654 #if defined(ENABLE_WEBRTC)
2651 void RenderProcessHostImpl::OnRegisterAecDumpConsumer(int id) { 2655 void RenderProcessHostImpl::OnRegisterAecDumpConsumer(int id) {
2652 BrowserThread::PostTask( 2656 BrowserThread::PostTask(
2653 BrowserThread::UI, FROM_HERE, 2657 BrowserThread::UI, FROM_HERE,
2654 base::Bind(&RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread, 2658 base::Bind(&RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread,
2655 weak_factory_.GetWeakPtr(), id)); 2659 weak_factory_.GetWeakPtr(), id));
2656 } 2660 }
2657 2661
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) { 2662 void RenderProcessHostImpl::OnUnregisterAecDumpConsumer(int id) {
2666 BrowserThread::PostTask( 2663 BrowserThread::PostTask(
2667 BrowserThread::UI, FROM_HERE, 2664 BrowserThread::UI, FROM_HERE,
2668 base::Bind(&RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread, 2665 base::Bind(&RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread,
2669 weak_factory_.GetWeakPtr(), id)); 2666 weak_factory_.GetWeakPtr(), id));
2670 } 2667 }
2671 2668
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) { 2669 void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) {
2680 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2670 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2681 aec_dump_consumers_.push_back(id); 2671 aec_dump_consumers_.push_back(id);
2682 2672
2683 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { 2673 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) {
2684 base::FilePath file_with_extensions = GetAecDumpFilePathWithExtensions( 2674 base::FilePath file_with_extensions = GetAecDumpFilePathWithExtensions(
2685 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()); 2675 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath());
2686 EnableAecDumpForId(file_with_extensions, id); 2676 EnableAecDumpForId(file_with_extensions, id);
2687 } 2677 }
2688 } 2678 }
2689 2679
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) { 2680 void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) {
2702 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2681 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2703 for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); 2682 for (std::vector<int>::iterator it = aec_dump_consumers_.begin();
2704 it != aec_dump_consumers_.end(); ++it) { 2683 it != aec_dump_consumers_.end(); ++it) {
2705 if (*it == id) { 2684 if (*it == id) {
2706 aec_dump_consumers_.erase(it); 2685 aec_dump_consumers_.erase(it);
2707 break; 2686 break;
2708 } 2687 }
2709 } 2688 }
2710 } 2689 }
2711 2690
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, 2691 void RenderProcessHostImpl::EnableAecDumpForId(const base::FilePath& file,
2724 int id) { 2692 int id) {
2725 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2693 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2726 BrowserThread::PostTaskAndReplyWithResult( 2694 BrowserThread::PostTaskAndReplyWithResult(
2727 BrowserThread::FILE, FROM_HERE, 2695 BrowserThread::FILE, FROM_HERE,
2728 base::Bind(&CreateFileForProcess, file.AddExtension(IntToStringType(id))), 2696 base::Bind(&CreateFileForProcess, file.AddExtension(IntToStringType(id))),
2729 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer, 2697 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer,
2730 weak_factory_.GetWeakPtr(), id)); 2698 weak_factory_.GetWeakPtr(), id));
2731 } 2699 }
2732 2700
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( 2701 void RenderProcessHostImpl::SendAecDumpFileToRenderer(
2744 int id, 2702 int id,
2745 IPC::PlatformFileForTransit file_for_transit) { 2703 IPC::PlatformFileForTransit file_for_transit) {
2746 if (file_for_transit == IPC::InvalidPlatformFileForTransit()) 2704 if (file_for_transit == IPC::InvalidPlatformFileForTransit())
2747 return; 2705 return;
2748 Send(new AecDumpMsg_EnableAecDump(id, file_for_transit)); 2706 Send(new AecDumpMsg_EnableAecDump(id, file_for_transit));
2749 } 2707 }
2750 2708
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() { 2709 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() {
2760 Send(new AecDumpMsg_DisableAecDump()); 2710 Send(new AecDumpMsg_DisableAecDump());
2761 } 2711 }
2762 2712
2763 void RenderProcessHostImpl::SendDisableEventLogToRenderer() {
2764 Send(new WebRTCEventLogMsg_DisableEventLog());
2765 }
2766
2767 base::FilePath RenderProcessHostImpl::GetAecDumpFilePathWithExtensions( 2713 base::FilePath RenderProcessHostImpl::GetAecDumpFilePathWithExtensions(
2768 const base::FilePath& file) { 2714 const base::FilePath& file) {
2769 return file.AddExtension(IntToStringType(base::GetProcId(GetHandle()))) 2715 return file.AddExtension(IntToStringType(base::GetProcId(GetHandle())))
2770 .AddExtension(kAecDumpFileNameAddition); 2716 .AddExtension(kAecDumpFileNameAddition);
2771 } 2717 }
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) 2718 #endif // defined(ENABLE_WEBRTC)
2779 2719
2780 void RenderProcessHostImpl::GetAudioOutputControllers( 2720 void RenderProcessHostImpl::GetAudioOutputControllers(
2781 const GetAudioOutputControllersCallback& callback) const { 2721 const GetAudioOutputControllersCallback& callback) const {
2782 audio_renderer_host()->GetOutputControllers(callback); 2722 audio_renderer_host()->GetOutputControllers(callback);
2783 } 2723 }
2784 2724
2785 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { 2725 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() {
2786 return bluetooth_dispatcher_host_.get(); 2726 return bluetooth_dispatcher_host_.get();
2787 } 2727 }
2788 2728
2789 void RenderProcessHostImpl::RecomputeAndUpdateWebKitPreferences() { 2729 void RenderProcessHostImpl::RecomputeAndUpdateWebKitPreferences() {
2790 // We are updating all widgets including swapped out ones. 2730 // We are updating all widgets including swapped out ones.
2791 std::unique_ptr<RenderWidgetHostIterator> widgets( 2731 std::unique_ptr<RenderWidgetHostIterator> widgets(
2792 RenderWidgetHostImpl::GetAllRenderWidgetHosts()); 2732 RenderWidgetHostImpl::GetAllRenderWidgetHosts());
2793 while (RenderWidgetHost* widget = widgets->GetNextHost()) { 2733 while (RenderWidgetHost* widget = widgets->GetNextHost()) {
2794 RenderViewHost* rvh = RenderViewHost::From(widget); 2734 RenderViewHost* rvh = RenderViewHost::From(widget);
2795 if (!rvh) 2735 if (!rvh)
2796 continue; 2736 continue;
2797 2737
2798 // Skip widgets in other processes. 2738 // Skip widgets in other processes.
2799 if (rvh->GetProcess()->GetID() != GetID()) 2739 if (rvh->GetProcess()->GetID() != GetID())
2800 continue; 2740 continue;
2801 2741
2802 rvh->OnWebkitPreferencesChanged(); 2742 rvh->OnWebkitPreferencesChanged();
2803 } 2743 }
2804 } 2744 }
2805 2745
2806 } // namespace content 2746 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698