OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/resource_manager/public/resource_manager.h" | 5 #include "athena/resource_manager/public/resource_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "athena/activity/public/activity.h" | 10 #include "athena/activity/public/activity.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // Remember that the activity order has changed. | 168 // Remember that the activity order has changed. |
169 activity_order_changed_ = true; | 169 activity_order_changed_ = true; |
170 } | 170 } |
171 | 171 |
172 void ResourceManagerImpl::OnOverviewModeEnter() { | 172 void ResourceManagerImpl::OnOverviewModeEnter() { |
173 in_overview_mode_ = true; | 173 in_overview_mode_ = true; |
174 } | 174 } |
175 | 175 |
176 void ResourceManagerImpl::OnOverviewModeExit() { | 176 void ResourceManagerImpl::OnOverviewModeExit() { |
177 in_overview_mode_ = false; | 177 in_overview_mode_ = false; |
178 // Reorder the activities. | 178 // Reorder the activities and manage the resources again since an order change |
| 179 // might have caused a visibility change. |
179 UpdateActivityOrder(); | 180 UpdateActivityOrder(); |
| 181 ManageResource(); |
180 } | 182 } |
181 | 183 |
182 void ResourceManagerImpl::OnSplitViewModeEnter() { | 184 void ResourceManagerImpl::OnSplitViewModeEnter() { |
183 // Re-apply the memory pressure to make sure enough items are visible. | 185 // Re-apply the memory pressure to make sure enough items are visible. |
184 in_splitview_mode_ = true; | 186 in_splitview_mode_ = true; |
185 ManageResource(); | 187 ManageResource(); |
186 } | 188 } |
187 | 189 |
188 | 190 |
189 void ResourceManagerImpl::OnSplitViewModeExit() { | 191 void ResourceManagerImpl::OnSplitViewModeExit() { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 // The first |kMaxVisibleActivities| entries should be visible, all others | 276 // The first |kMaxVisibleActivities| entries should be visible, all others |
275 // invisible or at a lower activity state. | 277 // invisible or at a lower activity state. |
276 if (index < max_activities || | 278 if (index < max_activities || |
277 (state == Activity::ACTIVITY_INVISIBLE || | 279 (state == Activity::ACTIVITY_INVISIBLE || |
278 state == Activity::ACTIVITY_VISIBLE)) { | 280 state == Activity::ACTIVITY_VISIBLE)) { |
279 Activity::ActivityState visiblity_state = | 281 Activity::ActivityState visiblity_state = |
280 index < max_activities ? Activity::ACTIVITY_VISIBLE : | 282 index < max_activities ? Activity::ACTIVITY_VISIBLE : |
281 Activity::ACTIVITY_INVISIBLE; | 283 Activity::ACTIVITY_INVISIBLE; |
282 // Only change the state when it changes. Note that when the memory | 284 // Only change the state when it changes. Note that when the memory |
283 // pressure is critical, only the primary activities (1 or 2) are made | 285 // pressure is critical, only the primary activities (1 or 2) are made |
284 // visible. Furthermore, in relaxed mode we only want to make visible. | 286 // visible. Furthermore, in relaxed mode we only want to turn visible, |
| 287 // never invisible. |
285 if (visiblity_state != state && | 288 if (visiblity_state != state && |
286 (current_memory_pressure_ != MEMORY_PRESSURE_LOW || | 289 (current_memory_pressure_ != MEMORY_PRESSURE_LOW || |
287 visiblity_state == Activity::ACTIVITY_VISIBLE)) | 290 visiblity_state == Activity::ACTIVITY_VISIBLE)) { |
288 activity->SetCurrentState(visiblity_state); | 291 activity->SetCurrentState(visiblity_state); |
| 292 } |
289 } | 293 } |
290 | 294 |
291 // See which index we should handle next. | 295 // See which index we should handle next. |
292 if (activity_order_changed_) { | 296 if (activity_order_changed_) { |
293 activity_order_changed_ = false; | 297 activity_order_changed_ = false; |
294 index = 0; | 298 index = 0; |
295 } else { | 299 } else { |
296 ++index; | 300 ++index; |
297 } | 301 } |
298 } | 302 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 } | 397 } |
394 | 398 |
395 ResourceManager::ResourceManager() {} | 399 ResourceManager::ResourceManager() {} |
396 | 400 |
397 ResourceManager::~ResourceManager() { | 401 ResourceManager::~ResourceManager() { |
398 DCHECK(instance); | 402 DCHECK(instance); |
399 instance = NULL; | 403 instance = NULL; |
400 } | 404 } |
401 | 405 |
402 } // namespace athena | 406 } // namespace athena |
OLD | NEW |