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

Unified Diff: content/renderer/render_thread_impl.cc

Issue 2456073003: Purge memory via MemoryCoordinatorClientRegistry when a backgrounded renderer is suspended. (Closed)
Patch Set: 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..531e31bcff7a9b05244fd4d569bea0eb6d97cfff 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -846,7 +846,8 @@ void RenderThreadImpl::Init(
base::Bind(&RenderThreadImpl::OnSyncMemoryPressure,
base::Unretained(this))));
- if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) {
+ if (base::FeatureList::IsEnabled(features::kMemoryCoordinator) ||
+ base::FeatureList::IsEnabled(features::kPurgeAndSuspend)) {
bashi 2016/10/28 05:45:05 Let's discuss offline how to enable MemoryCoordina
tasak 2016/10/28 06:29:34 According to the discussion, I removed base::Featu
// Disable MemoryPressureListener when memory coordinator is enabled.
base::MemoryPressureListener::SetNotificationsSuppressed(true);
@@ -1756,6 +1757,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 +1773,17 @@ void RenderThreadImpl::OnProcessBackgrounded(bool backgrounded) {
void RenderThreadImpl::OnProcessPurgeAndSuspend() {
ChildThreadImpl::OnProcessPurgeAndSuspend();
- if (is_renderer_suspended_ || !RendererIsHidden())
+ DCHECK(!is_renderer_suspended_);
+ 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 +1895,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);
+ 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