Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: content/browser/memory/memory_coordinator.h

Issue 2564623004: memory coordinator: Throttle background renderers on Android (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_pressure_monitor.h" 9 #include "base/memory/memory_pressure_monitor.h"
10 #include "base/process/process_handle.h" 10 #include "base/process/process_handle.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 mojom::MemoryState memory_state; 93 mojom::MemoryState memory_state;
94 bool is_visible = false; 94 bool is_visible = false;
95 std::unique_ptr<MemoryCoordinatorHandleImpl> handle; 95 std::unique_ptr<MemoryCoordinatorHandleImpl> handle;
96 }; 96 };
97 97
98 // A map from process ID (RenderProcessHost::GetID()) to child process info. 98 // A map from process ID (RenderProcessHost::GetID()) to child process info.
99 using ChildInfoMap = std::map<int, ChildInfo>; 99 using ChildInfoMap = std::map<int, ChildInfo>;
100 100
101 ChildInfoMap& children() { return children_; } 101 ChildInfoMap& children() { return children_; }
102 102
103 private: 103 private:
104 #if !defined(OS_MACOSX) 104 #if !defined(OS_MACOSX)
105 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorTest, HandleAdded); 105 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorTest, HandleAdded);
106 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorTest, CanSuspendRenderer); 106 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorTest, CanSuspendRenderer);
107 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorTest, CanThrottleRenderer); 107 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorTest, CanThrottleRenderer);
108 #endif 108 #endif
109 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorTest, 109 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorTest,
110 ChildRemovedOnConnectionError); 110 ChildRemovedOnConnectionError);
111 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorTest, SetChildMemoryState);
112
113 // Called by SetChildMemoryState() to determine a child memory state based on
114 // the current status of the child process.
115 mojom::MemoryState OverrideChildState(mojom::MemoryState memroy_state,
116 const ChildInfo& child);
111 117
112 void SetDelegateForTesting( 118 void SetDelegateForTesting(
113 std::unique_ptr<MemoryCoordinatorDelegate> delegate); 119 std::unique_ptr<MemoryCoordinatorDelegate> delegate);
114 120
115 // Helper function of CreateHandle and AddChildForTesting. 121 // Helper function of CreateHandle and AddChildForTesting.
116 void CreateChildInfoMapEntry( 122 void CreateChildInfoMapEntry(
117 int render_process_id, 123 int render_process_id,
118 std::unique_ptr<MemoryCoordinatorHandleImpl> handle); 124 std::unique_ptr<MemoryCoordinatorHandleImpl> handle);
119 125
120 // Tracks child processes. An entry is added when a renderer connects to 126 // Tracks child processes. An entry is added when a renderer connects to
121 // MemoryCoordinator and removed automatically when an underlying binding is 127 // MemoryCoordinator and removed automatically when an underlying binding is
122 // disconnected. 128 // disconnected.
123 ChildInfoMap children_; 129 ChildInfoMap children_;
124 130
125 std::unique_ptr<MemoryCoordinatorDelegate> delegate_; 131 std::unique_ptr<MemoryCoordinatorDelegate> delegate_;
126 132
127 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinator); 133 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinator);
128 }; 134 };
129 135
130 } // namespace content 136 } // namespace content
131 137
132 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_ 138 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/memory/memory_coordinator.cc » ('j') | content/browser/memory/memory_coordinator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698