| 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_COORDINATOR_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ |
| 6 #define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ | 6 #define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/cancelable_callback.h" | 9 #include "base/cancelable_callback.h" |
| 10 #include "base/memory/memory_coordinator_client.h" | 10 #include "base/memory/memory_coordinator_client.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 class MemoryMonitor; | 31 class MemoryMonitor; |
| 32 class RenderProcessHost; | 32 class RenderProcessHost; |
| 33 | 33 |
| 34 using MemoryState = base::MemoryState; | 34 using MemoryState = base::MemoryState; |
| 35 | 35 |
| 36 // MemoryCondition is an internal state of memory coordinator which is used for | 36 // MemoryCondition is an internal state of memory coordinator which is used for |
| 37 // various things; calculating memory state for processes, requesting processes | 37 // various things; calculating memory state for processes, requesting processes |
| 38 // to purge memory, and scheduling tab discarding. | 38 // to purge memory, and scheduling tab discarding. |
| 39 enum class MemoryCondition : int { | 39 enum class MemoryCondition : int { |
| 40 NORMAL = 0, | 40 NORMAL = 0, |
| 41 WARNING = 1, | 41 CRITICAL = 1, |
| 42 CRITICAL = 2, | |
| 43 }; | 42 }; |
| 44 | 43 |
| 45 // MemoryCoordinatorImpl is an implementation of MemoryCoordinator. | 44 // MemoryCoordinatorImpl is an implementation of MemoryCoordinator. |
| 46 class CONTENT_EXPORT MemoryCoordinatorImpl : public base::MemoryCoordinator, | 45 class CONTENT_EXPORT MemoryCoordinatorImpl : public base::MemoryCoordinator, |
| 47 public MemoryCoordinator, | 46 public MemoryCoordinator, |
| 48 public NotificationObserver { | 47 public NotificationObserver { |
| 49 public: | 48 public: |
| 50 static MemoryCoordinatorImpl* GetInstance(); | 49 static MemoryCoordinatorImpl* GetInstance(); |
| 51 | 50 |
| 52 // A policy determines what actions (e.g. purging memory from a process) | 51 // A policy determines what actions (e.g. purging memory from a process) |
| 53 // MemoryCoordinator takes on various events. | 52 // MemoryCoordinator takes on various events. |
| 54 class Policy { | 53 class Policy { |
| 55 public: | 54 public: |
| 56 virtual ~Policy() {} | 55 virtual ~Policy() {} |
| 57 | 56 |
| 58 // Called periodically while the memory condition is WARNING. | |
| 59 virtual void OnWarningCondition() {} | |
| 60 // Called periodically while the memory condition is CRITICAL. | 57 // Called periodically while the memory condition is CRITICAL. |
| 61 virtual void OnCriticalCondition() {} | 58 virtual void OnCriticalCondition() {} |
| 62 // Called when the current MemoryCondition has changed. | 59 // Called when the current MemoryCondition has changed. |
| 63 virtual void OnConditionChanged(MemoryCondition prev, | 60 virtual void OnConditionChanged(MemoryCondition prev, |
| 64 MemoryCondition next) {} | 61 MemoryCondition next) {} |
| 65 // Called when the visibility of a child process has changed. | 62 // Called when the visibility of a child process has changed. |
| 66 virtual void OnChildVisibilityChanged(int render_process_id, | 63 virtual void OnChildVisibilityChanged(int render_process_id, |
| 67 bool is_visible) {} | 64 bool is_visible) {} |
| 68 }; | 65 }; |
| 69 | 66 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 ChildInfoMap children_; | 246 ChildInfoMap children_; |
| 250 | 247 |
| 251 SEQUENCE_CHECKER(sequence_checker_); | 248 SEQUENCE_CHECKER(sequence_checker_); |
| 252 | 249 |
| 253 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorImpl); | 250 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorImpl); |
| 254 }; | 251 }; |
| 255 | 252 |
| 256 } // namespace content | 253 } // namespace content |
| 257 | 254 |
| 258 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ | 255 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ |
| OLD | NEW |