| Index: components/memory_coordinator/browser/memory_coordinator.h
|
| diff --git a/components/memory_coordinator/browser/memory_coordinator.h b/components/memory_coordinator/browser/memory_coordinator.h
|
| index d6871798d3a1a38fbc2824b5b6de7a364fb97337..e4ac37366d1cc836f417d1c9edae1efce0e87488 100644
|
| --- a/components/memory_coordinator/browser/memory_coordinator.h
|
| +++ b/components/memory_coordinator/browser/memory_coordinator.h
|
| @@ -7,6 +7,7 @@
|
|
|
| #include "base/memory/memory_pressure_monitor.h"
|
| #include "components/memory_coordinator/common/client_registry.h"
|
| +#include "components/memory_coordinator/common/memory_coordinator_features.h"
|
| #include "components/memory_coordinator/public/interfaces/memory_coordinator.mojom.h"
|
| #include "mojo/public/cpp/bindings/binding.h"
|
|
|
| @@ -19,17 +20,26 @@ class MemoryCoordinatorHandleImpl;
|
| // and child processes based on its best knowledge of the memory usage.
|
| class MemoryCoordinator : public ClientRegistry {
|
| public:
|
| + using DispatchCallback = base::MemoryPressureMonitor::DispatchCallback;
|
| +
|
| + static MemoryCoordinator* GetInstance();
|
| +
|
| MemoryCoordinator();
|
| ~MemoryCoordinator() override;
|
|
|
| void CreateHandle(int render_process_id,
|
| mojom::MemoryCoordinatorHandleRequest request);
|
|
|
| - const base::MemoryPressureMonitor::DispatchCallback&
|
| - pressure_level_dispatcher() {
|
| + const DispatchCallback& pressure_level_dispatcher() {
|
| return pressure_level_dispatcher_;
|
| }
|
|
|
| + void SetChildrenDispatchCallback(const DispatchCallback& callback);
|
| +
|
| + void DispatchToRenderer(
|
| + int render_process_id,
|
| + base::MemoryPressureMonitor::MemoryPressureLevel level);
|
| +
|
| // Returns number of children. Only used for testing.
|
| size_t NumChildrenForTesting();
|
|
|
| @@ -39,8 +49,17 @@ class MemoryCoordinator : public ClientRegistry {
|
| // Called when MemoryPressureMonitor detects memory pressure.
|
| void OnMemoryPressure(base::MemoryPressureMonitor::MemoryPressureLevel level);
|
|
|
| + // Default implementation of |children_dispatch_callback_|. Translates
|
| + // pressure level to memory state and sends it all renderers synchronously.
|
| + void DispatchMemoryPressureToChildren(
|
| + base::MemoryPressureMonitor::MemoryPressureLevel level);
|
| +
|
| // A callback invoked when MemoryPressureMonitor detects memory pressure.
|
| - base::MemoryPressureMonitor::DispatchCallback pressure_level_dispatcher_;
|
| + DispatchCallback pressure_level_dispatcher_;
|
| +
|
| + // A callback invoked in OnMemoryPressure() to dispatch memory pressure to
|
| + // child processes.
|
| + DispatchCallback children_dispatch_callback_;
|
|
|
| // Mappings of RenderProcessHost::GetID() -> MemoryCoordinatorHandleImpl.
|
| // A mapping is added when a renderer connects to MemoryCoordinator and
|
|
|