| 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 19 matching lines...) Expand all Loading... |
| 30 ~MemoryConditionObserver(); | 30 ~MemoryConditionObserver(); |
| 31 | 31 |
| 32 // Schedules a task to update memory condition. The task will be executed | 32 // Schedules a task to update memory condition. The task will be executed |
| 33 // after |delay| has passed. | 33 // after |delay| has passed. |
| 34 void ScheduleUpdateCondition(base::TimeDelta delay); | 34 void ScheduleUpdateCondition(base::TimeDelta delay); |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, CalculateNextCondition); | 37 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, CalculateNextCondition); |
| 38 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, UpdateCondition); | 38 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, UpdateCondition); |
| 39 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, ForceSetMemoryCondition); | 39 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, ForceSetMemoryCondition); |
| 40 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, DiscardTabUnderCritical); |
| 40 | 41 |
| 41 // Calculates next memory condition from the amount of free memory using | 42 // Calculates next memory condition from the amount of free memory using |
| 42 // a heuristic. | 43 // a heuristic. |
| 43 MemoryCondition CalculateNextCondition(); | 44 MemoryCondition CalculateNextCondition(); |
| 44 | 45 |
| 45 // Periodically called to update the memory condition. | 46 // Periodically called to update the memory condition. |
| 46 void UpdateCondition(); | 47 void UpdateCondition(); |
| 47 | 48 |
| 48 MemoryCoordinatorImpl* coordinator_; | 49 MemoryCoordinatorImpl* coordinator_; |
| 49 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 50 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 78 int new_renderers_back_to_warning_; | 79 int new_renderers_back_to_warning_; |
| 79 // The interval of checking the amount of free memory. | 80 // The interval of checking the amount of free memory. |
| 80 base::TimeDelta monitoring_interval_; | 81 base::TimeDelta monitoring_interval_; |
| 81 | 82 |
| 82 DISALLOW_COPY_AND_ASSIGN(MemoryConditionObserver); | 83 DISALLOW_COPY_AND_ASSIGN(MemoryConditionObserver); |
| 83 }; | 84 }; |
| 84 | 85 |
| 85 } // namespace content | 86 } // namespace content |
| 86 | 87 |
| 87 #endif // CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_ | 88 #endif // CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_ |
| OLD | NEW |