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

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 2624063002: Stop suspending renderer and changing purge interval to 20min (Closed)
Patch Set: Fixed unit_tests failure. Created 3 years, 11 months 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 2251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2262 void RenderThreadImpl::OnMemoryStateChange(base::MemoryState state) { 2262 void RenderThreadImpl::OnMemoryStateChange(base::MemoryState state) {
2263 // TODO(hajimehoshi): Adjust the size of this memory usage according to 2263 // TODO(hajimehoshi): Adjust the size of this memory usage according to
2264 // |state|. RenderThreadImpl doesn't have a feature to limit memory usage at 2264 // |state|. RenderThreadImpl doesn't have a feature to limit memory usage at
2265 // present. 2265 // present.
2266 if (blink_platform_impl_) { 2266 if (blink_platform_impl_) {
2267 blink::WebMemoryCoordinator::onMemoryStateChange( 2267 blink::WebMemoryCoordinator::onMemoryStateChange(
2268 static_cast<blink::MemoryState>(state)); 2268 static_cast<blink::MemoryState>(state));
2269 } 2269 }
2270 switch (state) { 2270 switch (state) {
2271 case base::MemoryState::NORMAL: 2271 case base::MemoryState::NORMAL:
2272 ResumeRenderer();
2273 break; 2272 break;
2274 case base::MemoryState::THROTTLED: 2273 case base::MemoryState::THROTTLED:
2275 ResumeRenderer();
2276 // TODO(bashi): Figure out what kind of strategy is suitable on 2274 // TODO(bashi): Figure out what kind of strategy is suitable on
2277 // THROTTLED state. crbug.com/674815 2275 // THROTTLED state. crbug.com/674815
2278 #if defined(OS_ANDROID) 2276 #if defined(OS_ANDROID)
2279 OnTrimMemoryImmediately(); 2277 OnTrimMemoryImmediately();
2280 #else 2278 #else
2281 OnSyncMemoryPressure( 2279 OnSyncMemoryPressure(
2282 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE); 2280 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE);
2283 #endif 2281 #endif
2284 ReleaseFreeMemory(); 2282 ReleaseFreeMemory();
2285 break; 2283 break;
2286 case base::MemoryState::SUSPENDED: 2284 case base::MemoryState::SUSPENDED:
2287 SuspendRenderer(); 2285 OnTrimMemoryImmediately();
2286 ReleaseFreeMemory();
2287 ClearMemory();
2288 break; 2288 break;
2289 case base::MemoryState::UNKNOWN: 2289 case base::MemoryState::UNKNOWN:
2290 NOTREACHED(); 2290 NOTREACHED();
2291 break; 2291 break;
2292 } 2292 }
2293 } 2293 }
2294 2294
2295 void RenderThreadImpl::SuspendRenderer() {
2296 DCHECK(IsMainThread());
2297 OnTrimMemoryImmediately();
2298 ReleaseFreeMemory();
2299 ClearMemory();
2300 // TODO(bashi): Enable the tab suspension when MemoryCoordinator is enabled.
2301 if (!base::FeatureList::IsEnabled(features::kMemoryCoordinator) &&
2302 base::FeatureList::IsEnabled(features::kPurgeAndSuspend))
2303 renderer_scheduler_->SuspendRenderer();
2304 }
2305
2306 void RenderThreadImpl::ResumeRenderer() {
2307 DCHECK(IsMainThread());
2308 // TODO(bashi): Enable the tab suspension when MemoryCoordinator is enabled.
2309 if (!base::FeatureList::IsEnabled(features::kMemoryCoordinator) &&
2310 base::FeatureList::IsEnabled(features::kPurgeAndSuspend))
2311 renderer_scheduler_->ResumeRenderer();
2312 }
2313
2314 void RenderThreadImpl::ClearMemory() { 2295 void RenderThreadImpl::ClearMemory() {
2315 // Do not call into blink if it is not initialized. 2296 // Do not call into blink if it is not initialized.
2316 if (blink_platform_impl_) { 2297 if (blink_platform_impl_) {
2317 // Purge Skia font cache, by setting it to 0 and then again to the 2298 // Purge Skia font cache, by setting it to 0 and then again to the
2318 // previous limit. 2299 // previous limit.
2319 size_t font_cache_limit = SkGraphics::SetFontCacheLimit(0); 2300 size_t font_cache_limit = SkGraphics::SetFontCacheLimit(0);
2320 SkGraphics::SetFontCacheLimit(font_cache_limit); 2301 SkGraphics::SetFontCacheLimit(font_cache_limit);
2321 } 2302 }
2322 } 2303 }
2323 2304
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2501 } 2482 }
2502 } 2483 }
2503 2484
2504 void RenderThreadImpl::OnRendererInterfaceRequest( 2485 void RenderThreadImpl::OnRendererInterfaceRequest(
2505 mojom::RendererAssociatedRequest request) { 2486 mojom::RendererAssociatedRequest request) {
2506 DCHECK(!renderer_binding_.is_bound()); 2487 DCHECK(!renderer_binding_.is_bound());
2507 renderer_binding_.Bind(std::move(request)); 2488 renderer_binding_.Bind(std::move(request));
2508 } 2489 }
2509 2490
2510 } // namespace content 2491 } // namespace content
OLDNEW
« chrome/browser/memory/tab_manager.cc ('K') | « content/renderer/render_thread_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698