| 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 29 matching lines...) Expand all Loading... |
| 40 MemoryCoordinatorImpl(scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 40 MemoryCoordinatorImpl(scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 41 std::unique_ptr<MemoryMonitor> monitor); | 41 std::unique_ptr<MemoryMonitor> monitor); |
| 42 ~MemoryCoordinatorImpl() override; | 42 ~MemoryCoordinatorImpl() override; |
| 43 | 43 |
| 44 // MemoryCoordinator implementations: | 44 // MemoryCoordinator implementations: |
| 45 void Start() override; | 45 void Start() override; |
| 46 void OnChildAdded(int render_process_id) override; | 46 void OnChildAdded(int render_process_id) override; |
| 47 | 47 |
| 48 MemoryMonitor* memory_monitor() { return memory_monitor_.get(); } | 48 MemoryMonitor* memory_monitor() { return memory_monitor_.get(); } |
| 49 | 49 |
| 50 base::MemoryState GetCurrentMemoryState() const override; |
| 51 |
| 50 private: | 52 private: |
| 51 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, CalculateNextState); | 53 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, CalculateNextState); |
| 52 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, UpdateState); | 54 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, UpdateState); |
| 53 | 55 |
| 54 friend struct MemoryCoordinatorSingletonTraits; | 56 friend struct MemoryCoordinatorSingletonTraits; |
| 55 | 57 |
| 56 using MemoryState = base::MemoryState; | 58 using MemoryState = base::MemoryState; |
| 57 | 59 |
| 58 // Calculates the next global state from the amount of free memory using | 60 // Calculates the next global state from the amount of free memory using |
| 59 // a heuristic. | 61 // a heuristic. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 base::TimeDelta monitoring_interval_; | 112 base::TimeDelta monitoring_interval_; |
| 111 | 113 |
| 112 base::WeakPtrFactory<MemoryCoordinatorImpl> weak_ptr_factory_; | 114 base::WeakPtrFactory<MemoryCoordinatorImpl> weak_ptr_factory_; |
| 113 | 115 |
| 114 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorImpl); | 116 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorImpl); |
| 115 }; | 117 }; |
| 116 | 118 |
| 117 } // namespace content | 119 } // namespace content |
| 118 | 120 |
| 119 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ | 121 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ |
| OLD | NEW |