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

Side by Side Diff: chrome/browser/renderer_host/web_cache_manager.cc

Issue 19392003: Limit dead resource capacity in Blink cache to 50%. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/renderer_host/web_cache_manager.h" 5 #include "chrome/browser/renderer_host/web_cache_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 void WebCacheManager::EnactStrategy(const AllocationStrategy& strategy) { 308 void WebCacheManager::EnactStrategy(const AllocationStrategy& strategy) {
309 // Inform each render process of its cache allocation. 309 // Inform each render process of its cache allocation.
310 AllocationStrategy::const_iterator allocation = strategy.begin(); 310 AllocationStrategy::const_iterator allocation = strategy.begin();
311 while (allocation != strategy.end()) { 311 while (allocation != strategy.end()) {
312 content::RenderProcessHost* host = 312 content::RenderProcessHost* host =
313 content::RenderProcessHost::FromID(allocation->first); 313 content::RenderProcessHost::FromID(allocation->first);
314 if (host) { 314 if (host) {
315 // This is the capacity this renderer has been allocated. 315 // This is the capacity this renderer has been allocated.
316 size_t capacity = allocation->second; 316 size_t capacity = allocation->second;
317 317
318 // We don't reserve any space for dead objects in the cache. Instead, we 318 // We don't reserve any space for dead objects in the cache. Instead, we
319 // prefer to keep live objects around. There is probably some performance 319 // prefer to keep live objects around. There is probably some performance
320 // tuning to be done here. 320 // tuning to be done here.
321 size_t min_dead_capacity = 0; 321 size_t min_dead_capacity = 0;
322 322
323 // We allow the dead objects to consume all of the cache, if the renderer 323 // We allow the dead objects to consume up to half of the cache capacity.
324 // so desires. If we wanted this memory, we would have set the total 324 size_t max_dead_capacity = capacity / 2;
325 // capacity lower.
326 size_t max_dead_capacity = capacity;
327 325
328 host->Send(new ChromeViewMsg_SetCacheCapacities(min_dead_capacity, 326 host->Send(new ChromeViewMsg_SetCacheCapacities(min_dead_capacity,
329 max_dead_capacity, 327 max_dead_capacity,
330 capacity)); 328 capacity));
331 } 329 }
332 ++allocation; 330 ++allocation;
333 } 331 }
334 } 332 }
335 333
336 void WebCacheManager::ClearRendererCache( 334 void WebCacheManager::ClearRendererCache(
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) { 432 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) {
435 // Moved to inactive status. This invalidates our iterator. 433 // Moved to inactive status. This invalidates our iterator.
436 inactive_renderers_.insert(*iter); 434 inactive_renderers_.insert(*iter);
437 active_renderers_.erase(*iter); 435 active_renderers_.erase(*iter);
438 iter = active_renderers_.begin(); 436 iter = active_renderers_.begin();
439 continue; 437 continue;
440 } 438 }
441 ++iter; 439 ++iter;
442 } 440 }
443 } 441 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698