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

Unified Diff: content/child/memory/child_memory_coordinator_impl.cc

Issue 2731913002: NotForReview: Expose the global memory budget (chromium side)
Patch Set: Add --simulate-memory-pressure Created 3 years, 9 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
« no previous file with comments | « content/child/memory/child_memory_coordinator_impl.h ('k') | content/common/memory_coordinator.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/memory/child_memory_coordinator_impl.cc
diff --git a/content/child/memory/child_memory_coordinator_impl.cc b/content/child/memory/child_memory_coordinator_impl.cc
index 6616a22e1b7d320a2aeb5339914c886f8b7eae54..3100962a1629c6cb9aea530b3d3418c7ec1441b3 100644
--- a/content/child/memory/child_memory_coordinator_impl.cc
+++ b/content/child/memory/child_memory_coordinator_impl.cc
@@ -50,6 +50,9 @@ ChildMemoryCoordinatorImpl::ChildMemoryCoordinatorImpl(
DCHECK(!g_child_memory_coordinator);
g_child_memory_coordinator = this;
parent_->AddChild(binding_.CreateInterfacePtrAndBind());
+ parent_->GetGlobalBudgetHandle(
+ base::Bind(&ChildMemoryCoordinatorImpl::OnGetGlobalBudgetHandle,
+ base::Unretained(this)));
base::MemoryCoordinatorProxy::SetMemoryCoordinator(this);
}
@@ -63,6 +66,17 @@ base::MemoryState ChildMemoryCoordinatorImpl::GetCurrentMemoryState() const {
return current_state_;
}
+int64_t ChildMemoryCoordinatorImpl::GetGlobalBudget() {
+ if (!global_budget_handle_.is_valid())
+ return -1;
+ return *reinterpret_cast<int64_t*>(global_budget_mapping_.get());
+}
+
+void ChildMemoryCoordinatorImpl::SetGlobalBudgetUpdateInterval(
+ uint32_t interval_ms) {
+ parent_->SetGlobalBudgetUpdateInterval(interval_ms);
+}
+
void ChildMemoryCoordinatorImpl::PurgeMemory() {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("memory-infra"),
"ChildMemoryCoordinatorImpl::PurgeMemory");
@@ -77,6 +91,13 @@ void ChildMemoryCoordinatorImpl::OnStateChange(mojom::MemoryState state) {
base::MemoryCoordinatorClientRegistry::GetInstance()->Notify(current_state_);
}
+void ChildMemoryCoordinatorImpl::OnGetGlobalBudgetHandle(
+ mojo::ScopedSharedBufferHandle handle) {
+ global_budget_handle_ = std::move(handle);
+ global_budget_mapping_ = global_budget_handle_->Map(sizeof(int64_t));
+ DCHECK(global_budget_mapping_.get());
+}
+
#if !defined(OS_ANDROID)
std::unique_ptr<ChildMemoryCoordinatorImpl> CreateChildMemoryCoordinator(
mojom::MemoryCoordinatorHandlePtr parent,
« no previous file with comments | « content/child/memory/child_memory_coordinator_impl.h ('k') | content/common/memory_coordinator.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698