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/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 "base/trace_event/trace_event.h" |
8 #include "content/browser/memory/memory_monitor.h" | 9 #include "content/browser/memory/memory_monitor.h" |
9 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
10 #include "content/public/browser/notification_types.h" | 11 #include "content/public/browser/notification_types.h" |
11 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
12 #include "content/public/browser/render_widget_host.h" | 13 #include "content/public/browser/render_widget_host.h" |
13 #include "content/public/common/content_features.h" | 14 #include "content/public/common/content_features.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 namespace { | 18 namespace { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 base::TimeTicks now = base::TimeTicks::Now(); | 190 base::TimeTicks now = base::TimeTicks::Now(); |
190 MemoryState prev_state = current_state_; | 191 MemoryState prev_state = current_state_; |
191 MemoryState next_state = CalculateNextState(); | 192 MemoryState next_state = CalculateNextState(); |
192 | 193 |
193 if (last_state_change_.is_null() || current_state_ != next_state) { | 194 if (last_state_change_.is_null() || current_state_ != next_state) { |
194 current_state_ = next_state; | 195 current_state_ = next_state; |
195 last_state_change_ = now; | 196 last_state_change_ = now; |
196 } | 197 } |
197 | 198 |
198 if (next_state != prev_state) { | 199 if (next_state != prev_state) { |
| 200 TRACE_EVENT2("memory-infra", "MemoryCoordinatorImpl::UpdateState", |
| 201 "prev", MemoryStateToString(prev_state), |
| 202 "next", MemoryStateToString(next_state)); |
| 203 |
199 NotifyStateToClients(); | 204 NotifyStateToClients(); |
200 NotifyStateToChildren(); | 205 NotifyStateToChildren(); |
201 ScheduleUpdateState(minimum_transition_period_); | 206 ScheduleUpdateState(minimum_transition_period_); |
202 } else { | 207 } else { |
203 ScheduleUpdateState(monitoring_interval_); | 208 ScheduleUpdateState(monitoring_interval_); |
204 } | 209 } |
205 } | 210 } |
206 | 211 |
207 void MemoryCoordinatorImpl::NotifyStateToClients() { | 212 void MemoryCoordinatorImpl::NotifyStateToClients() { |
208 auto state = GetCurrentMemoryState(); | 213 auto state = GetCurrentMemoryState(); |
(...skipping 13 matching lines...) Expand all Loading... |
222 } | 227 } |
223 | 228 |
224 bool MemoryCoordinatorImpl::ValidateParameters() { | 229 bool MemoryCoordinatorImpl::ValidateParameters() { |
225 return (new_renderers_until_throttled_ > new_renderers_until_suspended_) && | 230 return (new_renderers_until_throttled_ > new_renderers_until_suspended_) && |
226 (new_renderers_back_to_normal_ > new_renderers_back_to_throttled_) && | 231 (new_renderers_back_to_normal_ > new_renderers_back_to_throttled_) && |
227 (new_renderers_back_to_normal_ > new_renderers_until_throttled_) && | 232 (new_renderers_back_to_normal_ > new_renderers_until_throttled_) && |
228 (new_renderers_back_to_throttled_ > new_renderers_until_suspended_); | 233 (new_renderers_back_to_throttled_ > new_renderers_until_suspended_); |
229 } | 234 } |
230 | 235 |
231 } // namespace content | 236 } // namespace content |
OLD | NEW |