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

Unified Diff: chrome/browser/sessions/tab_loader.h

Issue 2370753002: Make TabLoader a client of memory coordinator (Closed)
Patch Set: Use MemoryCoordinatorProxy Created 4 years, 2 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 | « no previous file | chrome/browser/sessions/tab_loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/tab_loader.h
diff --git a/chrome/browser/sessions/tab_loader.h b/chrome/browser/sessions/tab_loader.h
index 1ae274c7ef7f742e8bdae3ecffba8c12f726028f..a422931c9f46c624f15cd31704e614964c3e7f47 100644
--- a/chrome/browser/sessions/tab_loader.h
+++ b/chrome/browser/sessions/tab_loader.h
@@ -12,6 +12,7 @@
#include <set>
#include "base/macros.h"
+#include "base/memory/memory_coordinator_client.h"
#include "base/memory/memory_pressure_listener.h"
#include "base/timer/timer.h"
#include "chrome/browser/sessions/session_restore_delegate.h"
@@ -40,7 +41,8 @@ class SessionRestoreStatsCollector;
// of SessionRestoreImpl doesn't have timing problems.
class TabLoader : public content::NotificationObserver,
public base::RefCounted<TabLoader>,
- public TabLoaderCallback {
+ public TabLoaderCallback,
+ public base::MemoryCoordinatorClient {
public:
using RestoredTab = SessionRestoreDelegate::RestoredTab;
@@ -103,14 +105,20 @@ class TabLoader : public content::NotificationObserver,
// Called when a tab goes away or a load completes.
void HandleTabClosedOrLoaded(content::NavigationController* controller);
- // Convenience function returning the current memory pressure level.
- base::MemoryPressureListener::MemoryPressureLevel
- CurrentMemoryPressureLevel();
+ // Returns true when this is under memory pressure and required to purge
+ // memory by stopping loading tabs.
+ bool ShouldStopLoadingTabs() const;
// React to memory pressure by stopping to load any more tabs.
void OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
+ // base::MemoryCoordinatorClient implementation:
+ void OnMemoryStateChange(base::MemoryState state) override;
+
+ // Stops loading tabs to purge memory by stopping to load any more tabs.
+ void StopLoadingTabs();
+
std::unique_ptr<TabLoaderDelegate> delegate_;
// Listens for system under memory pressure notifications and stops loading
« no previous file with comments | « no previous file | chrome/browser/sessions/tab_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698