OLD | NEW |
---|---|
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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 return IPC::InvalidPlatformFileForTransit(); | 312 return IPC::InvalidPlatformFileForTransit(); |
313 } | 313 } |
314 return IPC::TakePlatformFileForTransit(std::move(dump_file)); | 314 return IPC::TakePlatformFileForTransit(std::move(dump_file)); |
315 } | 315 } |
316 | 316 |
317 // Allow us to only run the trial in the first renderer. | 317 // Allow us to only run the trial in the first renderer. |
318 bool has_done_stun_trials = false; | 318 bool has_done_stun_trials = false; |
319 | 319 |
320 #endif | 320 #endif |
321 | 321 |
322 // Tracks the maximum number of simultaneous output streams browser-wide. | |
323 // Accessed on UI thread. | |
324 base::LazyInstance<media::AudioStreamsTracker> g_audio_streams_tracker = | |
325 LAZY_INSTANCE_INITIALIZER; | |
326 | |
322 // the global list of all renderer processes | 327 // the global list of all renderer processes |
323 base::LazyInstance<IDMap<RenderProcessHost*>>::Leaky g_all_hosts = | 328 base::LazyInstance<IDMap<RenderProcessHost*>>::Leaky g_all_hosts = |
324 LAZY_INSTANCE_INITIALIZER; | 329 LAZY_INSTANCE_INITIALIZER; |
325 | 330 |
326 // Map of site to process, to ensure we only have one RenderProcessHost per | 331 // Map of site to process, to ensure we only have one RenderProcessHost per |
327 // site in process-per-site mode. Each map is specific to a BrowserContext. | 332 // site in process-per-site mode. Each map is specific to a BrowserContext. |
328 class SiteProcessMap : public base::SupportsUserData::Data { | 333 class SiteProcessMap : public base::SupportsUserData::Data { |
329 public: | 334 public: |
330 typedef base::hash_map<std::string, RenderProcessHost*> SiteToProcessMap; | 335 typedef base::hash_map<std::string, RenderProcessHost*> SiteToProcessMap; |
331 SiteProcessMap() {} | 336 SiteProcessMap() {} |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
775 | 780 |
776 is_dead_ = true; | 781 is_dead_ = true; |
777 | 782 |
778 UnregisterHost(GetID()); | 783 UnregisterHost(GetID()); |
779 | 784 |
780 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 785 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
781 switches::kDisableGpuShaderDiskCache)) { | 786 switches::kDisableGpuShaderDiskCache)) { |
782 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 787 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
783 base::Bind(&RemoveShaderInfo, GetID())); | 788 base::Bind(&RemoveShaderInfo, GetID())); |
784 } | 789 } |
790 | |
791 // If we had any streams, report UMA stats for the maximum number of | |
792 // simultaneous streams for this render process and for the whole browser | |
793 // process since last reported. | |
794 if (audio_streams_tracker_.max_stream_count() > 0) { | |
795 UMA_HISTOGRAM_CUSTOM_COUNTS("Media.AudioRendererIpcStreams", | |
796 audio_streams_tracker_.max_stream_count(), 1, | |
797 50, 51); | |
798 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
799 "Media.AudioRendererIpcStreamsTotal", | |
800 g_audio_streams_tracker.Get().max_stream_count(), 1, 100, 101); | |
ncarter (slow)
2017/01/31 18:33:12
This logging used to happen each time a MessageFil
DaleCurtis
2017/01/31 22:08:31
Ah, I didn't know multiple sets of MessageFilter's
Henrik Grunell
2017/02/03 08:52:20
Sorry Dale, I missed that I was supposed to reply
DaleCurtis
2017/02/06 22:19:02
Deleted, thanks!
| |
801 g_audio_streams_tracker.Get().ResetMaxStreamCount(); | |
802 } | |
785 } | 803 } |
786 | 804 |
787 bool RenderProcessHostImpl::Init() { | 805 bool RenderProcessHostImpl::Init() { |
788 // calling Init() more than once does nothing, this makes it more convenient | 806 // calling Init() more than once does nothing, this makes it more convenient |
789 // for the view host which may not be sure in some cases | 807 // for the view host which may not be sure in some cases |
790 if (HasConnection()) | 808 if (HasConnection()) |
791 return true; | 809 return true; |
792 | 810 |
793 is_dead_ = false; | 811 is_dead_ = false; |
794 | 812 |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1548 if (visible_widgets_ == 0) { | 1566 if (visible_widgets_ == 0) { |
1549 DCHECK(!is_process_backgrounded_); | 1567 DCHECK(!is_process_backgrounded_); |
1550 UpdateProcessPriority(); | 1568 UpdateProcessPriority(); |
1551 } | 1569 } |
1552 } | 1570 } |
1553 | 1571 |
1554 int RenderProcessHostImpl::VisibleWidgetCount() const { | 1572 int RenderProcessHostImpl::VisibleWidgetCount() const { |
1555 return visible_widgets_; | 1573 return visible_widgets_; |
1556 } | 1574 } |
1557 | 1575 |
1558 void RenderProcessHostImpl::AudioStateChanged() { | 1576 void RenderProcessHostImpl::OnAudioStreamAdded() { |
1577 audio_streams_tracker_.IncreaseStreamCount(); | |
1578 g_audio_streams_tracker.Get().IncreaseStreamCount(); | |
1559 UpdateProcessPriority(); | 1579 UpdateProcessPriority(); |
Max Morin
2017/01/30 11:47:07
It probably makes sense to only UpdateProcessPrior
DaleCurtis
2017/02/06 22:19:02
UpdateProcessPriority() takes care of this.
| |
1560 } | 1580 } |
1561 | 1581 |
1582 void RenderProcessHostImpl::OnAudioStreamRemoved() { | |
1583 audio_streams_tracker_.DecreaseStreamCount(); | |
1584 g_audio_streams_tracker.Get().DecreaseStreamCount(); | |
1585 UpdateProcessPriority(); | |
1586 } | |
1587 | |
1562 bool RenderProcessHostImpl::IsForGuestsOnly() const { | 1588 bool RenderProcessHostImpl::IsForGuestsOnly() const { |
1563 return is_for_guests_only_; | 1589 return is_for_guests_only_; |
1564 } | 1590 } |
1565 | 1591 |
1566 StoragePartition* RenderProcessHostImpl::GetStoragePartition() const { | 1592 StoragePartition* RenderProcessHostImpl::GetStoragePartition() const { |
1567 return storage_partition_impl_; | 1593 return storage_partition_impl_; |
1568 } | 1594 } |
1569 | 1595 |
1570 static void AppendCompositorCommandLineFlags(base::CommandLine* command_line) { | 1596 static void AppendCompositorCommandLineFlags(base::CommandLine* command_line) { |
1571 command_line->AppendSwitchASCII( | 1597 command_line->AppendSwitchASCII( |
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2808 | 2834 |
2809 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2835 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
2810 switches::kDisableRendererPriorityManagement)) { | 2836 switches::kDisableRendererPriorityManagement)) { |
2811 return; | 2837 return; |
2812 } | 2838 } |
2813 | 2839 |
2814 // We background a process as soon as it hosts no active audio streams and no | 2840 // We background a process as soon as it hosts no active audio streams and no |
2815 // visible widgets -- the callers must call this function whenever we | 2841 // visible widgets -- the callers must call this function whenever we |
2816 // transition in/out of those states. | 2842 // transition in/out of those states. |
2817 const bool should_background = | 2843 const bool should_background = |
2818 visible_widgets_ == 0 && !audio_renderer_host_->HasActiveAudio() && | 2844 visible_widgets_ == 0 && !audio_streams_tracker_.has_streams() && |
2819 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 2845 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
2820 switches::kDisableRendererBackgrounding); | 2846 switches::kDisableRendererBackgrounding); |
2821 | 2847 |
2822 // TODO(sebsg): Remove this ifdef when https://crbug.com/537671 is fixed. | 2848 // TODO(sebsg): Remove this ifdef when https://crbug.com/537671 is fixed. |
2823 #if !defined(OS_ANDROID) | 2849 #if !defined(OS_ANDROID) |
2824 if (is_process_backgrounded_ == should_background) | 2850 if (is_process_backgrounded_ == should_background) |
2825 return; | 2851 return; |
2826 #endif | 2852 #endif |
2827 | 2853 |
2828 TRACE_EVENT1("renderer_host", "RenderProcessHostImpl::UpdateProcessPriority", | 2854 TRACE_EVENT1("renderer_host", "RenderProcessHostImpl::UpdateProcessPriority", |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3057 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3083 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
3058 | 3084 |
3059 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3085 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
3060 // Capture the error message in a crash key value. | 3086 // Capture the error message in a crash key value. |
3061 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3087 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
3062 bad_message::ReceivedBadMessage(render_process_id, | 3088 bad_message::ReceivedBadMessage(render_process_id, |
3063 bad_message::RPH_MOJO_PROCESS_ERROR); | 3089 bad_message::RPH_MOJO_PROCESS_ERROR); |
3064 } | 3090 } |
3065 | 3091 |
3066 } // namespace content | 3092 } // namespace content |
OLD | NEW |