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

Unified Diff: components/memory_coordinator/browser/memory_coordinator.h

Issue 2172893003: MC: WIP: dispatching notifications from browser to renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mc-4-dispatch-callback
Patch Set: Created 4 years, 5 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 | « chrome/browser/memory/tab_manager.cc ('k') | components/memory_coordinator/browser/memory_coordinator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/browser/memory/tab_manager.cc ('k') | components/memory_coordinator/browser/memory_coordinator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698