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 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
816 #endif | 816 #endif |
817 | 817 |
818 memory_pressure_listener_.reset(new base::MemoryPressureListener( | 818 memory_pressure_listener_.reset(new base::MemoryPressureListener( |
819 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)), | 819 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)), |
820 base::Bind(&RenderThreadImpl::OnSyncMemoryPressure, | 820 base::Bind(&RenderThreadImpl::OnSyncMemoryPressure, |
821 base::Unretained(this)))); | 821 base::Unretained(this)))); |
822 | 822 |
823 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) { | 823 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) { |
824 // Currently it is not possible to enable both PurgeAndSuspend and | 824 // Currently it is not possible to enable both PurgeAndSuspend and |
825 // MemoryCoordinator at the same time. | 825 // MemoryCoordinator at the same time. |
826 DCHECK(!base::FeatureList::IsEnabled(features::kPurgeAndSuspend)); | 826 DCHECK(!base::FeatureList::IsEnabled(features::kPurgeAndSuspend)); |
Wez
2017/02/15 21:41:03
We have both MemoryCoordinator and PurgeAndSuspend
| |
827 | 827 |
828 // Disable MemoryPressureListener when memory coordinator is enabled. | 828 // Disable MemoryPressureListener when memory coordinator is enabled. |
829 base::MemoryPressureListener::SetNotificationsSuppressed(true); | 829 base::MemoryPressureListener::SetNotificationsSuppressed(true); |
830 | 830 |
831 // TODO(bashi): Revisit how to manage the lifetime of | 831 // TODO(bashi): Revisit how to manage the lifetime of |
832 // ChildMemoryCoordinatorImpl. | 832 // ChildMemoryCoordinatorImpl. |
833 // https://codereview.chromium.org/2094583002/#msg52 | 833 // https://codereview.chromium.org/2094583002/#msg52 |
834 mojom::MemoryCoordinatorHandlePtr parent_coordinator; | 834 mojom::MemoryCoordinatorHandlePtr parent_coordinator; |
835 GetRemoteInterfaces()->GetInterface(mojo::MakeRequest(&parent_coordinator)); | 835 GetRemoteInterfaces()->GetInterface(mojo::MakeRequest(&parent_coordinator)); |
836 memory_coordinator_ = CreateChildMemoryCoordinator( | 836 memory_coordinator_ = CreateChildMemoryCoordinator( |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1663 void RenderThreadImpl::OnProcessPurgeAndSuspend() { | 1663 void RenderThreadImpl::OnProcessPurgeAndSuspend() { |
1664 ChildThreadImpl::OnProcessPurgeAndSuspend(); | 1664 ChildThreadImpl::OnProcessPurgeAndSuspend(); |
1665 if (!RendererIsHidden()) | 1665 if (!RendererIsHidden()) |
1666 return; | 1666 return; |
1667 | 1667 |
1668 // TODO(bashi): Enable the tab suspension when MemoryCoordinator is enabled. | 1668 // TODO(bashi): Enable the tab suspension when MemoryCoordinator is enabled. |
1669 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) | 1669 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) |
1670 return; | 1670 return; |
1671 | 1671 |
1672 if (base::FeatureList::IsEnabled(features::kPurgeAndSuspend)) { | 1672 if (base::FeatureList::IsEnabled(features::kPurgeAndSuspend)) { |
1673 // TODO(tasak): After enabling MemoryCoordinator, remove this Notify | 1673 memory_coordinator_->PurgeMemory(); |
Wez
2017/02/15 19:51:58
Isn't |memory_coordinator_| only initialized if Me
| |
1674 // and follow MemoryCoordinator's request. | |
1675 base::MemoryCoordinatorClientRegistry::GetInstance()->Notify( | |
1676 base::MemoryState::SUSPENDED); | |
1677 } | 1674 } |
1678 // Since purging is not a synchronous task (e.g. v8 GC, oilpan GC, ...), | 1675 // Since purging is not a synchronous task (e.g. v8 GC, oilpan GC, ...), |
1679 // we need to wait until the task is finished. So wait 15 seconds and | 1676 // we need to wait until the task is finished. So wait 15 seconds and |
1680 // update purge+suspend UMA histogram. | 1677 // update purge+suspend UMA histogram. |
1681 // TODO(tasak): use MemoryCoordinator's callback to report purge+suspend | 1678 // TODO(tasak): use MemoryCoordinator's callback to report purge+suspend |
1682 // UMA when MemoryCoordinator is available. | 1679 // UMA when MemoryCoordinator is available. |
1683 GetRendererScheduler()->DefaultTaskRunner()->PostDelayedTask( | 1680 GetRendererScheduler()->DefaultTaskRunner()->PostDelayedTask( |
1684 FROM_HERE, record_purge_suspend_metric_closure_.callback(), | 1681 FROM_HERE, record_purge_suspend_metric_closure_.callback(), |
1685 base::TimeDelta::FromSeconds(15)); | 1682 base::TimeDelta::FromSeconds(15)); |
1686 } | 1683 } |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2440 } | 2437 } |
2441 } | 2438 } |
2442 | 2439 |
2443 void RenderThreadImpl::OnRendererInterfaceRequest( | 2440 void RenderThreadImpl::OnRendererInterfaceRequest( |
2444 mojom::RendererAssociatedRequest request) { | 2441 mojom::RendererAssociatedRequest request) { |
2445 DCHECK(!renderer_binding_.is_bound()); | 2442 DCHECK(!renderer_binding_.is_bound()); |
2446 renderer_binding_.Bind(std::move(request)); | 2443 renderer_binding_.Bind(std::move(request)); |
2447 } | 2444 } |
2448 | 2445 |
2449 } // namespace content | 2446 } // namespace content |
OLD | NEW |