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

Unified Diff: content/browser/memory/memory_coordinator.cc

Issue 2376233005: [NotForReview] An idea for experimenting purge & suspend (Closed)
Patch Set: Created 4 years, 3 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
Index: content/browser/memory/memory_coordinator.cc
diff --git a/content/browser/memory/memory_coordinator.cc b/content/browser/memory/memory_coordinator.cc
index 52ee2ece71f8a47def79edd5401bd9c791680b49..098efddc4264d9f36c0f586622628293c3d066a1 100644
--- a/content/browser/memory/memory_coordinator.cc
+++ b/content/browser/memory/memory_coordinator.cc
@@ -34,11 +34,19 @@ class MemoryCoordinatorHandleImpl : public mojom::MemoryCoordinatorHandle {
};
// static
+bool MemoryCoordinator::IsEnabled() {
+ // TODO(tasak): Remove |kPurgeAndSuspend| when the experiment is done.
+ return base::FeatureList::IsEnabled(features::kMemoryCoordinator) ||
+ base::FeatureList::IsEnabled(features::kPurgeAndSuspend);
+}
+
+// static
MemoryCoordinator* MemoryCoordinator::GetInstance() {
- if (!base::FeatureList::IsEnabled(features::kMemoryCoordinator))
- return nullptr;
- return base::Singleton<MemoryCoordinator,
- base::LeakySingletonTraits<MemoryCoordinator>>::get();
+ if (IsEnabled()) {
+ return base::Singleton<MemoryCoordinator, base::LeakySingletonTraits<
+ MemoryCoordinator>>::get();
+ }
+ return nullptr;
}
MemoryCoordinator::MemoryCoordinator() {}
@@ -89,6 +97,11 @@ mojom::MemoryState MemoryCoordinator::GetMemoryState(
return iter->second.memory_state;
}
+bool MemoryCoordinator::PurgeAndSuspendChild(int render_process_id) {
+ DCHECK(base::FeatureList::IsEnabled(features::kPurgeAndSuspend));
+ return SetMemoryState(render_process_id, mojom::MemoryState::SUSPENDED);
+}
+
void MemoryCoordinator::AddChildForTesting(
int dummy_render_process_id, mojom::ChildMemoryCoordinatorPtr child) {
mojom::MemoryCoordinatorHandlePtr mch;
« no previous file with comments | « content/browser/memory/memory_coordinator.h ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698