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

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

Issue 2564623004: memory coordinator: Throttle background renderers on Android (Closed)
Patch Set: naming 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
« no previous file with comments | « content/browser/memory/memory_coordinator.h ('k') | content/browser/memory/memory_coordinator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/memory/memory_coordinator.cc
diff --git a/content/browser/memory/memory_coordinator.cc b/content/browser/memory/memory_coordinator.cc
index 5bf29c78e1d6afbb11fe113de6507c3193f24188..b691322002007921695018b1e3ae16c69fec041d 100644
--- a/content/browser/memory/memory_coordinator.cc
+++ b/content/browser/memory/memory_coordinator.cc
@@ -88,10 +88,7 @@ bool MemoryCoordinator::SetChildMemoryState(int render_process_id,
if (!iter->second.handle->child().is_bound())
return false;
- // We don't suspend foreground renderers. Throttle them instead.
- if (memory_state == mojom::MemoryState::SUSPENDED &&
- iter->second.is_visible)
- memory_state = mojom::MemoryState::THROTTLED;
+ memory_state = OverrideGlobalState(memory_state, iter->second);
// A nop doesn't need to be sent, but is considered successful.
if (iter->second.memory_state == memory_state)
@@ -173,6 +170,23 @@ bool MemoryCoordinator::CanSuspendRenderer(int render_process_id) {
return delegate_->CanSuspendBackgroundedRenderer(render_process_id);
}
+mojom::MemoryState MemoryCoordinator::OverrideGlobalState(
+ mojom::MemoryState memory_state,
+ const ChildInfo& child) {
+ // We don't suspend foreground renderers. Throttle them instead.
+ if (child.is_visible && memory_state == mojom::MemoryState::SUSPENDED)
+ return mojom::MemoryState::THROTTLED;
+#if defined(OS_ANDROID)
+ // On Android, we throttle background renderers immediately.
+ // TODO(bashi): Create a specialized class of MemoryCoordinator for Android
+ // and move this ifdef to the class.
+ if (!child.is_visible && memory_state == mojom::MemoryState::NORMAL)
+ return mojom::MemoryState::THROTTLED;
+ // TODO(bashi): Suspend background renderers after a certain period of time.
+#endif // defined(OS_ANDROID)
+ return memory_state;
+}
+
void MemoryCoordinator::SetDelegateForTesting(
std::unique_ptr<MemoryCoordinatorDelegate> delegate) {
CHECK(!delegate_);
« no previous file with comments | « content/browser/memory/memory_coordinator.h ('k') | content/browser/memory/memory_coordinator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698