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 17 matching lines...) Expand all Loading... |
28 public WindowManagerObserver, | 28 public WindowManagerObserver, |
29 public ActivityManagerObserver, | 29 public ActivityManagerObserver, |
30 public MemoryPressureObserver, | 30 public MemoryPressureObserver, |
31 public WindowListProviderObserver { | 31 public WindowListProviderObserver { |
32 public: | 32 public: |
33 ResourceManagerImpl(ResourceManagerDelegate* delegate); | 33 ResourceManagerImpl(ResourceManagerDelegate* delegate); |
34 virtual ~ResourceManagerImpl(); | 34 virtual ~ResourceManagerImpl(); |
35 | 35 |
36 // ResourceManager: | 36 // ResourceManager: |
37 virtual void SetMemoryPressureAndStopMonitoring( | 37 virtual void SetMemoryPressureAndStopMonitoring( |
38 MemoryPressure pressure) OVERRIDE; | 38 MemoryPressure pressure) override; |
39 virtual void SetWaitTimeBetweenResourceManageCalls(int time_in_ms) OVERRIDE { | 39 virtual void SetWaitTimeBetweenResourceManageCalls(int time_in_ms) override { |
40 wait_time_for_resource_deallocation_ = | 40 wait_time_for_resource_deallocation_ = |
41 base::TimeDelta::FromMilliseconds(time_in_ms); | 41 base::TimeDelta::FromMilliseconds(time_in_ms); |
42 // Reset the timeout to force the next resource call to execute immediately. | 42 // Reset the timeout to force the next resource call to execute immediately. |
43 next_resource_management_time_ = base::Time::Now(); | 43 next_resource_management_time_ = base::Time::Now(); |
44 } | 44 } |
45 | 45 |
46 virtual void Pause(bool pause) OVERRIDE { | 46 virtual void Pause(bool pause) override { |
47 if (pause) { | 47 if (pause) { |
48 if (!pause_) | 48 if (!pause_) |
49 queued_command_ = false; | 49 queued_command_ = false; |
50 ++pause_; | 50 ++pause_; |
51 } else { | 51 } else { |
52 DCHECK(pause_); | 52 DCHECK(pause_); |
53 --pause_; | 53 --pause_; |
54 if (!pause && queued_command_) { | 54 if (!pause && queued_command_) { |
55 UpdateActivityOrder(); | 55 UpdateActivityOrder(); |
56 ManageResource(); | 56 ManageResource(); |
57 } | 57 } |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 // ActivityManagerObserver: | 61 // ActivityManagerObserver: |
62 virtual void OnActivityStarted(Activity* activity) OVERRIDE; | 62 virtual void OnActivityStarted(Activity* activity) override; |
63 virtual void OnActivityEnding(Activity* activity) OVERRIDE; | 63 virtual void OnActivityEnding(Activity* activity) override; |
64 | 64 |
65 // WindowManagerObserver: | 65 // WindowManagerObserver: |
66 virtual void OnOverviewModeEnter() OVERRIDE; | 66 virtual void OnOverviewModeEnter() override; |
67 virtual void OnOverviewModeExit() OVERRIDE; | 67 virtual void OnOverviewModeExit() override; |
68 virtual void OnSplitViewModeEnter() OVERRIDE; | 68 virtual void OnSplitViewModeEnter() override; |
69 virtual void OnSplitViewModeExit() OVERRIDE; | 69 virtual void OnSplitViewModeExit() override; |
70 | 70 |
71 // MemoryPressureObserver: | 71 // MemoryPressureObserver: |
72 virtual void OnMemoryPressure(MemoryPressure pressure) OVERRIDE; | 72 virtual void OnMemoryPressure(MemoryPressure pressure) override; |
73 virtual ResourceManagerDelegate* GetDelegate() OVERRIDE; | 73 virtual ResourceManagerDelegate* GetDelegate() override; |
74 | 74 |
75 // WindowListProviderObserver: | 75 // WindowListProviderObserver: |
76 virtual void OnWindowStackingChanged() OVERRIDE; | 76 virtual void OnWindowStackingChanged() override; |
77 virtual void OnWindowRemoved(aura::Window* removed_window, | 77 virtual void OnWindowRemoved(aura::Window* removed_window, |
78 int index) OVERRIDE; | 78 int index) override; |
79 | 79 |
80 private: | 80 private: |
81 // Manage the resources for our activities. | 81 // Manage the resources for our activities. |
82 void ManageResource(); | 82 void ManageResource(); |
83 | 83 |
84 // Check that the visibility of activities is properly set. | 84 // Check that the visibility of activities is properly set. |
85 void UpdateVisibilityStates(); | 85 void UpdateVisibilityStates(); |
86 | 86 |
87 // Check if activities can be unloaded to reduce memory pressure. | 87 // Check if activities can be unloaded to reduce memory pressure. |
88 void TryToUnloadAnActivity(); | 88 void TryToUnloadAnActivity(); |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 } | 480 } |
481 | 481 |
482 ResourceManager::ResourceManager() {} | 482 ResourceManager::ResourceManager() {} |
483 | 483 |
484 ResourceManager::~ResourceManager() { | 484 ResourceManager::~ResourceManager() { |
485 DCHECK(instance); | 485 DCHECK(instance); |
486 instance = NULL; | 486 instance = NULL; |
487 } | 487 } |
488 | 488 |
489 } // namespace athena | 489 } // namespace athena |
OLD | NEW |