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..b415798177b4f442d2f9307fa8df467bcd576405 100644 |
--- a/content/browser/memory/memory_coordinator_impl.h |
+++ b/content/browser/memory/memory_coordinator_impl.h |
@@ -112,7 +112,7 @@ class CONTENT_EXPORT MemoryCoordinatorImpl : public base::MemoryCoordinator, |
void UpdateConditionIfNeeded(MemoryCondition condition); |
// Asks the delegate to discard a tab. |
- void DiscardTab(); |
+ bool DiscardTab(); |
protected: |
// Returns the RenderProcessHost which is correspond to the given id. |
@@ -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 regularly while the memory condition is WARNING. |
haraken
2017/03/24 11:55:39
periodically
bashi
2017/03/28 03:15:31
Done.
|
+ void OnWarningCondition(); |
+ |
+ // Called regularly while the memory condition is CRITICAL. |
haraken
2017/03/24 11:55:39
periodically
bashi
2017/03/28 03:15:31
Done.
|
+ 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 TryPurgeMemoryFromChildren(PurgeTarget target); |
haraken
2017/03/24 11:55:39
TryTo
bashi
2017/03/28 03:15:31
Done.
|
+ |
+ // Tries to purge memory from the browser process. |
+ bool TryPurgeMemoryFromBrowser(); |
haraken
2017/03/24 11:55:39
TryTo
bashi
2017/03/28 03:15:31
Done.
|
+ |
scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
std::unique_ptr<MemoryCoordinatorDelegate> delegate_; |
std::unique_ptr<MemoryMonitor> memory_monitor_; |
@@ -226,6 +247,14 @@ 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_; |
+ |
+ // When a child process remains backgrounded for this TimeDelta, the process |
+ // becomes a candidate for purging memory on WARNING condition. |
+ base::TimeDelta background_child_purge_candidate_period_; |
+ |
// Tracks child processes. An entry is added when a renderer connects to |
// MemoryCoordinator and removed automatically when an underlying binding is |
// disconnected. |