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

Side by Side Diff: content/child/memory/child_memory_coordinator_impl.cc

Issue 2669323002: Add ChildMemoryCoordinator::PurgeMemory() (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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
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("memory-infra", "ChildMemoryCoordinatorImpl::OnStateChange", 71 TRACE_EVENT1("memory-infra", "ChildMemoryCoordinatorImpl::OnStateChange",
64 "state", MemoryStateToString(base_state)); 72 "state", MemoryStateToString(base_state));
65 base::MemoryCoordinatorClientRegistry::GetInstance()->Notify( 73 base::MemoryCoordinatorClientRegistry::GetInstance()->Notify(
66 base_state); 74 base_state);
67 } 75 }
68 76
69 #if !defined(OS_ANDROID) 77 #if !defined(OS_ANDROID)
70 std::unique_ptr<ChildMemoryCoordinatorImpl> CreateChildMemoryCoordinator( 78 std::unique_ptr<ChildMemoryCoordinatorImpl> CreateChildMemoryCoordinator(
71 mojom::MemoryCoordinatorHandlePtr parent, 79 mojom::MemoryCoordinatorHandlePtr parent,
72 ChildMemoryCoordinatorDelegate* delegate) { 80 ChildMemoryCoordinatorDelegate* delegate) {
73 return base::WrapUnique( 81 return base::WrapUnique(
74 new ChildMemoryCoordinatorImpl(std::move(parent), delegate)); 82 new ChildMemoryCoordinatorImpl(std::move(parent), delegate));
75 } 83 }
76 #endif 84 #endif
77 85
78 } // namespace content 86 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698