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

Side by Side Diff: content/browser/memory/memory_coordinator_impl.cc

Issue 2412413002: WIP: Add MemoryCoordinator::GetCurrentMemoryState (Closed)
Patch Set: (rebase) Created 4 years, 2 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/browser/memory/memory_coordinator_impl.h" 5 #include "content/browser/memory/memory_coordinator_impl.h"
6 6
7 #include "base/threading/thread_task_runner_handle.h" 7 #include "base/threading/thread_task_runner_handle.h"
8 #include "content/browser/memory/memory_monitor.h" 8 #include "content/browser/memory/memory_monitor.h"
9 #include "content/public/common/content_features.h" 9 #include "content/public/common/content_features.h"
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 DCHECK(last_state_change_.is_null()); 95 DCHECK(last_state_change_.is_null());
96 DCHECK(ValidateParameters()); 96 DCHECK(ValidateParameters());
97 ScheduleUpdateState(base::TimeDelta()); 97 ScheduleUpdateState(base::TimeDelta());
98 } 98 }
99 99
100 void MemoryCoordinatorImpl::OnChildAdded(int render_process_id) { 100 void MemoryCoordinatorImpl::OnChildAdded(int render_process_id) {
101 // Populate the global state as an initial state of a newly created process. 101 // Populate the global state as an initial state of a newly created process.
102 SetMemoryState(render_process_id, ToMojomMemoryState(current_state_)); 102 SetMemoryState(render_process_id, ToMojomMemoryState(current_state_));
103 } 103 }
104 104
105 base::MemoryState MemoryCoordinatorImpl::GetCurrentMemoryState() const {
106 return current_state_;
107 }
108
105 base::MemoryState MemoryCoordinatorImpl::CalculateNextState() { 109 base::MemoryState MemoryCoordinatorImpl::CalculateNextState() {
106 using MemoryState = base::MemoryState; 110 using MemoryState = base::MemoryState;
107 111
108 int available = memory_monitor_->GetFreeMemoryUntilCriticalMB(); 112 int available = memory_monitor_->GetFreeMemoryUntilCriticalMB();
109 if (available <= 0) 113 if (available <= 0)
110 return MemoryState::SUSPENDED; 114 return MemoryState::SUSPENDED;
111 115
112 int expected_renderer_count = available / expected_renderer_size_; 116 int expected_renderer_count = available / expected_renderer_size_;
113 117
114 switch (current_state_) { 118 switch (current_state_) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 186 }
183 187
184 bool MemoryCoordinatorImpl::ValidateParameters() { 188 bool MemoryCoordinatorImpl::ValidateParameters() {
185 return (new_renderers_until_throttled_ > new_renderers_until_suspended_) && 189 return (new_renderers_until_throttled_ > new_renderers_until_suspended_) &&
186 (new_renderers_back_to_normal_ > new_renderers_back_to_throttled_) && 190 (new_renderers_back_to_normal_ > new_renderers_back_to_throttled_) &&
187 (new_renderers_back_to_normal_ > new_renderers_until_throttled_) && 191 (new_renderers_back_to_normal_ > new_renderers_until_throttled_) &&
188 (new_renderers_back_to_throttled_ > new_renderers_until_suspended_); 192 (new_renderers_back_to_throttled_ > new_renderers_until_suspended_);
189 } 193 }
190 194
191 } // namespace content 195 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/memory/memory_coordinator_impl.h ('k') | content/browser/memory/memory_coordinator_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698