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

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

Issue 2569963002: MemoryCoordinator checks if ServiceWorker exists on the suspending process (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 #include "content/browser/memory/memory_coordinator.h" 5 #include "content/browser/memory/memory_coordinator.h"
6 6
7 #include "base/memory/memory_coordinator_client_registry.h" 7 #include "base/memory/memory_coordinator_client_registry.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "content/public/browser/content_browser_client.h" 9 #include "content/public/browser/content_browser_client.h"
10 #include "content/public/browser/render_process_host.h" 10 #include "content/public/browser/render_process_host.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 children_.erase(render_process_id); 160 children_.erase(render_process_id);
161 } 161 }
162 162
163 bool MemoryCoordinator::CanSuspendRenderer(int render_process_id) { 163 bool MemoryCoordinator::CanSuspendRenderer(int render_process_id) {
164 // If there is no delegate (i.e. unittests), renderers are always suspendable. 164 // If there is no delegate (i.e. unittests), renderers are always suspendable.
165 if (!delegate_) 165 if (!delegate_)
166 return true; 166 return true;
167 auto* render_process_host = RenderProcessHost::FromID(render_process_id); 167 auto* render_process_host = RenderProcessHost::FromID(render_process_id);
168 if (!render_process_host || !render_process_host->IsProcessBackgrounded()) 168 if (!render_process_host || !render_process_host->IsProcessBackgrounded())
169 return false; 169 return false;
170 if (render_process_host->GetWorkerRefCount() > 0)
171 return false;
170 return delegate_->CanSuspendBackgroundedRenderer(render_process_id); 172 return delegate_->CanSuspendBackgroundedRenderer(render_process_id);
171 } 173 }
172 174
173 mojom::MemoryState MemoryCoordinator::OverrideGlobalState( 175 mojom::MemoryState MemoryCoordinator::OverrideGlobalState(
174 mojom::MemoryState memory_state, 176 mojom::MemoryState memory_state,
175 const ChildInfo& child) { 177 const ChildInfo& child) {
176 // We don't suspend foreground renderers. Throttle them instead. 178 // We don't suspend foreground renderers. Throttle them instead.
177 if (child.is_visible && memory_state == mojom::MemoryState::SUSPENDED) 179 if (child.is_visible && memory_state == mojom::MemoryState::SUSPENDED)
178 return mojom::MemoryState::THROTTLED; 180 return mojom::MemoryState::THROTTLED;
179 #if defined(OS_ANDROID) 181 #if defined(OS_ANDROID)
(...skipping 28 matching lines...) Expand all
208 210
209 MemoryCoordinator::ChildInfo::ChildInfo() {} 211 MemoryCoordinator::ChildInfo::ChildInfo() {}
210 212
211 MemoryCoordinator::ChildInfo::ChildInfo(const ChildInfo& rhs) { 213 MemoryCoordinator::ChildInfo::ChildInfo(const ChildInfo& rhs) {
212 // This is a nop, but exists for compatibility with STL containers. 214 // This is a nop, but exists for compatibility with STL containers.
213 } 215 }
214 216
215 MemoryCoordinator::ChildInfo::~ChildInfo() {} 217 MemoryCoordinator::ChildInfo::~ChildInfo() {}
216 218
217 } // namespace content 219 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698