OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |