diff options
author | vollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-21 22:57:05 +0000 |
---|---|---|
committer | vollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-21 22:57:05 +0000 |
commit | fd33b59ffb2b597b9c6614f91456f93a23292f0f (patch) | |
tree | 25d71ff151d83880c9caf41653d056b602331fb4 /content/renderer/render_thread_impl.cc | |
parent | a14ddcdd5bb4f7b221275872d5cf4e9233bab7f4 (diff) | |
download | chromium_src-fd33b59ffb2b597b9c6614f91456f93a23292f0f.zip chromium_src-fd33b59ffb2b597b9c6614f91456f93a23292f0f.tar.gz chromium_src-fd33b59ffb2b597b9c6614f91456f93a23292f0f.tar.bz2 |
Apply artificial memory pressure when backgrounded.
In https://codereview.chromium.org/17106004/, I am adding discardable memory
emulation for platforms that do not support it natively. The emulation works by
listening for memory pressure notifications and purging memory in response.
But we don't yet provide memory pressure notifications on any platform other
than android.
In future, we'll periodically poll system memory usage, and send memory pressure
notifications as appropriate, but as a first step, we will artificially apply
memory pressure when tabs are backgrounded.
BUG=237681
Review URL: https://chromiumcodereview.appspot.com/17355004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207947 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/render_thread_impl.cc')
-rw-r--r-- | content/renderer/render_thread_impl.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index a91a9d9..795a92a 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -14,6 +14,7 @@ #include "base/debug/trace_event.h" #include "base/lazy_instance.h" #include "base/logging.h" +#include "base/memory/discardable_memory.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" #include "base/metrics/stats_table.h" @@ -71,6 +72,7 @@ #include "content/renderer/p2p/socket_dispatcher.h" #include "content/renderer/plugin_channel_host.h" #include "content/renderer/render_process_impl.h" +#include "content/renderer/render_process_visibility_manager.h" #include "content/renderer/render_view_impl.h" #include "content/renderer/renderer_webkitplatformsupport_impl.h" #include "content/renderer/skia_benchmarking_extension.h" @@ -597,6 +599,10 @@ void RenderThreadImpl::WidgetHidden() { DCHECK(hidden_widget_count_ < widget_count_); hidden_widget_count_++; + RenderProcessVisibilityManager* manager = + RenderProcessVisibilityManager::GetInstance(); + manager->WidgetVisibilityChanged(false); + if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { return; } @@ -608,6 +614,11 @@ void RenderThreadImpl::WidgetHidden() { void RenderThreadImpl::WidgetRestored() { DCHECK_GT(hidden_widget_count_, 0); hidden_widget_count_--; + + RenderProcessVisibilityManager* manager = + RenderProcessVisibilityManager::GetInstance(); + manager->WidgetVisibilityChanged(true); + if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { return; } |