Chromium Code Reviews| 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 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1565 if (visible_widgets_ == 0) { | 1565 if (visible_widgets_ == 0) { |
| 1566 DCHECK(!is_process_backgrounded_); | 1566 DCHECK(!is_process_backgrounded_); |
| 1567 UpdateProcessPriority(); | 1567 UpdateProcessPriority(); |
| 1568 } | 1568 } |
| 1569 } | 1569 } |
| 1570 | 1570 |
| 1571 int RenderProcessHostImpl::VisibleWidgetCount() const { | 1571 int RenderProcessHostImpl::VisibleWidgetCount() const { |
| 1572 return visible_widgets_; | 1572 return visible_widgets_; |
| 1573 } | 1573 } |
| 1574 | 1574 |
| 1575 void RenderProcessHostImpl::AudioStateChanged() { | 1575 void RenderProcessHostImpl::OnAudioStreamAdded() { |
| 1576 ++audio_stream_count_; | |
| 1576 UpdateProcessPriority(); | 1577 UpdateProcessPriority(); |
| 1577 } | 1578 } |
| 1578 | 1579 |
| 1580 void RenderProcessHostImpl::OnAudioStreamRemoved() { | |
| 1581 --audio_stream_count_; | |
|
o1ka
2017/02/07 09:38:02
DCHECK(audio_stream_count_ > 0)?
DaleCurtis
2017/02/07 22:09:16
Done.
| |
| 1582 UpdateProcessPriority(); | |
| 1583 } | |
| 1584 | |
| 1579 bool RenderProcessHostImpl::IsForGuestsOnly() const { | 1585 bool RenderProcessHostImpl::IsForGuestsOnly() const { |
| 1580 return is_for_guests_only_; | 1586 return is_for_guests_only_; |
| 1581 } | 1587 } |
| 1582 | 1588 |
| 1583 StoragePartition* RenderProcessHostImpl::GetStoragePartition() const { | 1589 StoragePartition* RenderProcessHostImpl::GetStoragePartition() const { |
| 1584 return storage_partition_impl_; | 1590 return storage_partition_impl_; |
| 1585 } | 1591 } |
| 1586 | 1592 |
| 1587 static void AppendCompositorCommandLineFlags(base::CommandLine* command_line) { | 1593 static void AppendCompositorCommandLineFlags(base::CommandLine* command_line) { |
| 1588 command_line->AppendSwitchASCII( | 1594 command_line->AppendSwitchASCII( |
| (...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2824 | 2830 |
| 2825 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2831 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 2826 switches::kDisableRendererPriorityManagement)) { | 2832 switches::kDisableRendererPriorityManagement)) { |
| 2827 return; | 2833 return; |
| 2828 } | 2834 } |
| 2829 | 2835 |
| 2830 // We background a process as soon as it hosts no active audio streams and no | 2836 // We background a process as soon as it hosts no active audio streams and no |
| 2831 // visible widgets -- the callers must call this function whenever we | 2837 // visible widgets -- the callers must call this function whenever we |
| 2832 // transition in/out of those states. | 2838 // transition in/out of those states. |
| 2833 const bool should_background = | 2839 const bool should_background = |
| 2834 visible_widgets_ == 0 && !audio_renderer_host_->HasActiveAudio() && | 2840 visible_widgets_ == 0 && audio_stream_count_ == 0 && |
| 2835 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 2841 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 2836 switches::kDisableRendererBackgrounding); | 2842 switches::kDisableRendererBackgrounding); |
| 2837 | 2843 |
| 2838 // TODO(sebsg): Remove this ifdef when https://crbug.com/537671 is fixed. | 2844 // TODO(sebsg): Remove this ifdef when https://crbug.com/537671 is fixed. |
| 2839 #if !defined(OS_ANDROID) | 2845 #if !defined(OS_ANDROID) |
| 2840 if (is_process_backgrounded_ == should_background) | 2846 if (is_process_backgrounded_ == should_background) |
| 2841 return; | 2847 return; |
| 2842 #endif | 2848 #endif |
| 2843 | 2849 |
| 2844 TRACE_EVENT1("renderer_host", "RenderProcessHostImpl::UpdateProcessPriority", | 2850 TRACE_EVENT1("renderer_host", "RenderProcessHostImpl::UpdateProcessPriority", |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3073 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3079 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 3074 | 3080 |
| 3075 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3081 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
| 3076 // Capture the error message in a crash key value. | 3082 // Capture the error message in a crash key value. |
| 3077 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3083 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
| 3078 bad_message::ReceivedBadMessage(render_process_id, | 3084 bad_message::ReceivedBadMessage(render_process_id, |
| 3079 bad_message::RPH_MOJO_PROCESS_ERROR); | 3085 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 3080 } | 3086 } |
| 3081 | 3087 |
| 3082 } // namespace content | 3088 } // namespace content |
| OLD | NEW |