| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // Overrides the global state to |new_state|. State update tasks won't be | 62 // 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 | 63 // 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. | 64 // remains the same until |duration| is passed or another call of this method. |
| 65 void ForceSetGlobalState(base::MemoryState new_state, | 65 void ForceSetGlobalState(base::MemoryState new_state, |
| 66 base::TimeDelta duration); | 66 base::TimeDelta duration); |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, CalculateNextState); | 69 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, CalculateNextState); |
| 70 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, UpdateState); | 70 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, UpdateState); |
| 71 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, SetMemoryStateForTesting); | 71 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, SetMemoryStateForTesting); |
| 72 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, ForceSetGlobalState); |
| 72 | 73 |
| 73 friend struct MemoryCoordinatorSingletonTraits; | 74 friend struct MemoryCoordinatorSingletonTraits; |
| 74 | 75 |
| 75 using MemoryState = base::MemoryState; | 76 using MemoryState = base::MemoryState; |
| 76 | 77 |
| 77 // Changes the global state and notifies state changes to clients (lives in | 78 // Changes the global state and notifies state changes to clients (lives in |
| 78 // the browser) and child processes (renderers) if needed. Returns true when | 79 // the browser) and child processes (renderers) if needed. Returns true when |
| 79 // the state is actually changed. | 80 // the state is actually changed. |
| 80 bool ChangeStateIfNeeded(MemoryState prev_state, MemoryState next_state); | 81 bool ChangeStateIfNeeded(MemoryState prev_state, MemoryState next_state); |
| 81 | 82 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 base::TimeDelta monitoring_interval_; | 143 base::TimeDelta monitoring_interval_; |
| 143 | 144 |
| 144 base::WeakPtrFactory<MemoryCoordinatorImpl> weak_ptr_factory_; | 145 base::WeakPtrFactory<MemoryCoordinatorImpl> weak_ptr_factory_; |
| 145 | 146 |
| 146 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorImpl); | 147 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorImpl); |
| 147 }; | 148 }; |
| 148 | 149 |
| 149 } // namespace content | 150 } // namespace content |
| 150 | 151 |
| 151 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ | 152 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ |
| OLD | NEW |