OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_ | 5 #ifndef CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_ |
6 #define CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_ | 6 #define CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_ |
7 | 7 |
8 #include "base/cancelable_callback.h" | 8 #include "base/cancelable_callback.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 void ScheduleUpdateCondition(base::TimeDelta delay); | 29 void ScheduleUpdateCondition(base::TimeDelta delay); |
30 | 30 |
31 // Called when the browser is foregrounded. | 31 // Called when the browser is foregrounded. |
32 void OnForegrounded(); | 32 void OnForegrounded(); |
33 | 33 |
34 // Called when the browser is backgrounded. | 34 // Called when the browser is backgrounded. |
35 void OnBackgrounded(); | 35 void OnBackgrounded(); |
36 | 36 |
37 private: | 37 private: |
38 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, CalculateNextCondition); | 38 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, CalculateNextCondition); |
39 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, UpdateCondition); | |
40 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, ForceSetMemoryCondition); | 39 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, ForceSetMemoryCondition); |
41 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, DiscardTabUnderCritical); | 40 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, DiscardTabUnderCritical); |
42 | 41 |
43 // Sets the monitoring interval and reschedules a task to update memory | 42 // Sets the monitoring interval and reschedules a task to update memory |
44 // condition. | 43 // condition. |
45 void SetMonitoringInterval(base::TimeDelta interval); | 44 void SetMonitoringInterval(base::TimeDelta interval); |
46 | 45 |
47 // Calculates next memory condition from the amount of free memory using | 46 // Calculates next memory condition from the amount of free memory using |
48 // a heuristic. | 47 // a heuristic. |
49 MemoryCondition CalculateNextCondition(); | 48 MemoryCondition CalculateNextCondition(); |
(...skipping 11 matching lines...) Expand all Loading... |
61 base::TimeDelta monitoring_interval_foregrounded_; | 60 base::TimeDelta monitoring_interval_foregrounded_; |
62 // The value of |monitoring_interval_| when the browser is backgrounded. | 61 // The value of |monitoring_interval_| when the browser is backgrounded. |
63 base::TimeDelta monitoring_interval_backgrounded_; | 62 base::TimeDelta monitoring_interval_backgrounded_; |
64 | 63 |
65 DISALLOW_COPY_AND_ASSIGN(MemoryConditionObserver); | 64 DISALLOW_COPY_AND_ASSIGN(MemoryConditionObserver); |
66 }; | 65 }; |
67 | 66 |
68 } // namespace content | 67 } // namespace content |
69 | 68 |
70 #endif // CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_ | 69 #endif // CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_ |
OLD | NEW |