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

Unified Diff: content/renderer/render_thread_impl.cc

Issue 2456073003: Purge memory via MemoryCoordinatorClientRegistry when a backgrounded renderer is suspended. (Closed)
Patch Set: Add DCHECK Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/common/content_features.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_thread_impl.cc
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 7296ab1965a7c5116af4244b3ebf7c479521b458..31353ced34909229d5643af0e2ab281fb07936a4 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -847,6 +847,10 @@ void RenderThreadImpl::Init(
base::Unretained(this))));
if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) {
+ // Currently it is not possible to enable both PurgeAndSuspend and
+ // MemoryCoordinator at the same time.
+ DCHECK(!base::FeatureList::IsEnabled(features::kPurgeAndSuspend));
+
// Disable MemoryPressureListener when memory coordinator is enabled.
base::MemoryPressureListener::SetNotificationsSuppressed(true);
@@ -1756,6 +1760,12 @@ void RenderThreadImpl::OnProcessBackgrounded(bool backgrounded) {
renderer_scheduler_->OnRendererBackgrounded();
} else {
renderer_scheduler_->OnRendererForegrounded();
+ // TODO(tasak): after enabling MemoryCoordinator, remove this Notify
+ // and follow MemoryCoordinator's request.
+ if (base::FeatureList::IsEnabled(features::kPurgeAndSuspend))
+ base::MemoryCoordinatorClientRegistry::GetInstance()->Notify(
+ base::MemoryState::NORMAL);
+
record_purge_suspend_metric_closure_.Cancel();
record_purge_suspend_metric_closure_.Reset(
base::Bind(&RenderThreadImpl::RecordPurgeAndSuspendMetrics,
@@ -1766,11 +1776,17 @@ void RenderThreadImpl::OnProcessBackgrounded(bool backgrounded) {
void RenderThreadImpl::OnProcessPurgeAndSuspend() {
ChildThreadImpl::OnProcessPurgeAndSuspend();
- if (is_renderer_suspended_ || !RendererIsHidden())
+ DCHECK(!is_renderer_suspended_);
tasak 2016/10/28 06:31:33 This needs https://codereview.chromium.org/2462513
+ if (!RendererIsHidden())
return;
- // TODO(hajimehoshi): Implement purging e.g. cache (crbug/607077)
is_renderer_suspended_ = true;
- renderer_scheduler_->SuspendRenderer();
+ if (base::FeatureList::IsEnabled(features::kPurgeAndSuspend)) {
+ // TODO(tasak): After enabling MemoryCoordinator, remove this Notify
+ // and follow MemoryCoordinator's request.
+ base::MemoryCoordinatorClientRegistry::GetInstance()->Notify(
+ base::MemoryState::SUSPENDED);
+ renderer_scheduler_->SuspendRenderer();
+ }
// Since purging is not a synchronous task (e.g. v8 GC, oilpan GC, ...),
// we need to wait until the task is finished. So wait 15 seconds and
@@ -1882,7 +1898,13 @@ void RenderThreadImpl::OnProcessResume() {
DCHECK(is_renderer_suspended_);
is_renderer_suspended_ = false;
- renderer_scheduler_->ResumeRenderer();
+ if (base::FeatureList::IsEnabled(features::kPurgeAndSuspend)) {
+ // TODO(tasak): after enabling MemoryCoordinator, remove this Notify
+ // and follow MemoryCoordinator's request.
+ base::MemoryCoordinatorClientRegistry::GetInstance()->Notify(
+ base::MemoryState::NORMAL);
haraken 2016/10/28 07:49:41 I'm not sure if this should be NORMAL. It could be
chrisha 2016/11/01 21:24:38 Ditto. This seems fine for now.
+ renderer_scheduler_->ResumeRenderer();
+ }
}
scoped_refptr<gpu::GpuChannelHost> RenderThreadImpl::EstablishGpuChannelSync() {
« no previous file with comments | « content/public/common/content_features.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698