Chromium Code Reviews| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 current_memory_pressure_(MemoryPressureObserver::MEMORY_PRESSURE_UNKNOWN), | 160 current_memory_pressure_(MemoryPressureObserver::MEMORY_PRESSURE_UNKNOWN), |
| 161 memory_pressure_notifier_(new MemoryPressureNotifier(this)), | 161 memory_pressure_notifier_(new MemoryPressureNotifier(this)), |
| 162 pause_(false), | 162 pause_(false), |
| 163 queued_command_(false), | 163 queued_command_(false), |
| 164 activity_order_changed_(false), | 164 activity_order_changed_(false), |
| 165 in_overview_mode_(false), | 165 in_overview_mode_(false), |
| 166 in_split_view_mode_(false), | 166 in_split_view_mode_(false), |
| 167 next_resource_management_time_(base::Time::Now()), | 167 next_resource_management_time_(base::Time::Now()), |
| 168 wait_time_for_resource_deallocation_(base::TimeDelta::FromMilliseconds( | 168 wait_time_for_resource_deallocation_(base::TimeDelta::FromMilliseconds( |
| 169 delegate_->MemoryPressureIntervalInMS())) { | 169 delegate_->MemoryPressureIntervalInMS())) { |
| 170 WindowManager::GetInstance()->AddObserver(this); | 170 WindowManager::Get()->AddObserver(this); |
| 171 WindowManager::GetInstance()->GetWindowListProvider()->AddObserver(this); | 171 WindowManager::Get()->GetWindowListProvider()->AddObserver(this); |
| 172 ActivityManager::Get()->AddObserver(this); | 172 ActivityManager::Get()->AddObserver(this); |
| 173 } | 173 } |
| 174 | 174 |
| 175 ResourceManagerImpl::~ResourceManagerImpl() { | 175 ResourceManagerImpl::~ResourceManagerImpl() { |
| 176 ActivityManager::Get()->RemoveObserver(this); | 176 ActivityManager::Get()->RemoveObserver(this); |
| 177 WindowManager::GetInstance()->GetWindowListProvider()->RemoveObserver(this); | 177 WindowManager::Get()->GetWindowListProvider()->RemoveObserver(this); |
| 178 WindowManager::GetInstance()->RemoveObserver(this); | 178 WindowManager::Get()->RemoveObserver(this); |
| 179 | 179 |
| 180 while (!activity_list_.empty()) | 180 while (!activity_list_.empty()) |
| 181 OnActivityEnding(activity_list_.front()); | 181 OnActivityEnding(activity_list_.front()); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void ResourceManagerImpl::SetMemoryPressureAndStopMonitoring( | 184 void ResourceManagerImpl::SetMemoryPressureAndStopMonitoring( |
| 185 MemoryPressureObserver::MemoryPressure pressure) { | 185 MemoryPressureObserver::MemoryPressure pressure) { |
| 186 memory_pressure_notifier_->StopObserving(); | 186 memory_pressure_notifier_->StopObserving(); |
| 187 OnMemoryPressure(pressure); | 187 OnMemoryPressure(pressure); |
| 188 } | 188 } |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 unloadable_activities.size() << ")"; | 411 unloadable_activities.size() << ")"; |
| 412 } | 412 } |
| 413 } | 413 } |
| 414 | 414 |
| 415 void ResourceManagerImpl::UpdateActivityOrder() { | 415 void ResourceManagerImpl::UpdateActivityOrder() { |
| 416 queued_command_ = true; | 416 queued_command_ = true; |
| 417 if (activity_list_.empty()) | 417 if (activity_list_.empty()) |
| 418 return; | 418 return; |
| 419 std::vector<Activity*> new_activity_list; | 419 std::vector<Activity*> new_activity_list; |
| 420 const aura::Window::Windows children = | 420 const aura::Window::Windows children = |
| 421 activity_list_[0]->GetWindow()->parent()->children(); | 421 WindowManager::Get()->GetWindowListProvider()->GetWindowList(); |
|
Jun Mukai
2014/09/23 23:01:49
IIRC this intentionally doesn't use WindowListProv
Jun Mukai
2014/09/23 23:20:08
chatted offline and this is actually a good move.
Mr4D (OOO till 08-26)
2014/09/23 23:21:02
When this was written the WindowListProvider did n
| |
| 422 // Find the first window in the container which is part of the application. | 422 // Find the first window in the container which is part of the application. |
| 423 for (aura::Window::Windows::const_reverse_iterator child_iterator = | 423 for (aura::Window::Windows::const_reverse_iterator child_iterator = |
| 424 children.rbegin(); | 424 children.rbegin(); |
| 425 child_iterator != children.rend(); ++child_iterator) { | 425 child_iterator != children.rend(); ++child_iterator) { |
| 426 for (std::vector<Activity*>::iterator activity_iterator = | 426 for (std::vector<Activity*>::iterator activity_iterator = |
| 427 activity_list_.begin(); | 427 activity_list_.begin(); |
| 428 activity_iterator != activity_list_.end(); ++activity_iterator) { | 428 activity_iterator != activity_list_.end(); ++activity_iterator) { |
| 429 if (*child_iterator == (*activity_iterator)->GetWindow()) { | 429 if (*child_iterator == (*activity_iterator)->GetWindow()) { |
| 430 new_activity_list.push_back(*activity_iterator); | 430 new_activity_list.push_back(*activity_iterator); |
| 431 activity_list_.erase(activity_iterator); | 431 activity_list_.erase(activity_iterator); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 } | 479 } |
| 480 | 480 |
| 481 ResourceManager::ResourceManager() {} | 481 ResourceManager::ResourceManager() {} |
| 482 | 482 |
| 483 ResourceManager::~ResourceManager() { | 483 ResourceManager::~ResourceManager() { |
| 484 DCHECK(instance); | 484 DCHECK(instance); |
| 485 instance = NULL; | 485 instance = NULL; |
| 486 } | 486 } |
| 487 | 487 |
| 488 } // namespace athena | 488 } // namespace athena |
| OLD | NEW |