Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 804 // We may not have a MojoShellConnection object in tests that directly | 804 // We may not have a MojoShellConnection object in tests that directly |
| 805 // instantiate a RenderThreadImpl. | 805 // instantiate a RenderThreadImpl. |
| 806 if (MojoShellConnection::Get() && | 806 if (MojoShellConnection::Get() && |
| 807 base::CommandLine::ForCurrentProcess()->HasSwitch( | 807 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 808 switches::kUseMusInRenderer)) | 808 switches::kUseMusInRenderer)) |
| 809 CreateRenderWidgetWindowTreeClientFactory(); | 809 CreateRenderWidgetWindowTreeClientFactory(); |
| 810 #endif | 810 #endif |
| 811 | 811 |
| 812 service_registry()->ConnectToRemoteService( | 812 service_registry()->ConnectToRemoteService( |
| 813 mojo::GetProxy(&storage_partition_service_)); | 813 mojo::GetProxy(&storage_partition_service_)); |
| 814 | |
| 815 is_cache_purged_ = false; | |
| 814 } | 816 } |
| 815 | 817 |
| 816 RenderThreadImpl::~RenderThreadImpl() { | 818 RenderThreadImpl::~RenderThreadImpl() { |
| 817 } | 819 } |
| 818 | 820 |
| 819 void RenderThreadImpl::Shutdown() { | 821 void RenderThreadImpl::Shutdown() { |
| 820 FOR_EACH_OBSERVER( | 822 FOR_EACH_OBSERVER( |
| 821 RenderThreadObserver, observers_, OnRenderProcessShutdown()); | 823 RenderThreadObserver, observers_, OnRenderProcessShutdown()); |
| 822 | 824 |
| 823 if (memory_observer_) { | 825 if (memory_observer_) { |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1672 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache) | 1674 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache) |
| 1673 #endif | 1675 #endif |
| 1674 IPC_MESSAGE_UNHANDLED(handled = false) | 1676 IPC_MESSAGE_UNHANDLED(handled = false) |
| 1675 IPC_END_MESSAGE_MAP() | 1677 IPC_END_MESSAGE_MAP() |
| 1676 return handled; | 1678 return handled; |
| 1677 } | 1679 } |
| 1678 | 1680 |
| 1679 void RenderThreadImpl::OnProcessBackgrounded(bool backgrounded) { | 1681 void RenderThreadImpl::OnProcessBackgrounded(bool backgrounded) { |
| 1680 ChildThreadImpl::OnProcessBackgrounded(backgrounded); | 1682 ChildThreadImpl::OnProcessBackgrounded(backgrounded); |
| 1681 | 1683 |
| 1682 if (backgrounded) | 1684 if (backgrounded) { |
| 1683 renderer_scheduler_->OnRendererBackgrounded(); | 1685 renderer_scheduler_->OnRendererBackgrounded(); |
| 1684 else | 1686 } else { |
| 1685 renderer_scheduler_->OnRendererForegrounded(); | 1687 renderer_scheduler_->OnRendererForegrounded(); |
| 1688 is_cache_purged_ = false; | |
| 1689 } | |
| 1690 } | |
| 1691 | |
| 1692 void RenderThreadImpl::OnProcessPurgeAndSuspend() { | |
| 1693 ChildThreadImpl::OnProcessPurgeAndSuspend(); | |
| 1694 if (is_cache_purged_) | |
| 1695 return; | |
| 1696 // TODO(hajimehoshi): Implement purging e.g. cache (crbug/607077) | |
| 1697 is_cache_purged_ = true; | |
| 1698 renderer_scheduler_->SuspendRendererWhenBackgrounded(); | |
|
dcheng
2016/05/10 16:28:06
Will we ever send a "purge and suspend" to a non-b
hajimehoshi
2016/05/11 07:23:31
Good point. Done by adding |is_backgrounded_|.
| |
| 1686 } | 1699 } |
| 1687 | 1700 |
| 1688 void RenderThreadImpl::OnCreateNewFrame(FrameMsg_NewFrame_Params params) { | 1701 void RenderThreadImpl::OnCreateNewFrame(FrameMsg_NewFrame_Params params) { |
| 1689 CompositorDependencies* compositor_deps = this; | 1702 CompositorDependencies* compositor_deps = this; |
| 1690 RenderFrameImpl::CreateFrame( | 1703 RenderFrameImpl::CreateFrame( |
| 1691 params.routing_id, params.proxy_routing_id, params.opener_routing_id, | 1704 params.routing_id, params.proxy_routing_id, params.opener_routing_id, |
| 1692 params.parent_routing_id, params.previous_sibling_routing_id, | 1705 params.parent_routing_id, params.previous_sibling_routing_id, |
| 1693 params.replication_state, compositor_deps, params.widget_params, | 1706 params.replication_state, compositor_deps, params.widget_params, |
| 1694 params.frame_owner_properties); | 1707 params.frame_owner_properties); |
| 1695 } | 1708 } |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2046 } | 2059 } |
| 2047 | 2060 |
| 2048 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 2061 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
| 2049 size_t erased = | 2062 size_t erased = |
| 2050 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 2063 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
| 2051 routing_id_); | 2064 routing_id_); |
| 2052 DCHECK_EQ(1u, erased); | 2065 DCHECK_EQ(1u, erased); |
| 2053 } | 2066 } |
| 2054 | 2067 |
| 2055 } // namespace content | 2068 } // namespace content |
| OLD | NEW |