| 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" |
| 11 #include "base/time/time.h" |
| 11 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 12 #include "content/common/memory_coordinator.mojom.h" | 13 #include "content/common/memory_coordinator.mojom.h" |
| 13 #include "content/public/browser/memory_coordinator_delegate.h" | 14 #include "content/public/browser/memory_coordinator_delegate.h" |
| 14 #include "mojo/public/cpp/bindings/binding.h" | 15 #include "mojo/public/cpp/bindings/binding.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 // NOTE: Memory coordinator is under development and not fully working. | 19 // NOTE: Memory coordinator is under development and not fully working. |
| 19 // TODO(bashi): Add more explanations when we implement memory coordinator V0. | 20 // TODO(bashi): Add more explanations when we implement memory coordinator V0. |
| 20 | 21 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 49 | 50 |
| 50 // Returns the memory state of the specified render process. Returns UNKNOWN | 51 // Returns the memory state of the specified render process. Returns UNKNOWN |
| 51 // if the process is not tracked by this coordinator. | 52 // if the process is not tracked by this coordinator. |
| 52 mojom::MemoryState GetChildMemoryState(int render_process_id) const; | 53 mojom::MemoryState GetChildMemoryState(int render_process_id) const; |
| 53 | 54 |
| 54 // Records memory pressure notifications. Called by MemoryPressureMonitor. | 55 // Records memory pressure notifications. Called by MemoryPressureMonitor. |
| 55 // TODO(bashi): Remove this when MemoryPressureMonitor is retired. | 56 // TODO(bashi): Remove this when MemoryPressureMonitor is retired. |
| 56 void RecordMemoryPressure( | 57 void RecordMemoryPressure( |
| 57 base::MemoryPressureMonitor::MemoryPressureLevel level); | 58 base::MemoryPressureMonitor::MemoryPressureLevel level); |
| 58 | 59 |
| 60 // Returns the interval between memory checks. |
| 61 virtual base::TimeDelta GetMonitoringInterval() const; |
| 62 |
| 59 // Called when ChildMemoryCoordinator calls AddChild(). | 63 // Called when ChildMemoryCoordinator calls AddChild(). |
| 60 virtual void OnChildAdded(int render_process_id) {} | 64 virtual void OnChildAdded(int render_process_id) {} |
| 61 | 65 |
| 62 virtual base::MemoryState GetCurrentMemoryState() const; | 66 virtual base::MemoryState GetCurrentMemoryState() const; |
| 63 virtual void SetCurrentMemoryStateForTesting(base::MemoryState memory_state); | 67 virtual void SetCurrentMemoryStateForTesting(base::MemoryState memory_state); |
| 64 | 68 |
| 65 protected: | 69 protected: |
| 66 // Constructor. Protected as this is a singleton, but accessible for | 70 // Constructor. Protected as this is a singleton, but accessible for |
| 67 // unittests. | 71 // unittests. |
| 68 MemoryCoordinator(); | 72 MemoryCoordinator(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 ChildInfoMap children_; | 113 ChildInfoMap children_; |
| 110 | 114 |
| 111 std::unique_ptr<MemoryCoordinatorDelegate> delegate_; | 115 std::unique_ptr<MemoryCoordinatorDelegate> delegate_; |
| 112 | 116 |
| 113 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinator); | 117 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinator); |
| 114 }; | 118 }; |
| 115 | 119 |
| 116 } // namespace content | 120 } // namespace content |
| 117 | 121 |
| 118 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_ | 122 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_ |
| OLD | NEW |