OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_DEFAULT_POLICY_H_ | 5 #ifndef CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_DEFAULT_POLICY_H_ |
6 #define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_DEFAULT_POLICY_H_ | 6 #define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_DEFAULT_POLICY_H_ |
7 | 7 |
8 #include "content/browser/memory/memory_coordinator_impl.h" | 8 #include "content/browser/memory/memory_coordinator_impl.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 // The default policy of MemoryCoordinator. | 12 // The default policy of MemoryCoordinator. |
13 class MemoryCoordinatorDefaultPolicy : public MemoryCoordinatorImpl::Policy { | 13 class MemoryCoordinatorDefaultPolicy : public MemoryCoordinatorImpl::Policy { |
14 public: | 14 public: |
15 explicit MemoryCoordinatorDefaultPolicy(MemoryCoordinatorImpl* coordinator); | 15 explicit MemoryCoordinatorDefaultPolicy(MemoryCoordinatorImpl* coordinator); |
16 ~MemoryCoordinatorDefaultPolicy() override; | 16 ~MemoryCoordinatorDefaultPolicy() override; |
17 | 17 |
18 void OnWarningCondition() override; | |
19 void OnCriticalCondition() override; | 18 void OnCriticalCondition() override; |
20 void OnConditionChanged(MemoryCondition prev, MemoryCondition next) override; | 19 void OnConditionChanged(MemoryCondition prev, MemoryCondition next) override; |
21 void OnChildVisibilityChanged(int render_process_id, | 20 void OnChildVisibilityChanged(int render_process_id, |
22 bool is_visible) override; | 21 bool is_visible) override; |
23 | 22 |
24 private: | 23 private: |
25 // Set the provided memory_state to all child processes. | 24 // Set the provided memory_state to all child processes. |
26 void SetMemoryStateToAllChildren(MemoryState memory_state); | 25 void SetMemoryStateToAllChildren(MemoryState memory_state); |
27 | 26 |
28 enum class PurgeTarget { | 27 enum class PurgeTarget { |
29 BACKGROUNDED, | 28 BACKGROUNDED, |
30 ALL, | 29 ALL, |
31 }; | 30 }; |
32 | 31 |
33 // Tries to find a candidate child process for purging memory and asks the | 32 // Tries to find a candidate child process for purging memory and asks the |
34 // child to purge memory. | 33 // child to purge memory. |
35 bool TryToPurgeMemoryFromChildren(PurgeTarget target); | 34 bool TryToPurgeMemoryFromChildren(PurgeTarget target); |
36 | 35 |
37 // Not owned. | 36 // Not owned. |
38 MemoryCoordinatorImpl* coordinator_; | 37 MemoryCoordinatorImpl* coordinator_; |
39 }; | 38 }; |
40 | 39 |
41 } // namespace content | 40 } // namespace content |
42 | 41 |
43 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_DEFAULT_POLICY_H_ | 42 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_DEFAULT_POLICY_H_ |
OLD | NEW |