| 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_H_ | 5 #ifndef CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_ |
| 6 #define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_ | 6 #define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_ |
| 7 | 7 |
| 8 #include "base/memory/memory_coordinator_client_registry.h" | 8 #include "base/memory/memory_coordinator_client_registry.h" |
| 9 #include "base/memory/memory_pressure_monitor.h" | 9 #include "base/memory/memory_pressure_monitor.h" |
| 10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 mojom::MemoryState GetChildMemoryState(int render_process_id) const; | 52 mojom::MemoryState GetChildMemoryState(int render_process_id) const; |
| 53 | 53 |
| 54 // Records memory pressure notifications. Called by MemoryPressureMonitor. | 54 // Records memory pressure notifications. Called by MemoryPressureMonitor. |
| 55 // TODO(bashi): Remove this when MemoryPressureMonitor is retired. | 55 // TODO(bashi): Remove this when MemoryPressureMonitor is retired. |
| 56 void RecordMemoryPressure( | 56 void RecordMemoryPressure( |
| 57 base::MemoryPressureMonitor::MemoryPressureLevel level); | 57 base::MemoryPressureMonitor::MemoryPressureLevel level); |
| 58 | 58 |
| 59 // Called when ChildMemoryCoordinator calls AddChild(). | 59 // Called when ChildMemoryCoordinator calls AddChild(). |
| 60 virtual void OnChildAdded(int render_process_id) {} | 60 virtual void OnChildAdded(int render_process_id) {} |
| 61 | 61 |
| 62 // Returns the global memory state. |
| 63 virtual base::MemoryState GetGlobalMemoryState() const; |
| 64 |
| 65 // Returns the browser's current memory state. Note that the current state |
| 66 // could be different from the global memory state as the browser won't be |
| 67 // suspended. |
| 62 virtual base::MemoryState GetCurrentMemoryState() const; | 68 virtual base::MemoryState GetCurrentMemoryState() const; |
| 69 |
| 70 // Sets the global memory state for testing. |
| 63 virtual void SetCurrentMemoryStateForTesting(base::MemoryState memory_state); | 71 virtual void SetCurrentMemoryStateForTesting(base::MemoryState memory_state); |
| 64 | 72 |
| 65 protected: | 73 protected: |
| 66 // Constructor. Protected as this is a singleton, but accessible for | 74 // Constructor. Protected as this is a singleton, but accessible for |
| 67 // unittests. | 75 // unittests. |
| 68 MemoryCoordinator(); | 76 MemoryCoordinator(); |
| 69 | 77 |
| 70 // Adds the given ChildMemoryCoordinator as a child of this coordinator. | 78 // Adds the given ChildMemoryCoordinator as a child of this coordinator. |
| 71 void AddChildForTesting(int dummy_render_process_id, | 79 void AddChildForTesting(int dummy_render_process_id, |
| 72 mojom::ChildMemoryCoordinatorPtr child); | 80 mojom::ChildMemoryCoordinatorPtr child); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 ChildInfoMap children_; | 117 ChildInfoMap children_; |
| 110 | 118 |
| 111 std::unique_ptr<MemoryCoordinatorDelegate> delegate_; | 119 std::unique_ptr<MemoryCoordinatorDelegate> delegate_; |
| 112 | 120 |
| 113 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinator); | 121 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinator); |
| 114 }; | 122 }; |
| 115 | 123 |
| 116 } // namespace content | 124 } // namespace content |
| 117 | 125 |
| 118 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_ | 126 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_ |
| OLD | NEW |