| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 // We don't reserve any space for dead objects in the cache. Instead, we | 306 // We don't reserve any space for dead objects in the cache. Instead, we |
| 307 // prefer to keep live objects around. There is probably some performance | 307 // prefer to keep live objects around. There is probably some performance |
| 308 // tuning to be done here. | 308 // tuning to be done here. |
| 309 size_t min_dead_capacity = 0; | 309 size_t min_dead_capacity = 0; |
| 310 | 310 |
| 311 // We allow the dead objects to consume all of the cache, if the renderer | 311 // We allow the dead objects to consume all of the cache, if the renderer |
| 312 // so desires. If we wanted this memory, we would have set the total | 312 // so desires. If we wanted this memory, we would have set the total |
| 313 // capacity lower. | 313 // capacity lower. |
| 314 size_t max_dead_capacity = capacity; | 314 size_t max_dead_capacity = capacity; |
| 315 | 315 |
| 316 host->Send(new ViewMsg_SetCacheCapacities(min_dead_capacity, | 316 host->Send(new ChromeViewMsg_SetCacheCapacities(min_dead_capacity, |
| 317 max_dead_capacity, | 317 max_dead_capacity, |
| 318 capacity)); | 318 capacity)); |
| 319 } | 319 } |
| 320 ++allocation; | 320 ++allocation; |
| 321 } | 321 } |
| 322 } | 322 } |
| 323 | 323 |
| 324 void WebCacheManager::ClearRendederCache(const std::set<int>& renderers) { | 324 void WebCacheManager::ClearRendederCache(const std::set<int>& renderers) { |
| 325 std::set<int>::const_iterator iter = renderers.begin(); | 325 std::set<int>::const_iterator iter = renderers.begin(); |
| 326 for (; iter != renderers.end(); ++iter) { | 326 for (; iter != renderers.end(); ++iter) { |
| 327 RenderProcessHost* host = RenderProcessHost::FromID(*iter); | 327 RenderProcessHost* host = RenderProcessHost::FromID(*iter); |
| 328 if (host) | 328 if (host) |
| 329 host->Send(new ViewMsg_ClearCache()); | 329 host->Send(new ChromeViewMsg_ClearCache()); |
| 330 } | 330 } |
| 331 } | 331 } |
| 332 | 332 |
| 333 void WebCacheManager::ReviseAllocationStrategy() { | 333 void WebCacheManager::ReviseAllocationStrategy() { |
| 334 DCHECK(stats_.size() <= | 334 DCHECK(stats_.size() <= |
| 335 active_renderers_.size() + inactive_renderers_.size()); | 335 active_renderers_.size() + inactive_renderers_.size()); |
| 336 | 336 |
| 337 // Check if renderers have gone inactive. | 337 // Check if renderers have gone inactive. |
| 338 FindInactiveRenderers(); | 338 FindInactiveRenderers(); |
| 339 | 339 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) { | 418 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) { |
| 419 // Moved to inactive status. This invalidates our iterator. | 419 // Moved to inactive status. This invalidates our iterator. |
| 420 inactive_renderers_.insert(*iter); | 420 inactive_renderers_.insert(*iter); |
| 421 active_renderers_.erase(*iter); | 421 active_renderers_.erase(*iter); |
| 422 iter = active_renderers_.begin(); | 422 iter = active_renderers_.begin(); |
| 423 continue; | 423 continue; |
| 424 } | 424 } |
| 425 ++iter; | 425 ++iter; |
| 426 } | 426 } |
| 427 } | 427 } |
| OLD | NEW |