Chromium Code Reviews| Index: content/browser/memory/memory_coordinator.cc |
| diff --git a/content/browser/memory/memory_coordinator.cc b/content/browser/memory/memory_coordinator.cc |
| index 52ee2ece71f8a47def79edd5401bd9c791680b49..a0d4481f3873c75d06ed09c22d8e819e2af9a32c 100644 |
| --- a/content/browser/memory/memory_coordinator.cc |
| +++ b/content/browser/memory/memory_coordinator.cc |
| @@ -9,6 +9,14 @@ |
| namespace content { |
| +// static |
| +void MemoryCoordinatorDelegate::Set( |
| + const base::WeakPtr<MemoryCoordinatorDelegate>& delegate) { |
| + auto* coordinator = MemoryCoordinator::GetInstance(); |
| + if (coordinator) |
| + coordinator->SetDelegate(delegate); |
| +} |
| + |
| // The implementation of MemoryCoordinatorHandle. See memory_coordinator.mojom |
| // for the role of this class. |
| class MemoryCoordinatorHandleImpl : public mojom::MemoryCoordinatorHandle { |
| @@ -75,6 +83,11 @@ bool MemoryCoordinator::SetMemoryState(int render_process_id, |
| if (iter->second.memory_state == memory_state) |
| return true; |
| + // Can't suspend the given renderer. |
| + if (iter->second.memory_state == mojom::MemoryState::SUSPENDED && |
|
haraken
2016/10/07 06:38:19
Shouldn't this be:
if (memory_state == mojom::M
bashi
2016/10/07 07:13:37
Yes. Thanks. Done.
|
| + !CanSuspendRenderer(render_process_id)) |
| + return false; |
| + |
| // Update the internal state and send the message. |
| iter->second.memory_state = memory_state; |
| iter->second.handle->child()->OnStateChange(memory_state); |
| @@ -103,6 +116,10 @@ void MemoryCoordinator::OnConnectionError(int render_process_id) { |
| children_.erase(render_process_id); |
| } |
| +bool MemoryCoordinator::CanSuspendRenderer(int render_process_id) { |
| + return delegate_ && delegate_->CanSuspendRenderer(render_process_id); |
| +} |
| + |
| void MemoryCoordinator::CreateChildInfoMapEntry( |
| int render_process_id, |
| std::unique_ptr<MemoryCoordinatorHandleImpl> handle) { |