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

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 1914143002: Experimental 'purging and suspending' backgrounded tabs behind the flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address on haraken's review Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/test/fake_renderer_scheduler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "content/renderer/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 // We may not have a MojoShellConnection object in tests that directly 815 // We may not have a MojoShellConnection object in tests that directly
816 // instantiate a RenderThreadImpl. 816 // instantiate a RenderThreadImpl.
817 if (MojoShellConnection::Get() && 817 if (MojoShellConnection::Get() &&
818 base::CommandLine::ForCurrentProcess()->HasSwitch( 818 base::CommandLine::ForCurrentProcess()->HasSwitch(
819 switches::kUseMusInRenderer)) 819 switches::kUseMusInRenderer))
820 CreateRenderWidgetWindowTreeClientFactory(); 820 CreateRenderWidgetWindowTreeClientFactory();
821 #endif 821 #endif
822 822
823 service_registry()->ConnectToRemoteService( 823 service_registry()->ConnectToRemoteService(
824 mojo::GetProxy(&storage_partition_service_)); 824 mojo::GetProxy(&storage_partition_service_));
825
826 is_renderer_suspended_ = false;
825 } 827 }
826 828
827 RenderThreadImpl::~RenderThreadImpl() { 829 RenderThreadImpl::~RenderThreadImpl() {
828 } 830 }
829 831
830 void RenderThreadImpl::Shutdown() { 832 void RenderThreadImpl::Shutdown() {
831 FOR_EACH_OBSERVER( 833 FOR_EACH_OBSERVER(
832 RenderThreadObserver, observers_, OnRenderProcessShutdown()); 834 RenderThreadObserver, observers_, OnRenderProcessShutdown());
833 835
834 if (memory_observer_) { 836 if (memory_observer_) {
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache) 1702 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache)
1701 #endif 1703 #endif
1702 IPC_MESSAGE_UNHANDLED(handled = false) 1704 IPC_MESSAGE_UNHANDLED(handled = false)
1703 IPC_END_MESSAGE_MAP() 1705 IPC_END_MESSAGE_MAP()
1704 return handled; 1706 return handled;
1705 } 1707 }
1706 1708
1707 void RenderThreadImpl::OnProcessBackgrounded(bool backgrounded) { 1709 void RenderThreadImpl::OnProcessBackgrounded(bool backgrounded) {
1708 ChildThreadImpl::OnProcessBackgrounded(backgrounded); 1710 ChildThreadImpl::OnProcessBackgrounded(backgrounded);
1709 1711
1710 if (backgrounded) 1712 if (backgrounded) {
1711 renderer_scheduler_->OnRendererBackgrounded(); 1713 renderer_scheduler_->OnRendererBackgrounded();
1712 else 1714 } else {
1713 renderer_scheduler_->OnRendererForegrounded(); 1715 renderer_scheduler_->OnRendererForegrounded();
1716 is_renderer_suspended_ = false;
1717 }
1718 }
1719
1720 void RenderThreadImpl::OnProcessPurgeAndSuspend() {
1721 ChildThreadImpl::OnProcessPurgeAndSuspend();
1722 if (is_renderer_suspended_)
1723 return;
1724 // TODO(hajimehoshi): Implement purging e.g. cache (crbug/607077)
1725 is_renderer_suspended_ = true;
1726 renderer_scheduler_->SuspendRenderer();
1714 } 1727 }
1715 1728
1716 void RenderThreadImpl::OnCreateNewFrame(FrameMsg_NewFrame_Params params) { 1729 void RenderThreadImpl::OnCreateNewFrame(FrameMsg_NewFrame_Params params) {
1717 CompositorDependencies* compositor_deps = this; 1730 CompositorDependencies* compositor_deps = this;
1718 RenderFrameImpl::CreateFrame( 1731 RenderFrameImpl::CreateFrame(
1719 params.routing_id, params.proxy_routing_id, params.opener_routing_id, 1732 params.routing_id, params.proxy_routing_id, params.opener_routing_id,
1720 params.parent_routing_id, params.previous_sibling_routing_id, 1733 params.parent_routing_id, params.previous_sibling_routing_id,
1721 params.replication_state, compositor_deps, params.widget_params, 1734 params.replication_state, compositor_deps, params.widget_params,
1722 params.frame_owner_properties); 1735 params.frame_owner_properties);
1723 } 1736 }
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) 2103 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical)
2091 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; 2104 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate;
2092 2105
2093 blink::mainThreadIsolate()->MemoryPressureNotification( 2106 blink::mainThreadIsolate()->MemoryPressureNotification(
2094 v8_memory_pressure_level); 2107 v8_memory_pressure_level);
2095 blink::MemoryPressureNotificationToWorkerThreadIsolates( 2108 blink::MemoryPressureNotificationToWorkerThreadIsolates(
2096 v8_memory_pressure_level); 2109 v8_memory_pressure_level);
2097 } 2110 }
2098 2111
2099 } // namespace content 2112 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/test/fake_renderer_scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698