Index: content/browser/memory/memory_coordinator_default_policy.cc |
diff --git a/content/browser/memory/memory_coordinator_default_policy.cc b/content/browser/memory/memory_coordinator_default_policy.cc |
index 826a74dd0dbff151ae7ab8a0d57ef27294c10e30..0808dc0040b4bfc2007d9a1c258006b1bd48174c 100644 |
--- a/content/browser/memory/memory_coordinator_default_policy.cc |
+++ b/content/browser/memory/memory_coordinator_default_policy.cc |
@@ -6,18 +6,6 @@ |
namespace content { |
-namespace { |
- |
-const int kDefaultBackgroundChildPurgeCandidatePeriodSeconds = 30; |
- |
-MemoryState CalculateMemoryStateForProcess(MemoryCondition condition) { |
- if (condition == MemoryCondition::CRITICAL) |
- return MemoryState::THROTTLED; |
- return MemoryState::NORMAL; |
-} |
- |
-} // namespace |
- |
MemoryCoordinatorDefaultPolicy::MemoryCoordinatorDefaultPolicy( |
MemoryCoordinatorImpl* coordinator) |
: coordinator_(coordinator) { |
@@ -27,69 +15,15 @@ MemoryCoordinatorDefaultPolicy::MemoryCoordinatorDefaultPolicy( |
MemoryCoordinatorDefaultPolicy::~MemoryCoordinatorDefaultPolicy() {} |
void MemoryCoordinatorDefaultPolicy::OnCriticalCondition() { |
+ // Just trigger tab discarding for now. |
coordinator_->DiscardTab(); |
- |
- // Prefer to purge memory from child processes than browser process because |
- // we prioritize the brower process. |
- if (TryToPurgeMemoryFromChildren(PurgeTarget::ALL)) |
- return; |
- |
- coordinator_->TryToPurgeMemoryFromBrowser(); |
} |
void MemoryCoordinatorDefaultPolicy::OnConditionChanged(MemoryCondition prev, |
- MemoryCondition next) { |
- DCHECK(prev != next); |
- if (next == MemoryCondition::NORMAL) { |
- // Set NORMAL state to all clients/processes. |
- coordinator_->SetBrowserMemoryState(MemoryState::NORMAL); |
- SetMemoryStateToAllChildren(MemoryState::NORMAL); |
- } else if (next == MemoryCondition::CRITICAL) { |
- // Set THROTTLED state to all clients/processes. |
- coordinator_->SetBrowserMemoryState(MemoryState::THROTTLED); |
- SetMemoryStateToAllChildren(MemoryState::THROTTLED); |
- } |
-} |
+ MemoryCondition next) {} |
void MemoryCoordinatorDefaultPolicy::OnChildVisibilityChanged( |
int render_process_id, |
- bool is_visible) { |
- auto iter = coordinator_->children().find(render_process_id); |
- if (iter == coordinator_->children().end()) |
- return; |
- |
- iter->second.is_visible = is_visible; |
- if (!is_visible) { |
- // A backgrounded process becomes a candidate for purging memory when |
- // the process remains backgrounded for a certian period of time. |
- iter->second.can_purge_after = |
- coordinator_->NowTicks() + |
- base::TimeDelta::FromSeconds( |
- kDefaultBackgroundChildPurgeCandidatePeriodSeconds); |
- } |
- MemoryState new_state = |
- CalculateMemoryStateForProcess(coordinator_->GetMemoryCondition()); |
- coordinator_->SetChildMemoryState(render_process_id, new_state); |
-} |
- |
-void MemoryCoordinatorDefaultPolicy::SetMemoryStateToAllChildren( |
- MemoryState state) { |
- // It's OK to call SetChildMemoryState() unconditionally because it checks |
- // whether this state transition is valid. |
- for (auto& iter : coordinator_->children()) |
- coordinator_->SetChildMemoryState(iter.first, state); |
-} |
- |
-bool MemoryCoordinatorDefaultPolicy::TryToPurgeMemoryFromChildren( |
- PurgeTarget target) { |
- // TODO(bashi): Better to sort child processes based on their priorities. |
- for (auto& iter : coordinator_->children()) { |
- if (iter.second.is_visible && target == PurgeTarget::BACKGROUNDED) |
- continue; |
- if (coordinator_->TryToPurgeMemoryFromChild(iter.first)) |
- return true; |
- } |
- return false; |
-} |
+ bool is_visible) {} |
} // namespace content |