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, |