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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 StatsMap::iterator entry = stats_.find(renderer_id); | 130 StatsMap::iterator entry = stats_.find(renderer_id); |
131 if (entry == stats_.end()) | 131 if (entry == stats_.end()) |
132 return; // We might see stats for a renderer that has been destroyed. | 132 return; // We might see stats for a renderer that has been destroyed. |
133 | 133 |
134 // Record the updated stats. | 134 // Record the updated stats. |
135 entry->second.capacity = stats.capacity; | 135 entry->second.capacity = stats.capacity; |
136 entry->second.deadSize = stats.deadSize; | 136 entry->second.deadSize = stats.deadSize; |
137 entry->second.liveSize = stats.liveSize; | 137 entry->second.liveSize = stats.liveSize; |
138 entry->second.maxDeadCapacity = stats.maxDeadCapacity; | 138 entry->second.maxDeadCapacity = stats.maxDeadCapacity; |
139 entry->second.minDeadCapacity = stats.minDeadCapacity; | 139 entry->second.minDeadCapacity = stats.minDeadCapacity; |
140 | |
141 // trigger notification | |
142 WebCache::UsageStats stats_details(stats); | |
143 // &stats_details is only valid during the notification. | |
144 // See notification_types.h. | |
145 NotificationService::current()->Notify( | |
146 chrome::NOTIFICATION_WEB_CACHE_STATS_OBSERVED, | |
147 Source<RenderProcessHost>(RenderProcessHost::FromID(renderer_id)), | |
148 Details<WebCache::UsageStats>(&stats_details)); | |
149 } | 140 } |
150 | 141 |
151 void WebCacheManager::SetGlobalSizeLimit(size_t bytes) { | 142 void WebCacheManager::SetGlobalSizeLimit(size_t bytes) { |
152 global_size_limit_ = bytes; | 143 global_size_limit_ = bytes; |
153 ReviseAllocationStrategyLater(); | 144 ReviseAllocationStrategyLater(); |
154 } | 145 } |
155 | 146 |
156 void WebCacheManager::ClearCache() { | 147 void WebCacheManager::ClearCache() { |
157 // Tell each renderer process to clear the cache. | 148 // Tell each renderer process to clear the cache. |
158 ClearRendederCache(active_renderers_); | 149 ClearRendederCache(active_renderers_); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) { | 418 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) { |
428 // Moved to inactive status. This invalidates our iterator. | 419 // Moved to inactive status. This invalidates our iterator. |
429 inactive_renderers_.insert(*iter); | 420 inactive_renderers_.insert(*iter); |
430 active_renderers_.erase(*iter); | 421 active_renderers_.erase(*iter); |
431 iter = active_renderers_.begin(); | 422 iter = active_renderers_.begin(); |
432 continue; | 423 continue; |
433 } | 424 } |
434 ++iter; | 425 ++iter; |
435 } | 426 } |
436 } | 427 } |
OLD | NEW |