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

Unified Diff: content/browser/memory/memory_coordinator.cc

Issue 2552603002: Add tests for MemoryCoordinator::Can{Throttle,Suspend}Renderer() (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 side-by-side diff with in-line comments
Download patch
Index: content/browser/memory/memory_coordinator.cc
diff --git a/content/browser/memory/memory_coordinator.cc b/content/browser/memory/memory_coordinator.cc
index dc9d0a9789e7b4b68650a9ba6cf815bb90ab59ac..6de5c0ca688b1d10772033751d8973d96459278d 100644
--- a/content/browser/memory/memory_coordinator.cc
+++ b/content/browser/memory/memory_coordinator.cc
@@ -73,10 +73,6 @@ void MemoryCoordinator::CreateHandle(
CreateChildInfoMapEntry(render_process_id, std::move(handle));
}
-size_t MemoryCoordinator::NumChildrenForTesting() {
- return children_.size();
-}
-
bool MemoryCoordinator::SetChildMemoryState(int render_process_id,
mojom::MemoryState memory_state) {
// Can't set an invalid memory state.
@@ -168,7 +164,8 @@ void MemoryCoordinator::OnConnectionError(int render_process_id) {
}
bool MemoryCoordinator::CanThrottleRenderer(int render_process_id) {
- // If there is no delegate (i.e. tests), renderers are always throttleable.
+ // If there is no delegate (i.e. unittests), renderers are always
+ // throttleable.
// TODO(bashi): We check |delegate_| to avoid calling FromID() on a
// wrong thread in tests. Figure out a better way to handle tests.
if (!delegate_)
@@ -178,7 +175,7 @@ bool MemoryCoordinator::CanThrottleRenderer(int render_process_id) {
}
bool MemoryCoordinator::CanSuspendRenderer(int render_process_id) {
- // If there is no delegate (i.e. tests), renderers are always suspendable.
+ // If there is no delegate (i.e. unittests), renderers are always suspendable.
if (!delegate_)
return true;
auto* render_process_host = RenderProcessHost::FromID(render_process_id);
@@ -187,6 +184,12 @@ bool MemoryCoordinator::CanSuspendRenderer(int render_process_id) {
return delegate_->CanSuspendBackgroundedRenderer(render_process_id);
}
+void MemoryCoordinator::SetDelegateForTesting(
+ std::unique_ptr<MemoryCoordinatorDelegate> delegate) {
+ CHECK(!delegate_);
+ delegate_ = std::move(delegate);
+}
+
void MemoryCoordinator::CreateChildInfoMapEntry(
int render_process_id,
std::unique_ptr<MemoryCoordinatorHandleImpl> handle) {

Powered by Google App Engine
This is Rietveld 408576698