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

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: Added limit to number of log files and the size of the log files. Created 4 years, 8 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 #endif 237 #endif
238 238
239 namespace content { 239 namespace content {
240 namespace { 240 namespace {
241 241
242 const char kSiteProcessMapKeyName[] = "content_site_process_map"; 242 const char kSiteProcessMapKeyName[] = "content_site_process_map";
243 243
244 #ifdef ENABLE_WEBRTC 244 #ifdef ENABLE_WEBRTC
245 const base::FilePath::CharType kAecDumpFileNameAddition[] = 245 const base::FilePath::CharType kAecDumpFileNameAddition[] =
246 FILE_PATH_LITERAL("aec_dump"); 246 FILE_PATH_LITERAL("aec_dump");
247 const base::FilePath::CharType kEventLogFileNameAddition[] =
248 FILE_PATH_LITERAL("event_log");
249 #endif 247 #endif
250 248
251 void CacheShaderInfo(int32_t id, base::FilePath path) { 249 void CacheShaderInfo(int32_t id, base::FilePath path) {
252 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path); 250 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path);
253 } 251 }
254 252
255 void RemoveShaderInfo(int32_t id) { 253 void RemoveShaderInfo(int32_t id) {
256 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id); 254 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id);
257 } 255 }
258 256
(...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, 1758 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest,
1761 OnShutdownRequest) 1759 OnShutdownRequest)
1762 IPC_MESSAGE_HANDLER(RenderProcessHostMsg_SuddenTerminationChanged, 1760 IPC_MESSAGE_HANDLER(RenderProcessHostMsg_SuddenTerminationChanged,
1763 SuddenTerminationChanged) 1761 SuddenTerminationChanged)
1764 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, 1762 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction,
1765 OnUserMetricsRecordAction) 1763 OnUserMetricsRecordAction)
1766 IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK) 1764 IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK)
1767 #if defined(ENABLE_WEBRTC) 1765 #if defined(ENABLE_WEBRTC)
1768 IPC_MESSAGE_HANDLER(AecDumpMsg_RegisterAecDumpConsumer, 1766 IPC_MESSAGE_HANDLER(AecDumpMsg_RegisterAecDumpConsumer,
1769 OnRegisterAecDumpConsumer) 1767 OnRegisterAecDumpConsumer)
1770 IPC_MESSAGE_HANDLER(WebRTCEventLogMsg_RegisterEventLogConsumer,
1771 OnRegisterEventLogConsumer)
1772 IPC_MESSAGE_HANDLER(AecDumpMsg_UnregisterAecDumpConsumer, 1768 IPC_MESSAGE_HANDLER(AecDumpMsg_UnregisterAecDumpConsumer,
1773 OnUnregisterAecDumpConsumer) 1769 OnUnregisterAecDumpConsumer)
1774 IPC_MESSAGE_HANDLER(WebRTCEventLogMsg_UnregisterEventLogConsumer,
1775 OnUnregisterEventLogConsumer)
1776 #endif 1770 #endif
1777 // Adding single handlers for your service here is fine, but once your 1771 // Adding single handlers for your service here is fine, but once your
1778 // service needs more than one handler, please extract them into a new 1772 // service needs more than one handler, please extract them into a new
1779 // message filter and add that filter to CreateMessageFilters(). 1773 // message filter and add that filter to CreateMessageFilters().
1780 IPC_END_MESSAGE_MAP() 1774 IPC_END_MESSAGE_MAP()
1781 1775
1782 return true; 1776 return true;
1783 } 1777 }
1784 1778
1785 // Dispatch incoming messages to the appropriate IPC::Listener. 1779 // Dispatch incoming messages to the appropriate IPC::Listener.
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 // guaranteed during the lifetime of the closure. 2027 // guaranteed during the lifetime of the closure.
2034 if (audio_input_renderer_host_) { 2028 if (audio_input_renderer_host_) {
2035 // Not null if RenderProcessHostImpl::Init has already been called. 2029 // Not null if RenderProcessHostImpl::Init has already been called.
2036 BrowserThread::PostTask( 2030 BrowserThread::PostTask(
2037 BrowserThread::IO, FROM_HERE, 2031 BrowserThread::IO, FROM_HERE,
2038 base::Bind(&AudioInputRendererHost::DisableDebugRecording, 2032 base::Bind(&AudioInputRendererHost::DisableDebugRecording,
2039 audio_input_renderer_host_)); 2033 audio_input_renderer_host_));
2040 } 2034 }
2041 } 2035 }
2042 2036
2043 void RenderProcessHostImpl::EnableEventLogRecordings(
2044 const base::FilePath& file) {
2045 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2046
2047 // Enable Event log for each registered consumer.
2048 base::FilePath file_with_extensions = GetEventLogFilePathWithExtensions(file);
2049 for (int id : aec_dump_consumers_)
2050 EnableEventLogForId(file_with_extensions, id);
2051 }
2052
2053 void RenderProcessHostImpl::DisableEventLogRecordings() {
2054 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2055
2056 // Posting on the FILE thread and then replying back on the UI thread is only
2057 // for avoiding races between enable and disable. Nothing is done on the FILE
2058 // thread.
2059 BrowserThread::PostTaskAndReply(
2060 BrowserThread::FILE, FROM_HERE, base::Bind(&base::DoNothing),
2061 base::Bind(&RenderProcessHostImpl::SendDisableEventLogToRenderer,
2062 weak_factory_.GetWeakPtr()));
2063 }
2064
2065 void RenderProcessHostImpl::SetWebRtcLogMessageCallback( 2037 void RenderProcessHostImpl::SetWebRtcLogMessageCallback(
2066 base::Callback<void(const std::string&)> callback) { 2038 base::Callback<void(const std::string&)> callback) {
2067 #if defined(ENABLE_WEBRTC) 2039 #if defined(ENABLE_WEBRTC)
2068 BrowserMainLoop::GetInstance()->media_stream_manager()-> 2040 BrowserMainLoop::GetInstance()->media_stream_manager()->
2069 RegisterNativeLogCallback(GetID(), callback); 2041 RegisterNativeLogCallback(GetID(), callback);
2070 #endif 2042 #endif
2071 } 2043 }
2072 2044
2073 RenderProcessHostImpl::WebRtcStopRtpDumpCallback 2045 RenderProcessHostImpl::WebRtcStopRtpDumpCallback
2074 RenderProcessHostImpl::StartRtpDump( 2046 RenderProcessHostImpl::StartRtpDump(
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
2649 } 2621 }
2650 2622
2651 #if defined(ENABLE_WEBRTC) 2623 #if defined(ENABLE_WEBRTC)
2652 void RenderProcessHostImpl::OnRegisterAecDumpConsumer(int id) { 2624 void RenderProcessHostImpl::OnRegisterAecDumpConsumer(int id) {
2653 BrowserThread::PostTask( 2625 BrowserThread::PostTask(
2654 BrowserThread::UI, FROM_HERE, 2626 BrowserThread::UI, FROM_HERE,
2655 base::Bind(&RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread, 2627 base::Bind(&RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread,
2656 weak_factory_.GetWeakPtr(), id)); 2628 weak_factory_.GetWeakPtr(), id));
2657 } 2629 }
2658 2630
2659 void RenderProcessHostImpl::OnRegisterEventLogConsumer(int id) {
2660 BrowserThread::PostTask(
2661 BrowserThread::UI, FROM_HERE,
2662 base::Bind(&RenderProcessHostImpl::RegisterEventLogConsumerOnUIThread,
2663 weak_factory_.GetWeakPtr(), id));
2664 }
2665
2666 void RenderProcessHostImpl::OnUnregisterAecDumpConsumer(int id) { 2631 void RenderProcessHostImpl::OnUnregisterAecDumpConsumer(int id) {
2667 BrowserThread::PostTask( 2632 BrowserThread::PostTask(
2668 BrowserThread::UI, FROM_HERE, 2633 BrowserThread::UI, FROM_HERE,
2669 base::Bind(&RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread, 2634 base::Bind(&RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread,
2670 weak_factory_.GetWeakPtr(), id)); 2635 weak_factory_.GetWeakPtr(), id));
2671 } 2636 }
2672 2637
2673 void RenderProcessHostImpl::OnUnregisterEventLogConsumer(int id) {
2674 BrowserThread::PostTask(
2675 BrowserThread::UI, FROM_HERE,
2676 base::Bind(&RenderProcessHostImpl::UnregisterEventLogConsumerOnUIThread,
2677 weak_factory_.GetWeakPtr(), id));
2678 }
2679
2680 void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) { 2638 void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) {
2681 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2639 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2682 aec_dump_consumers_.push_back(id); 2640 aec_dump_consumers_.push_back(id);
2683 2641
2684 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { 2642 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) {
2685 base::FilePath file_with_extensions = GetAecDumpFilePathWithExtensions( 2643 base::FilePath file_with_extensions = GetAecDumpFilePathWithExtensions(
2686 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()); 2644 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath());
2687 EnableAecDumpForId(file_with_extensions, id); 2645 EnableAecDumpForId(file_with_extensions, id);
2688 } 2646 }
2689 } 2647 }
2690 2648
2691 void RenderProcessHostImpl::RegisterEventLogConsumerOnUIThread(int id) {
2692 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2693 aec_dump_consumers_.push_back(id);
2694
2695 if (WebRTCInternals::GetInstance()->IsEventLogRecordingsEnabled()) {
2696 base::FilePath file_with_extensions = GetEventLogFilePathWithExtensions(
2697 WebRTCInternals::GetInstance()->GetEventLogRecordingsFilePath());
2698 EnableEventLogForId(file_with_extensions, id);
2699 }
2700 }
2701
2702 void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) { 2649 void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) {
2703 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2650 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2704 for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); 2651 for (std::vector<int>::iterator it = aec_dump_consumers_.begin();
2705 it != aec_dump_consumers_.end(); ++it) { 2652 it != aec_dump_consumers_.end(); ++it) {
2706 if (*it == id) { 2653 if (*it == id) {
2707 aec_dump_consumers_.erase(it); 2654 aec_dump_consumers_.erase(it);
2708 break; 2655 break;
2709 } 2656 }
2710 } 2657 }
2711 } 2658 }
2712 2659
2713 void RenderProcessHostImpl::UnregisterEventLogConsumerOnUIThread(int id) {
2714 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2715 for (std::vector<int>::iterator it = aec_dump_consumers_.begin();
2716 it != aec_dump_consumers_.end(); ++it) {
2717 if (*it == id) {
2718 aec_dump_consumers_.erase(it);
2719 break;
2720 }
2721 }
2722 }
2723
2724 void RenderProcessHostImpl::EnableAecDumpForId(const base::FilePath& file, 2660 void RenderProcessHostImpl::EnableAecDumpForId(const base::FilePath& file,
2725 int id) { 2661 int id) {
2726 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2662 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2727 BrowserThread::PostTaskAndReplyWithResult( 2663 BrowserThread::PostTaskAndReplyWithResult(
2728 BrowserThread::FILE, FROM_HERE, 2664 BrowserThread::FILE, FROM_HERE,
2729 base::Bind(&CreateFileForProcess, file.AddExtension(IntToStringType(id)), 2665 base::Bind(&CreateFileForProcess, file.AddExtension(IntToStringType(id)),
2730 GetHandle()), 2666 GetHandle()),
2731 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer, 2667 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer,
2732 weak_factory_.GetWeakPtr(), id)); 2668 weak_factory_.GetWeakPtr(), id));
2733 } 2669 }
2734 2670
2735 void RenderProcessHostImpl::EnableEventLogForId(const base::FilePath& file,
2736 int id) {
2737 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2738 BrowserThread::PostTaskAndReplyWithResult(
2739 BrowserThread::FILE, FROM_HERE,
2740 base::Bind(&CreateFileForProcess, file.AddExtension(IntToStringType(id)),
2741 GetHandle()),
2742 base::Bind(&RenderProcessHostImpl::SendEventLogFileToRenderer,
2743 weak_factory_.GetWeakPtr(), id));
2744 }
2745
2746 void RenderProcessHostImpl::SendAecDumpFileToRenderer( 2671 void RenderProcessHostImpl::SendAecDumpFileToRenderer(
2747 int id, 2672 int id,
2748 IPC::PlatformFileForTransit file_for_transit) { 2673 IPC::PlatformFileForTransit file_for_transit) {
2749 if (file_for_transit == IPC::InvalidPlatformFileForTransit()) 2674 if (file_for_transit == IPC::InvalidPlatformFileForTransit())
2750 return; 2675 return;
2751 Send(new AecDumpMsg_EnableAecDump(id, file_for_transit)); 2676 Send(new AecDumpMsg_EnableAecDump(id, file_for_transit));
2752 } 2677 }
2753 2678
2754 void RenderProcessHostImpl::SendEventLogFileToRenderer(
2755 int id,
2756 IPC::PlatformFileForTransit file_for_transit) {
2757 if (file_for_transit == IPC::InvalidPlatformFileForTransit())
2758 return;
2759 Send(new WebRTCEventLogMsg_EnableEventLog(id, file_for_transit));
2760 }
2761
2762 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { 2679 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() {
2763 Send(new AecDumpMsg_DisableAecDump()); 2680 Send(new AecDumpMsg_DisableAecDump());
2764 } 2681 }
2765 2682
2766 void RenderProcessHostImpl::SendDisableEventLogToRenderer() {
2767 Send(new WebRTCEventLogMsg_DisableEventLog());
2768 }
2769
2770 base::FilePath RenderProcessHostImpl::GetAecDumpFilePathWithExtensions( 2683 base::FilePath RenderProcessHostImpl::GetAecDumpFilePathWithExtensions(
2771 const base::FilePath& file) { 2684 const base::FilePath& file) {
2772 return file.AddExtension(IntToStringType(base::GetProcId(GetHandle()))) 2685 return file.AddExtension(IntToStringType(base::GetProcId(GetHandle())))
2773 .AddExtension(kAecDumpFileNameAddition); 2686 .AddExtension(kAecDumpFileNameAddition);
2774 } 2687 }
2775
2776 base::FilePath RenderProcessHostImpl::GetEventLogFilePathWithExtensions(
2777 const base::FilePath& file) {
2778 return file.AddExtension(IntToStringType(base::GetProcId(GetHandle())))
2779 .AddExtension(kEventLogFileNameAddition);
2780 }
2781 #endif // defined(ENABLE_WEBRTC) 2688 #endif // defined(ENABLE_WEBRTC)
2782 2689
2783 void RenderProcessHostImpl::GetAudioOutputControllers( 2690 void RenderProcessHostImpl::GetAudioOutputControllers(
2784 const GetAudioOutputControllersCallback& callback) const { 2691 const GetAudioOutputControllersCallback& callback) const {
2785 audio_renderer_host()->GetOutputControllers(callback); 2692 audio_renderer_host()->GetOutputControllers(callback);
2786 } 2693 }
2787 2694
2788 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { 2695 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() {
2789 return bluetooth_dispatcher_host_.get(); 2696 return bluetooth_dispatcher_host_.get();
2790 } 2697 }
2791 2698
2792 void RenderProcessHostImpl::RecomputeAndUpdateWebKitPreferences() { 2699 void RenderProcessHostImpl::RecomputeAndUpdateWebKitPreferences() {
2793 // We are updating all widgets including swapped out ones. 2700 // We are updating all widgets including swapped out ones.
2794 scoped_ptr<RenderWidgetHostIterator> widgets( 2701 scoped_ptr<RenderWidgetHostIterator> widgets(
2795 RenderWidgetHostImpl::GetAllRenderWidgetHosts()); 2702 RenderWidgetHostImpl::GetAllRenderWidgetHosts());
2796 while (RenderWidgetHost* widget = widgets->GetNextHost()) { 2703 while (RenderWidgetHost* widget = widgets->GetNextHost()) {
2797 RenderViewHost* rvh = RenderViewHost::From(widget); 2704 RenderViewHost* rvh = RenderViewHost::From(widget);
2798 if (!rvh) 2705 if (!rvh)
2799 continue; 2706 continue;
2800 2707
2801 // Skip widgets in other processes. 2708 // Skip widgets in other processes.
2802 if (rvh->GetProcess()->GetID() != GetID()) 2709 if (rvh->GetProcess()->GetID() != GetID())
2803 continue; 2710 continue;
2804 2711
2805 rvh->OnWebkitPreferencesChanged(); 2712 rvh->OnWebkitPreferencesChanged();
2806 } 2713 }
2807 } 2714 }
2808 2715
2809 } // namespace content 2716 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698