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

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

Issue 2590773002: Add a public interface for content::MemoryCoordinator (Closed)
Patch Set: rebase Created 4 years 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_impl.cc
diff --git a/content/browser/memory/memory_coordinator_impl.cc b/content/browser/memory/memory_coordinator_impl.cc
index 0ed6859c49a819d8a97f8dcd63450f82a72bcb38..ec2bc2048031624902e40416d40ca4b2b991ea49 100644
--- a/content/browser/memory/memory_coordinator_impl.cc
+++ b/content/browser/memory/memory_coordinator_impl.cc
@@ -154,6 +154,11 @@ struct MemoryCoordinatorImplSingletonTraits
};
// static
+MemoryCoordinator* MemoryCoordinator::GetInstance() {
+ return MemoryCoordinatorImpl::GetInstance();
+}
+
+// static
MemoryCoordinatorImpl* MemoryCoordinatorImpl::GetInstance() {
if (!base::FeatureList::IsEnabled(features::kMemoryCoordinator))
return nullptr;
@@ -297,6 +302,22 @@ void MemoryCoordinatorImpl::Observe(int type,
SetChildMemoryState(iter->first, new_state);
}
+base::MemoryState MemoryCoordinatorImpl::GetStateForProcess(
+ base::ProcessHandle handle) {
+ DCHECK(CalledOnValidThread());
+ if (handle == base::kNullProcessHandle)
+ return MemoryState::UNKNOWN;
+ if (handle == base::GetCurrentProcessHandle())
+ return GetCurrentMemoryState();
+
+ for (auto& iter : children()) {
+ auto* render_process_host = GetRenderProcessHost(iter.first);
+ if (render_process_host && render_process_host->GetHandle() == handle)
+ return iter.second.memory_state;
+ }
+ return MemoryState::UNKNOWN;
+}
+
bool MemoryCoordinatorImpl::ChangeStateIfNeeded(base::MemoryState prev_state,
base::MemoryState next_state) {
DCHECK(CalledOnValidThread());
« no previous file with comments | « content/browser/memory/memory_coordinator_impl.h ('k') | content/browser/memory/memory_coordinator_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698