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

Unified Diff: content/browser/memory/memory_coordinator_impl.h

Issue 2763933002: memory coordinator: Purge memory under memory pressure (Closed)
Patch Set: comments Created 3 years, 9 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
Index: content/browser/memory/memory_coordinator_impl.h
diff --git a/content/browser/memory/memory_coordinator_impl.h b/content/browser/memory/memory_coordinator_impl.h
index 6659c1d0c49211f06529b6599403a7690efec7a1..c7c5052999fec55c8e9dba163f97f0a37d8b86ef 100644
--- a/content/browser/memory/memory_coordinator_impl.h
+++ b/content/browser/memory/memory_coordinator_impl.h
@@ -150,6 +150,7 @@ class CONTENT_EXPORT MemoryCoordinatorImpl : public base::MemoryCoordinator,
MemoryState memory_state;
bool is_visible = false;
+ base::TimeTicks can_purge_after;
std::unique_ptr<MemoryCoordinatorHandleImpl> handle;
};
@@ -174,6 +175,8 @@ class CONTENT_EXPORT MemoryCoordinatorImpl : public base::MemoryCoordinator,
FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, SetMemoryStateForTesting);
FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, ForceSetMemoryCondition);
FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, DiscardTabUnderCritical);
+ FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, OnWarningCondition);
+ FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, OnCriticalCondition);
friend struct MemoryCoordinatorSingletonTraits;
friend class MemoryCoordinatorHandleImpl;
@@ -202,6 +205,24 @@ class CONTENT_EXPORT MemoryCoordinatorImpl : public base::MemoryCoordinator,
// Notifies a state change to child processes.
void NotifyStateToChildren(MemoryState state);
+ // Called periodically while the memory condition is WARNING.
+ void OnWarningCondition();
+
+ // Called periodically while the memory condition is CRITICAL.
+ void OnCriticalCondition();
+
+ enum class PurgeTarget {
+ BACKGROUNDED,
+ ALL,
+ };
+
+ // Tries to find a candidate child process for purging memory and asks the
+ // child to purge memory.
+ bool TryToPurgeMemoryFromChildren(PurgeTarget target);
+
+ // Tries to purge memory from the browser process.
+ bool TryToPurgeMemoryFromBrowser();
+
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
std::unique_ptr<MemoryCoordinatorDelegate> delegate_;
std::unique_ptr<MemoryMonitor> memory_monitor_;
@@ -226,6 +247,10 @@ class CONTENT_EXPORT MemoryCoordinatorImpl : public base::MemoryCoordinator,
// multiple tasks in the same time frame.
base::CancelableClosure delayed_browser_memory_state_setter_;
+ // If this isn't null, purging memory from the browser process is suppressed
+ // until this ticks is passed.
+ base::TimeTicks can_purge_after_;
+
// Tracks child processes. An entry is added when a renderer connects to
// MemoryCoordinator and removed automatically when an underlying binding is
// disconnected.
« no previous file with comments | « content/browser/memory/memory_condition_observer.cc ('k') | content/browser/memory/memory_coordinator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698