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/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
29 // | 29 // |
30 // State calculation: | 30 // State calculation: |
31 // MemoryCoordinatorImpl uses followings to determine the global state: | 31 // MemoryCoordinatorImpl uses followings to determine the global state: |
32 // * Compute "number of renderers which can be created until the system will | 32 // * Compute "number of renderers which can be created until the system will |
33 // be in a critical state". Call this N. | 33 // be in a critical state". Call this N. |
34 // (See memory_monitor.h for the definition of "critical") | 34 // (See memory_monitor.h for the definition of "critical") |
35 // * Covert N to a memory state using some thresholds/hysteresis for each state. | 35 // * Covert N to a memory state using some thresholds/hysteresis for each state. |
36 // Once a state is changed to a limited state, larger N will be needed to go | 36 // Once a state is changed to a limited state, larger N will be needed to go |
37 // back to a relaxed state. (e.g. THROTTLED -> NORMAL) | 37 // back to a relaxed state. (e.g. THROTTLED -> NORMAL) |
38 // * Once a state is changed, it remains the same for a certain period of time. | 38 // * Once a state is changed, it remains the same for a certain period of time. |
39 class CONTENT_EXPORT MemoryCoordinatorImpl : public MemoryCoordinator, | 39 class CONTENT_EXPORT MemoryCoordinatorImpl |
40 public NotificationObserver, | 40 : public MemoryCoordinator, |
41 public base::NonThreadSafe { | 41 public NotificationObserver, |
42 public base::MemoryCoordinatorInterface, | |
chrisha
2016/12/13 15:42:47
I'm not sure we need multiple inheritance here.
R
| |
43 public base::NonThreadSafe { | |
42 public: | 44 public: |
43 MemoryCoordinatorImpl(scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 45 MemoryCoordinatorImpl(scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
44 std::unique_ptr<MemoryMonitor> monitor); | 46 std::unique_ptr<MemoryMonitor> monitor); |
45 ~MemoryCoordinatorImpl() override; | 47 ~MemoryCoordinatorImpl() override; |
46 | 48 |
49 MemoryMonitor* memory_monitor() { return memory_monitor_.get(); } | |
50 | |
47 // MemoryCoordinator implementations: | 51 // MemoryCoordinator implementations: |
48 void Start() override; | 52 void Start() override; |
49 void OnChildAdded(int render_process_id) override; | 53 void OnChildAdded(int render_process_id) override; |
50 | 54 |
51 MemoryMonitor* memory_monitor() { return memory_monitor_.get(); } | 55 base::MemoryState GetGlobalMemoryState() const override; |
52 | 56 |
53 base::MemoryState GetGlobalMemoryState() const override; | 57 base::WeakPtr<base::MemoryCoordinatorInterface> GetWeakPtr() override; |
54 base::MemoryState GetCurrentMemoryState() const override; | 58 |
55 void SetCurrentMemoryStateForTesting(base::MemoryState memory_state) override; | 59 // base::MemoryCoordinatorInterface implementations: |
60 base::MemoryState GetLocalMemoryState() override; | |
61 void SetMemoryStateForTesting(base::MemoryState state) override; | |
56 | 62 |
57 // NotificationObserver implementation: | 63 // NotificationObserver implementation: |
58 void Observe(int type, | 64 void Observe(int type, |
59 const NotificationSource& source, | 65 const NotificationSource& source, |
60 const NotificationDetails& details) override; | 66 const NotificationDetails& details) override; |
61 | 67 |
62 // Overrides the global state to |new_state|. State update tasks won't be | 68 // Overrides the global state to |new_state|. State update tasks won't be |
63 // scheduled until |duration| is passed. This means that the global state | 69 // scheduled until |duration| is passed. This means that the global state |
64 // remains the same until |duration| is passed or another call of this method. | 70 // remains the same until |duration| is passed or another call of this method. |
65 void ForceSetGlobalState(base::MemoryState new_state, | 71 void ForceSetGlobalState(base::MemoryState new_state, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 base::TimeDelta monitoring_interval_; | 149 base::TimeDelta monitoring_interval_; |
144 | 150 |
145 base::WeakPtrFactory<MemoryCoordinatorImpl> weak_ptr_factory_; | 151 base::WeakPtrFactory<MemoryCoordinatorImpl> weak_ptr_factory_; |
146 | 152 |
147 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorImpl); | 153 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorImpl); |
148 }; | 154 }; |
149 | 155 |
150 } // namespace content | 156 } // namespace content |
151 | 157 |
152 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ | 158 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ |
OLD | NEW |