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_coordinator_proxy.h" | |
9 #include "base/memory/memory_pressure_monitor.h" | 10 #include "base/memory/memory_pressure_monitor.h" |
10 #include "base/process/process_handle.h" | 11 #include "base/process/process_handle.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. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 // TODO(bashi): Remove this when MemoryPressureMonitor is retired. | 53 // TODO(bashi): Remove this when MemoryPressureMonitor is retired. |
53 void RecordMemoryPressure( | 54 void RecordMemoryPressure( |
54 base::MemoryPressureMonitor::MemoryPressureLevel level); | 55 base::MemoryPressureMonitor::MemoryPressureLevel level); |
55 | 56 |
56 // Called when ChildMemoryCoordinator calls AddChild(). | 57 // Called when ChildMemoryCoordinator calls AddChild(). |
57 virtual void OnChildAdded(int render_process_id) {} | 58 virtual void OnChildAdded(int render_process_id) {} |
58 | 59 |
59 // Returns the global memory state. | 60 // Returns the global memory state. |
60 virtual base::MemoryState GetGlobalMemoryState() const; | 61 virtual base::MemoryState GetGlobalMemoryState() const; |
61 | 62 |
62 // Returns the browser's current memory state. Note that the current state | 63 virtual base::WeakPtr<base::MemoryCoordinatorInterface> GetWeakPtr(); |
chrisha
2016/12/13 15:42:47
Maybe call this GetBaseMemoryCoordinator?
GetWeak
| |
63 // could be different from the global memory state as the browser won't be | |
64 // suspended. | |
65 virtual base::MemoryState GetCurrentMemoryState() const; | |
66 | |
67 // Sets the global memory state for testing. | |
68 virtual void SetCurrentMemoryStateForTesting(base::MemoryState memory_state); | |
69 | 64 |
70 protected: | 65 protected: |
71 // Constructor. Protected as this is a singleton, but accessible for | 66 // Constructor. Protected as this is a singleton, but accessible for |
72 // unittests. | 67 // unittests. |
73 MemoryCoordinator(); | 68 MemoryCoordinator(); |
74 | 69 |
75 // Adds the given ChildMemoryCoordinator as a child of this coordinator. | 70 // Adds the given ChildMemoryCoordinator as a child of this coordinator. |
76 void AddChildForTesting(int dummy_render_process_id, | 71 void AddChildForTesting(int dummy_render_process_id, |
77 mojom::ChildMemoryCoordinatorPtr child); | 72 mojom::ChildMemoryCoordinatorPtr child); |
78 | 73 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 ChildInfoMap children_; | 124 ChildInfoMap children_; |
130 | 125 |
131 std::unique_ptr<MemoryCoordinatorDelegate> delegate_; | 126 std::unique_ptr<MemoryCoordinatorDelegate> delegate_; |
132 | 127 |
133 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinator); | 128 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinator); |
134 }; | 129 }; |
135 | 130 |
136 } // namespace content | 131 } // namespace content |
137 | 132 |
138 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_ | 133 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_ |
OLD | NEW |