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" |
11 #include "athena/activity/public/activity_manager.h" | 11 #include "athena/activity/public/activity_manager.h" |
12 #include "athena/activity/public/activity_manager_observer.h" | 12 #include "athena/activity/public/activity_manager_observer.h" |
13 #include "athena/resource_manager/memory_pressure_notifier.h" | 13 #include "athena/resource_manager/memory_pressure_notifier.h" |
14 #include "athena/resource_manager/public/resource_manager_delegate.h" | 14 #include "athena/resource_manager/public/resource_manager_delegate.h" |
15 #include "athena/wm/public/window_manager.h" | 15 #include "athena/wm/public/window_manager.h" |
16 #include "athena/wm/public/window_manager_observer.h" | 16 #include "athena/wm/public/window_manager_observer.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
| 20 #include "ui/aura/window_observer.h" |
20 | 21 |
21 namespace athena { | 22 namespace athena { |
22 | 23 |
23 class ResourceManagerImpl : public ResourceManager, | 24 class ResourceManagerImpl : public ResourceManager, |
24 public WindowManagerObserver, | 25 public WindowManagerObserver, |
25 public ActivityManagerObserver, | 26 public ActivityManagerObserver, |
26 public MemoryPressureObserver { | 27 public MemoryPressureObserver, |
| 28 public aura::WindowObserver { |
27 public: | 29 public: |
28 ResourceManagerImpl(ResourceManagerDelegate* delegate); | 30 ResourceManagerImpl(ResourceManagerDelegate* delegate); |
29 virtual ~ResourceManagerImpl(); | 31 virtual ~ResourceManagerImpl(); |
30 | 32 |
31 // ResourceManager: | 33 // ResourceManager: |
32 virtual void SetMemoryPressureAndStopMonitoring( | 34 virtual void SetMemoryPressureAndStopMonitoring( |
33 MemoryPressureObserver::MemoryPressure pressure) OVERRIDE; | 35 MemoryPressureObserver::MemoryPressure pressure) OVERRIDE; |
| 36 virtual void Pause(bool pause) OVERRIDE { |
| 37 if (pause) { |
| 38 if (!pause_) |
| 39 queued_command_ = false; |
| 40 ++pause_; |
| 41 } else { |
| 42 DCHECK(pause_); |
| 43 --pause_; |
| 44 if (!pause && queued_command_) { |
| 45 UpdateActivityOrder(); |
| 46 ManageResource(); |
| 47 } |
| 48 } |
| 49 } |
34 | 50 |
35 // ActivityManagerObserver: | 51 // ActivityManagerObserver: |
36 virtual void OnActivityStarted(Activity* activity) OVERRIDE; | 52 virtual void OnActivityStarted(Activity* activity) OVERRIDE; |
37 virtual void OnActivityEnding(Activity* activity) OVERRIDE; | 53 virtual void OnActivityEnding(Activity* activity) OVERRIDE; |
38 | 54 |
39 // WindowManagerObserver: | 55 // WindowManagerObserver: |
40 virtual void OnOverviewModeEnter() OVERRIDE; | 56 virtual void OnOverviewModeEnter() OVERRIDE; |
41 virtual void OnOverviewModeExit() OVERRIDE; | 57 virtual void OnOverviewModeExit() OVERRIDE; |
42 virtual void OnActivityOrderHasChanged() OVERRIDE; | 58 virtual void OnSplitViewModeEnter() OVERRIDE; |
| 59 virtual void OnSplitViewModeExit() OVERRIDE; |
43 | 60 |
44 // MemoryPressureObserver: | 61 // MemoryPressureObserver: |
45 virtual void OnMemoryPressure( | 62 virtual void OnMemoryPressure( |
46 MemoryPressureObserver::MemoryPressure pressure) OVERRIDE; | 63 MemoryPressureObserver::MemoryPressure pressure) OVERRIDE; |
47 virtual ResourceManagerDelegate* GetDelegate() OVERRIDE; | 64 virtual ResourceManagerDelegate* GetDelegate() OVERRIDE; |
48 | 65 |
| 66 // aura::WindowObserver: |
| 67 virtual void OnWindowStackingChanged(aura::Window* window) OVERRIDE; |
| 68 |
49 private: | 69 private: |
50 // Manage the resources for our activities. | 70 // Manage the resources for our activities. |
51 void ManageResource(); | 71 void ManageResource(); |
52 | 72 |
53 // Order our activity list to the order of activities of the stream. | 73 // Order our activity list to the order of activities of the stream. |
54 // TODO(skuhne): Once the ActivityManager is responsible to create this list | 74 // TODO(skuhne): Once the ActivityManager is responsible to create this list |
55 // for us, we can remove this code here. | 75 // for us, we can remove this code here. |
56 void UpdateActivityOrder(); | 76 void UpdateActivityOrder(); |
57 | 77 |
58 // The sorted (new(front) -> old(back)) activity list. | 78 // The sorted (new(front) -> old(back)) activity list. |
59 // TODO(skuhne): Once the ActivityManager is responsible to create this list | 79 // TODO(skuhne): Once the ActivityManager is responsible to create this list |
60 // for us, we can remove this code here. | 80 // for us, we can remove this code here. |
61 std::vector<Activity*> activity_list_; | 81 std::vector<Activity*> activity_list_; |
62 | 82 |
63 // The resource manager delegate. | 83 // The resource manager delegate. |
64 scoped_ptr<ResourceManagerDelegate> delegate_; | 84 scoped_ptr<ResourceManagerDelegate> delegate_; |
65 | 85 |
66 // Keeping a reference to the current memory pressure. | 86 // Keeping a reference to the current memory pressure. |
67 MemoryPressureObserver::MemoryPressure current_memory_pressure_; | 87 MemoryPressureObserver::MemoryPressure current_memory_pressure_; |
68 | 88 |
69 // The memory pressure notifier. | 89 // The memory pressure notifier. |
70 scoped_ptr<MemoryPressureNotifier> memory_pressure_notifier_; | 90 scoped_ptr<MemoryPressureNotifier> memory_pressure_notifier_; |
71 | 91 |
| 92 // A ref counter. As long as not 0, the management is on hold. |
| 93 int pause_; |
| 94 |
| 95 // If true, a command came in while the resource manager was paused. |
| 96 bool queued_command_; |
| 97 |
| 98 // Used by ManageResource() to determine an activity state change while it |
| 99 // changes Activity properties. |
| 100 bool activity_order_changed_; |
| 101 |
| 102 // True if in overview mode - activity order changes will be ignored if true |
| 103 // and postponed till after the overview mode is ending. |
| 104 bool in_overview_mode_; |
| 105 |
| 106 // True if we are in split view mode. |
| 107 bool in_splitview_mode_; |
| 108 |
72 DISALLOW_COPY_AND_ASSIGN(ResourceManagerImpl); | 109 DISALLOW_COPY_AND_ASSIGN(ResourceManagerImpl); |
73 }; | 110 }; |
74 | 111 |
75 namespace { | 112 namespace { |
76 ResourceManagerImpl* instance = NULL; | 113 ResourceManagerImpl* instance = NULL; |
| 114 |
| 115 // We allow this many activities to be visible. All others must be at state of |
| 116 // invisible or below. |
| 117 const int kMaxVisibleActivities = 3; |
| 118 |
77 } // namespace | 119 } // namespace |
78 | 120 |
79 ResourceManagerImpl::ResourceManagerImpl(ResourceManagerDelegate* delegate) | 121 ResourceManagerImpl::ResourceManagerImpl(ResourceManagerDelegate* delegate) |
80 : delegate_(delegate), | 122 : delegate_(delegate), |
81 current_memory_pressure_(MemoryPressureObserver::MEMORY_PRESSURE_UNKNOWN), | 123 current_memory_pressure_(MemoryPressureObserver::MEMORY_PRESSURE_UNKNOWN), |
82 memory_pressure_notifier_(new MemoryPressureNotifier(this)) { | 124 memory_pressure_notifier_(new MemoryPressureNotifier(this)), |
| 125 pause_(false), |
| 126 queued_command_(false), |
| 127 activity_order_changed_(false), |
| 128 in_overview_mode_(false), |
| 129 in_splitview_mode_(false) { |
83 WindowManager::GetInstance()->AddObserver(this); | 130 WindowManager::GetInstance()->AddObserver(this); |
84 ActivityManager::Get()->AddObserver(this); | 131 ActivityManager::Get()->AddObserver(this); |
85 } | 132 } |
86 | 133 |
87 ResourceManagerImpl::~ResourceManagerImpl() { | 134 ResourceManagerImpl::~ResourceManagerImpl() { |
88 ActivityManager::Get()->RemoveObserver(this); | 135 ActivityManager::Get()->RemoveObserver(this); |
89 WindowManager::GetInstance()->RemoveObserver(this); | 136 WindowManager::GetInstance()->RemoveObserver(this); |
90 } | 137 } |
91 | 138 |
92 void ResourceManagerImpl::SetMemoryPressureAndStopMonitoring( | 139 void ResourceManagerImpl::SetMemoryPressureAndStopMonitoring( |
93 MemoryPressureObserver::MemoryPressure pressure) { | 140 MemoryPressureObserver::MemoryPressure pressure) { |
94 memory_pressure_notifier_->StopObserving(); | 141 memory_pressure_notifier_->StopObserving(); |
95 OnMemoryPressure(pressure); | 142 OnMemoryPressure(pressure); |
96 } | 143 } |
97 | 144 |
98 void ResourceManagerImpl::OnActivityStarted(Activity* activity) { | 145 void ResourceManagerImpl::OnActivityStarted(Activity* activity) { |
99 // As long as we have to manage the list of activities ourselves, we need to | 146 // As long as we have to manage the list of activities ourselves, we need to |
100 // order it here. | 147 // order it here. |
101 activity_list_.push_back(activity); | 148 activity_list_.push_back(activity); |
102 UpdateActivityOrder(); | 149 UpdateActivityOrder(); |
103 // Update the activity states. | 150 // Update the activity states. |
104 ManageResource(); | 151 ManageResource(); |
| 152 // Remember that the activity order has changed. |
| 153 activity_order_changed_ = true; |
| 154 activity->GetWindow()->AddObserver(this); |
105 } | 155 } |
106 | 156 |
107 void ResourceManagerImpl::OnActivityEnding(Activity* activity) { | 157 void ResourceManagerImpl::OnActivityEnding(Activity* activity) { |
| 158 DCHECK(activity->GetWindow()); |
| 159 activity->GetWindow()->RemoveObserver(this); |
108 // Remove the activity from the list again. | 160 // Remove the activity from the list again. |
109 std::vector<Activity*>::iterator it = | 161 std::vector<Activity*>::iterator it = |
110 std::find(activity_list_.begin(), activity_list_.end(), activity); | 162 std::find(activity_list_.begin(), activity_list_.end(), activity); |
111 DCHECK(it != activity_list_.end()); | 163 DCHECK(it != activity_list_.end()); |
112 activity_list_.erase(it); | 164 activity_list_.erase(it); |
| 165 // Remember that the activity order has changed. |
| 166 activity_order_changed_ = true; |
113 } | 167 } |
114 | 168 |
115 void ResourceManagerImpl::OnOverviewModeEnter() { | 169 void ResourceManagerImpl::OnOverviewModeEnter() { |
116 // Nothing to do here. | 170 in_overview_mode_ = true; |
117 } | 171 } |
118 | 172 |
119 void ResourceManagerImpl::OnOverviewModeExit() { | 173 void ResourceManagerImpl::OnOverviewModeExit() { |
120 // Nothing to do here. | 174 in_overview_mode_ = false; |
| 175 // Reorder the activities. |
| 176 UpdateActivityOrder(); |
121 } | 177 } |
122 | 178 |
123 void ResourceManagerImpl::OnActivityOrderHasChanged() { | 179 void ResourceManagerImpl::OnSplitViewModeEnter() { |
| 180 // Re-apply the memory pressure to make sure enough items are visible. |
| 181 in_splitview_mode_ = true; |
| 182 ManageResource(); |
| 183 } |
| 184 |
| 185 |
| 186 void ResourceManagerImpl::OnSplitViewModeExit() { |
| 187 // We don't do immediately something yet. The next ManageResource call will |
| 188 // come soon. |
| 189 in_splitview_mode_ = false; |
| 190 } |
| 191 |
| 192 void ResourceManagerImpl::OnWindowStackingChanged(aura::Window* window) { |
| 193 // TODO(skuhne): This needs to be changed to some WindowListProvider observer |
| 194 // if we decouple window order from activity order. |
| 195 |
| 196 // No need to do anything while being in overview mode. |
| 197 if (in_overview_mode_) |
| 198 return; |
| 199 |
124 // As long as we have to manage the list of activities ourselves, we need to | 200 // As long as we have to manage the list of activities ourselves, we need to |
125 // order it here. | 201 // order it here. |
126 UpdateActivityOrder(); | 202 UpdateActivityOrder(); |
| 203 |
127 // Manage the resources of each activity. | 204 // Manage the resources of each activity. |
128 ManageResource(); | 205 ManageResource(); |
129 } | 206 } |
130 | 207 |
131 void ResourceManagerImpl::OnMemoryPressure( | 208 void ResourceManagerImpl::OnMemoryPressure( |
132 MemoryPressureObserver::MemoryPressure pressure) { | 209 MemoryPressureObserver::MemoryPressure pressure) { |
133 current_memory_pressure_ = pressure; | 210 current_memory_pressure_ = pressure; |
134 ManageResource(); | 211 ManageResource(); |
135 } | 212 } |
136 | 213 |
137 ResourceManagerDelegate* ResourceManagerImpl::GetDelegate() { | 214 ResourceManagerDelegate* ResourceManagerImpl::GetDelegate() { |
138 return delegate_.get(); | 215 return delegate_.get(); |
139 } | 216 } |
140 | 217 |
141 void ResourceManagerImpl::ManageResource() { | 218 void ResourceManagerImpl::ManageResource() { |
142 // If there is none or only one app running we cannot do anything. | 219 // If there is none or only one app running we cannot do anything. |
143 if (activity_list_.size() <= 1U) | 220 if (activity_list_.size() <= 1U) |
144 return; | 221 return; |
| 222 |
| 223 if (pause_) { |
| 224 queued_command_ = true; |
| 225 return; |
| 226 } |
| 227 |
145 // TODO(skuhne): This algorithm needs to take all kinds of predictive analysis | 228 // TODO(skuhne): This algorithm needs to take all kinds of predictive analysis |
146 // and running applications into account. For this first patch we only do a | 229 // and running applications into account. For this first patch we only do a |
147 // very simple "floating window" algorithm which is surely not good enough. | 230 // very simple "floating window" algorithm which is surely not good enough. |
148 size_t max_running_activities = 5; | 231 size_t max_running_activities = 5; |
149 switch (current_memory_pressure_) { | 232 switch (current_memory_pressure_) { |
150 case MEMORY_PRESSURE_UNKNOWN: | 233 case MEMORY_PRESSURE_UNKNOWN: |
151 // If we do not know how much memory we have we assume that it must be a | 234 // If we do not know how much memory we have we assume that it must be a |
152 // high consumption. | 235 // high consumption. |
153 // Fallthrough. | 236 // Fallthrough. |
154 case MEMORY_PRESSURE_HIGH: | 237 case MEMORY_PRESSURE_HIGH: |
155 max_running_activities = 5; | 238 max_running_activities = 5; |
156 break; | 239 break; |
157 case MEMORY_PRESSURE_CRITICAL: | 240 case MEMORY_PRESSURE_CRITICAL: |
158 max_running_activities = 0; | 241 max_running_activities = 0; |
159 break; | 242 break; |
160 case MEMORY_PRESSURE_MODERATE: | 243 case MEMORY_PRESSURE_MODERATE: |
161 max_running_activities = 7; | 244 max_running_activities = 7; |
162 break; | 245 break; |
163 case MEMORY_PRESSURE_LOW: | 246 case MEMORY_PRESSURE_LOW: |
164 // No need to do anything yet. | 247 // This doesn't really matter. We do not change anything but turning |
165 return; | 248 // activities visible. |
| 249 max_running_activities = 10000; |
| 250 break; |
166 } | 251 } |
| 252 |
| 253 // The first n activities should be trated as "visible", means they updated |
| 254 // in overview mode and will keep their layer resources for faster switch |
| 255 // times. Usually we use |kMaxVisibleActivities| items, but when the memory |
| 256 // pressure gets critical we only hold as many as are really visible. |
| 257 size_t max_activities = kMaxVisibleActivities; |
| 258 if (current_memory_pressure_ == MEMORY_PRESSURE_CRITICAL) |
| 259 max_activities = 1 + (in_splitview_mode_ ? 1 : 0); |
| 260 |
| 261 // Restart and / or bail if the order of activities changes due to our calls. |
| 262 activity_order_changed_ = false; |
| 263 |
| 264 // Change the visibility of our activities in a pre-processing step. This is |
| 265 // required since it might change the order/number of activities. |
| 266 size_t index = 0; |
| 267 while (index < activity_list_.size()) { |
| 268 Activity* activity = activity_list_[index]; |
| 269 Activity::ActivityState state = activity->GetCurrentState(); |
| 270 |
| 271 // The first |kMaxVisibleActivities| entries should be visible, all others |
| 272 // invisible or at a lower activity state. |
| 273 if (index < max_activities || |
| 274 (state == Activity::ACTIVITY_INVISIBLE || |
| 275 state == Activity::ACTIVITY_VISIBLE)) { |
| 276 Activity::ActivityState visiblity_state = |
| 277 index < max_activities ? Activity::ACTIVITY_VISIBLE : |
| 278 Activity::ACTIVITY_INVISIBLE; |
| 279 // Only change the state when it changes. Note that when the memory |
| 280 // pressure is critical, only the primary activities (1 or 2) are made |
| 281 // visible. Furthermore, in relaxed mode we only want to make visible. |
| 282 if (visiblity_state != state && |
| 283 (current_memory_pressure_ != MEMORY_PRESSURE_LOW || |
| 284 visiblity_state == Activity::ACTIVITY_VISIBLE)) |
| 285 activity->SetCurrentState(visiblity_state); |
| 286 } |
| 287 |
| 288 // See which index we should handle next. |
| 289 if (activity_order_changed_) { |
| 290 activity_order_changed_ = false; |
| 291 index = 0; |
| 292 } else { |
| 293 ++index; |
| 294 } |
| 295 } |
| 296 |
| 297 // No need to remove anything. |
| 298 if (current_memory_pressure_ == MEMORY_PRESSURE_LOW) |
| 299 return; |
| 300 |
| 301 // Check if/which activity we want to unload. |
167 Activity* oldest_media_activity = NULL; | 302 Activity* oldest_media_activity = NULL; |
168 std::vector<Activity*> unloadable_activities; | 303 std::vector<Activity*> unloadable_activities; |
169 for (std::vector<Activity*>::iterator it = activity_list_.begin(); | 304 for (std::vector<Activity*>::iterator it = activity_list_.begin(); |
170 it != activity_list_.end(); ++it) { | 305 it != activity_list_.end(); ++it) { |
171 // The activity should not be unloaded or visible. | 306 Activity::ActivityState state = (*it)->GetCurrentState(); |
172 if ((*it)->GetCurrentState() != Activity::ACTIVITY_UNLOADED && | 307 // The activity should neither be unloaded nor visible. |
173 !(*it)->IsVisible()) { | 308 if (state != Activity::ACTIVITY_UNLOADED && |
| 309 state != Activity::ACTIVITY_VISIBLE) { |
174 if ((*it)->GetMediaState() == Activity::ACTIVITY_MEDIA_STATE_NONE) { | 310 if ((*it)->GetMediaState() == Activity::ACTIVITY_MEDIA_STATE_NONE) { |
175 // Does not play media - so we can unload this immediately. | 311 // Does not play media - so we can unload this immediately. |
176 unloadable_activities.push_back(*it); | 312 unloadable_activities.push_back(*it); |
177 } else { | 313 } else { |
178 oldest_media_activity = *it; | 314 oldest_media_activity = *it; |
179 } | 315 } |
180 } | 316 } |
181 } | 317 } |
| 318 |
182 if (unloadable_activities.size() > max_running_activities) { | 319 if (unloadable_activities.size() > max_running_activities) { |
183 unloadable_activities.back()->SetCurrentState(Activity::ACTIVITY_UNLOADED); | 320 unloadable_activities.back()->SetCurrentState(Activity::ACTIVITY_UNLOADED); |
184 return; | 321 return; |
185 } else if (current_memory_pressure_ == MEMORY_PRESSURE_CRITICAL) { | 322 } else if (current_memory_pressure_ == MEMORY_PRESSURE_CRITICAL) { |
186 if (oldest_media_activity) { | 323 if (oldest_media_activity) { |
187 oldest_media_activity->SetCurrentState(Activity::ACTIVITY_UNLOADED); | 324 oldest_media_activity->SetCurrentState(Activity::ACTIVITY_UNLOADED); |
| 325 LOG(WARNING) << "Unloading item to releave critical memory pressure"; |
188 return; | 326 return; |
189 } | 327 } |
190 LOG(ERROR) << "[ResourceManager]: Single activity uses too much memory."; | 328 LOG(ERROR) << "[ResourceManager]: Single activity uses too much memory."; |
191 return; | 329 return; |
192 } | 330 } |
| 331 |
193 if (current_memory_pressure_ != MEMORY_PRESSURE_UNKNOWN) { | 332 if (current_memory_pressure_ != MEMORY_PRESSURE_UNKNOWN) { |
194 // Only show this warning when the memory pressure is actually known. This | 333 // Only show this warning when the memory pressure is actually known. This |
195 // will suppress warnings in e.g. unit tests. | 334 // will suppress warnings in e.g. unit tests. |
196 LOG(WARNING) << "[ResourceManager]: No way to release memory pressure (" << | 335 LOG(WARNING) << "[ResourceManager]: No way to release memory pressure (" << |
197 current_memory_pressure_ << | 336 current_memory_pressure_ << |
198 "), Activities (running, allowed, unloadable)=(" << | 337 "), Activities (running, allowed, unloadable)=(" << |
199 activity_list_.size() << ", " << | 338 activity_list_.size() << ", " << |
200 max_running_activities << ", " << | 339 max_running_activities << ", " << |
201 unloadable_activities.size() << ")"; | 340 unloadable_activities.size() << ")"; |
202 } | 341 } |
203 } | 342 } |
204 | 343 |
205 void ResourceManagerImpl::UpdateActivityOrder() { | 344 void ResourceManagerImpl::UpdateActivityOrder() { |
| 345 queued_command_ = true; |
206 if (activity_list_.empty()) | 346 if (activity_list_.empty()) |
207 return; | 347 return; |
208 std::vector<Activity*> new_activity_list; | 348 std::vector<Activity*> new_activity_list; |
209 const aura::Window::Windows children = | 349 const aura::Window::Windows children = |
210 activity_list_[0]->GetWindow()->parent()->children(); | 350 activity_list_[0]->GetWindow()->parent()->children(); |
211 // Find the first window in the container which is part of the application. | 351 // Find the first window in the container which is part of the application. |
212 for (aura::Window::Windows::const_iterator child_iterator = children.begin(); | 352 for (aura::Window::Windows::const_reverse_iterator child_iterator = |
213 child_iterator != children.end(); ++child_iterator) { | 353 children.rbegin(); |
| 354 child_iterator != children.rend(); ++child_iterator) { |
214 for (std::vector<Activity*>::iterator activity_iterator = | 355 for (std::vector<Activity*>::iterator activity_iterator = |
215 activity_list_.begin(); | 356 activity_list_.begin(); |
216 activity_iterator != activity_list_.end(); ++activity_iterator) { | 357 activity_iterator != activity_list_.end(); ++activity_iterator) { |
217 if (*child_iterator == (*activity_iterator)->GetWindow()) { | 358 if (*child_iterator == (*activity_iterator)->GetWindow()) { |
218 new_activity_list.push_back(*activity_iterator); | 359 new_activity_list.push_back(*activity_iterator); |
219 activity_list_.erase(activity_iterator); | 360 activity_list_.erase(activity_iterator); |
220 break; | 361 break; |
221 } | 362 } |
222 } | 363 } |
223 } | 364 } |
224 // At this point the old list should be empty and we can swap the lists. | 365 // At this point the old list should be empty and we can swap the lists. |
225 DCHECK(!activity_list_.size()); | 366 DCHECK(!activity_list_.size()); |
226 activity_list_ = new_activity_list; | 367 activity_list_ = new_activity_list; |
| 368 |
| 369 // Remember that the activity order has changed. |
| 370 activity_order_changed_ = true; |
227 } | 371 } |
228 | 372 |
229 // static | 373 // static |
230 void ResourceManager::Create() { | 374 void ResourceManager::Create() { |
231 DCHECK(!instance); | 375 DCHECK(!instance); |
232 instance = new ResourceManagerImpl( | 376 instance = new ResourceManagerImpl( |
233 ResourceManagerDelegate::CreateResourceManagerDelegate()); | 377 ResourceManagerDelegate::CreateResourceManagerDelegate()); |
234 } | 378 } |
235 | 379 |
236 // static | 380 // static |
237 ResourceManager* ResourceManager::Get() { | 381 ResourceManager* ResourceManager::Get() { |
238 return instance; | 382 return instance; |
239 } | 383 } |
240 | 384 |
241 // static | 385 // static |
242 void ResourceManager::Shutdown() { | 386 void ResourceManager::Shutdown() { |
243 DCHECK(instance); | 387 DCHECK(instance); |
244 delete instance; | 388 delete instance; |
245 instance = NULL; | 389 instance = NULL; |
246 } | 390 } |
247 | 391 |
248 ResourceManager::ResourceManager() {} | 392 ResourceManager::ResourceManager() {} |
249 | 393 |
250 ResourceManager::~ResourceManager() { | 394 ResourceManager::~ResourceManager() { |
251 DCHECK(instance); | 395 DCHECK(instance); |
252 instance = NULL; | 396 instance = NULL; |
253 } | 397 } |
254 | 398 |
255 } // namespace athena | 399 } // namespace athena |
OLD | NEW |