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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // Remember that the activity order has changed. | 169 // Remember that the activity order has changed. |
170 activity_order_changed_ = true; | 170 activity_order_changed_ = true; |
171 } | 171 } |
172 | 172 |
173 void ResourceManagerImpl::OnOverviewModeEnter() { | 173 void ResourceManagerImpl::OnOverviewModeEnter() { |
174 in_overview_mode_ = true; | 174 in_overview_mode_ = true; |
175 } | 175 } |
176 | 176 |
177 void ResourceManagerImpl::OnOverviewModeExit() { | 177 void ResourceManagerImpl::OnOverviewModeExit() { |
178 in_overview_mode_ = false; | 178 in_overview_mode_ = false; |
179 // Reorder the activities. | 179 // Reorder the activities and manage the resources again since an order change |
| 180 // might have caused a visibility change. |
180 UpdateActivityOrder(); | 181 UpdateActivityOrder(); |
| 182 ManageResource(); |
181 } | 183 } |
182 | 184 |
183 void ResourceManagerImpl::OnSplitViewModeEnter() { | 185 void ResourceManagerImpl::OnSplitViewModeEnter() { |
184 // Re-apply the memory pressure to make sure enough items are visible. | 186 // Re-apply the memory pressure to make sure enough items are visible. |
185 in_splitview_mode_ = true; | 187 in_splitview_mode_ = true; |
186 ManageResource(); | 188 ManageResource(); |
187 } | 189 } |
188 | 190 |
189 | 191 |
190 void ResourceManagerImpl::OnSplitViewModeExit() { | 192 void ResourceManagerImpl::OnSplitViewModeExit() { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 // The first |kMaxVisibleActivities| entries should be visible, all others | 282 // The first |kMaxVisibleActivities| entries should be visible, all others |
281 // invisible or at a lower activity state. | 283 // invisible or at a lower activity state. |
282 if (index < max_activities || | 284 if (index < max_activities || |
283 (state == Activity::ACTIVITY_INVISIBLE || | 285 (state == Activity::ACTIVITY_INVISIBLE || |
284 state == Activity::ACTIVITY_VISIBLE)) { | 286 state == Activity::ACTIVITY_VISIBLE)) { |
285 Activity::ActivityState visiblity_state = | 287 Activity::ActivityState visiblity_state = |
286 index < max_activities ? Activity::ACTIVITY_VISIBLE : | 288 index < max_activities ? Activity::ACTIVITY_VISIBLE : |
287 Activity::ACTIVITY_INVISIBLE; | 289 Activity::ACTIVITY_INVISIBLE; |
288 // Only change the state when it changes. Note that when the memory | 290 // Only change the state when it changes. Note that when the memory |
289 // pressure is critical, only the primary activities (1 or 2) are made | 291 // pressure is critical, only the primary activities (1 or 2) are made |
290 // visible. Furthermore, in relaxed mode we only want to make visible. | 292 // visible. Furthermore, in relaxed mode we only want to turn visible, |
| 293 // never invisible. |
291 if (visiblity_state != state && | 294 if (visiblity_state != state && |
292 (current_memory_pressure_ != MEMORY_PRESSURE_LOW || | 295 (current_memory_pressure_ != MEMORY_PRESSURE_LOW || |
293 visiblity_state == Activity::ACTIVITY_VISIBLE)) | 296 visiblity_state == Activity::ACTIVITY_VISIBLE)) { |
294 activity->SetCurrentState(visiblity_state); | 297 activity->SetCurrentState(visiblity_state); |
| 298 } |
295 } | 299 } |
296 | 300 |
297 // See which index we should handle next. | 301 // See which index we should handle next. |
298 if (activity_order_changed_) { | 302 if (activity_order_changed_) { |
299 activity_order_changed_ = false; | 303 activity_order_changed_ = false; |
300 index = 0; | 304 index = 0; |
301 } else { | 305 } else { |
302 ++index; | 306 ++index; |
303 } | 307 } |
304 } | 308 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 } | 403 } |
400 | 404 |
401 ResourceManager::ResourceManager() {} | 405 ResourceManager::ResourceManager() {} |
402 | 406 |
403 ResourceManager::~ResourceManager() { | 407 ResourceManager::~ResourceManager() { |
404 DCHECK(instance); | 408 DCHECK(instance); |
405 instance = NULL; | 409 instance = NULL; |
406 } | 410 } |
407 | 411 |
408 } // namespace athena | 412 } // namespace athena |
OLD | NEW |