| 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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 EnactStrategy(strategy); | 411 EnactStrategy(strategy); |
| 412 } else { | 412 } else { |
| 413 // DIVIDE_EVENLY / DIVIDE_EVENLY should always succeed. | 413 // DIVIDE_EVENLY / DIVIDE_EVENLY should always succeed. |
| 414 NOTREACHED() << "Unable to find a cache allocation"; | 414 NOTREACHED() << "Unable to find a cache allocation"; |
| 415 } | 415 } |
| 416 } | 416 } |
| 417 | 417 |
| 418 void WebCacheManager::ReviseAllocationStrategyLater() { | 418 void WebCacheManager::ReviseAllocationStrategyLater() { |
| 419 // Ask to be called back in a few milliseconds to actually recompute our | 419 // Ask to be called back in a few milliseconds to actually recompute our |
| 420 // allocation. | 420 // allocation. |
| 421 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 421 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 422 base::Bind( | 422 base::Bind( |
| 423 &WebCacheManager::ReviseAllocationStrategy, | 423 &WebCacheManager::ReviseAllocationStrategy, |
| 424 weak_factory_.GetWeakPtr()), | 424 weak_factory_.GetWeakPtr()), |
| 425 base::TimeDelta::FromMilliseconds(kReviseAllocationDelayMS)); | 425 base::TimeDelta::FromMilliseconds(kReviseAllocationDelayMS)); |
| 426 } | 426 } |
| 427 | 427 |
| 428 void WebCacheManager::FindInactiveRenderers() { | 428 void WebCacheManager::FindInactiveRenderers() { |
| 429 std::set<int>::const_iterator iter = active_renderers_.begin(); | 429 std::set<int>::const_iterator iter = active_renderers_.begin(); |
| 430 while (iter != active_renderers_.end()) { | 430 while (iter != active_renderers_.end()) { |
| 431 StatsMap::iterator elmt = stats_.find(*iter); | 431 StatsMap::iterator elmt = stats_.find(*iter); |
| 432 DCHECK(elmt != stats_.end()); | 432 DCHECK(elmt != stats_.end()); |
| 433 TimeDelta idle = Time::Now() - elmt->second.access; | 433 TimeDelta idle = Time::Now() - elmt->second.access; |
| 434 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) { | 434 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) { |
| 435 // Moved to inactive status. This invalidates our iterator. | 435 // Moved to inactive status. This invalidates our iterator. |
| 436 inactive_renderers_.insert(*iter); | 436 inactive_renderers_.insert(*iter); |
| 437 active_renderers_.erase(*iter); | 437 active_renderers_.erase(*iter); |
| 438 iter = active_renderers_.begin(); | 438 iter = active_renderers_.begin(); |
| 439 continue; | 439 continue; |
| 440 } | 440 } |
| 441 ++iter; | 441 ++iter; |
| 442 } | 442 } |
| 443 } | 443 } |
| OLD | NEW |