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

Unified Diff: chrome/browser/memory/tab_manager.cc

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/BUILD.gn ('k') | components/memory_coordinator/browser/memory_coordinator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/memory/tab_manager.cc
diff --git a/chrome/browser/memory/tab_manager.cc b/chrome/browser/memory/tab_manager.cc
index 6fa39ad66f4abcae4e9a2b8fd9c2677945db888f..05c1825ee3f7523998eed4ee608bd1c38e651215 100644
--- a/chrome/browser/memory/tab_manager.cc
+++ b/chrome/browser/memory/tab_manager.cc
@@ -45,6 +45,7 @@
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
+#include "components/memory_coordinator/browser/memory_coordinator.h"
#include "components/metrics/system_memory_stats_recorder.h"
#include "components/variations/variations_associated_data.h"
#include "content/public/browser/browser_thread.h"
@@ -132,6 +133,14 @@ void NotifyRendererProcess(
render_process_host, level);
}
+void NotifyRendererUsingMemoryCoordinator(
+ const content::RenderProcessHost* render_process_host,
+ base::MemoryPressureListener::MemoryPressureLevel level) {
+ auto* coordinator = memory_coordinator::MemoryCoordinator::GetInstance();
+ DCHECK(coordinator);
+ coordinator->DispatchToRenderer(render_process_host->GetID(), level);
+}
+
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -155,6 +164,14 @@ TabManager::TabManager()
// testing seams.
get_current_pressure_level_ = base::Bind(&GetCurrentPressureLevel);
notify_renderer_process_ = base::Bind(&NotifyRendererProcess);
+ if (memory_coordinator::IsEnabled()) {
+ auto* coordinator = memory_coordinator::MemoryCoordinator::GetInstance();
+ DCHECK(coordinator);
+ coordinator->SetChildrenDispatchCallback(
+ base::Bind(&TabManager::OnMemoryPressure, base::Unretained(this)));
+ notify_renderer_process_ =
+ base::Bind(&NotifyRendererUsingMemoryCoordinator);
+ }
}
TabManager::~TabManager() {
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | components/memory_coordinator/browser/memory_coordinator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698