| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/child/memory/child_memory_coordinator_impl.h" | 5 #include "content/child/memory/child_memory_coordinator_impl.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/memory/memory_coordinator_client_registry.h" | 8 #include "base/memory/memory_coordinator_client_registry.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 g_child_memory_coordinator = this; | 51 g_child_memory_coordinator = this; |
| 52 parent_->AddChild(binding_.CreateInterfacePtrAndBind()); | 52 parent_->AddChild(binding_.CreateInterfacePtrAndBind()); |
| 53 } | 53 } |
| 54 | 54 |
| 55 ChildMemoryCoordinatorImpl::~ChildMemoryCoordinatorImpl() { | 55 ChildMemoryCoordinatorImpl::~ChildMemoryCoordinatorImpl() { |
| 56 base::AutoLock lock(*g_lock.Pointer()); | 56 base::AutoLock lock(*g_lock.Pointer()); |
| 57 DCHECK(g_child_memory_coordinator == this); | 57 DCHECK(g_child_memory_coordinator == this); |
| 58 g_child_memory_coordinator = nullptr; | 58 g_child_memory_coordinator = nullptr; |
| 59 } | 59 } |
| 60 | 60 |
| 61 void ChildMemoryCoordinatorImpl::PurgeMemory() { |
| 62 base::MemoryCoordinatorClientRegistry::GetInstance()->PurgeMemory(); |
| 63 // TODO(bashi): Remove following notification when all clients implement |
| 64 // OnPurgeMemory(); |
| 65 base::MemoryCoordinatorClientRegistry::GetInstance()->Notify( |
| 66 base::MemoryState::SUSPENDED); |
| 67 } |
| 68 |
| 61 void ChildMemoryCoordinatorImpl::OnStateChange(mojom::MemoryState state) { | 69 void ChildMemoryCoordinatorImpl::OnStateChange(mojom::MemoryState state) { |
| 62 base::MemoryState base_state = ToBaseMemoryState(state); | 70 base::MemoryState base_state = ToBaseMemoryState(state); |
| 63 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("memory-infra"), | 71 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("memory-infra"), |
| 64 "ChildMemoryCoordinatorImpl::OnStateChange", "state", | 72 "ChildMemoryCoordinatorImpl::OnStateChange", "state", |
| 65 MemoryStateToString(base_state)); | 73 MemoryStateToString(base_state)); |
| 66 base::MemoryCoordinatorClientRegistry::GetInstance()->Notify( | 74 base::MemoryCoordinatorClientRegistry::GetInstance()->Notify( |
| 67 base_state); | 75 base_state); |
| 68 } | 76 } |
| 69 | 77 |
| 70 #if !defined(OS_ANDROID) | 78 #if !defined(OS_ANDROID) |
| 71 std::unique_ptr<ChildMemoryCoordinatorImpl> CreateChildMemoryCoordinator( | 79 std::unique_ptr<ChildMemoryCoordinatorImpl> CreateChildMemoryCoordinator( |
| 72 mojom::MemoryCoordinatorHandlePtr parent, | 80 mojom::MemoryCoordinatorHandlePtr parent, |
| 73 ChildMemoryCoordinatorDelegate* delegate) { | 81 ChildMemoryCoordinatorDelegate* delegate) { |
| 74 return base::WrapUnique( | 82 return base::WrapUnique( |
| 75 new ChildMemoryCoordinatorImpl(std::move(parent), delegate)); | 83 new ChildMemoryCoordinatorImpl(std::move(parent), delegate)); |
| 76 } | 84 } |
| 77 #endif | 85 #endif |
| 78 | 86 |
| 79 } // namespace content | 87 } // namespace content |
| OLD | NEW |