| 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" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
| 18 #include "chrome/common/chrome_notification_types.h" |
| 18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/common/render_messages.h" | 20 #include "chrome/common/render_messages.h" |
| 20 #include "content/browser/renderer_host/browser_render_process_host.h" | 21 #include "content/browser/renderer_host/browser_render_process_host.h" |
| 21 #include "content/common/notification_service.h" | 22 #include "content/common/notification_service.h" |
| 22 | 23 |
| 23 using base::Time; | 24 using base::Time; |
| 24 using base::TimeDelta; | 25 using base::TimeDelta; |
| 25 using WebKit::WebCache; | 26 using WebKit::WebCache; |
| 26 | 27 |
| 27 static const unsigned int kReviseAllocationDelayMS = 200 /* milliseconds */; | 28 static const unsigned int kReviseAllocationDelayMS = 200 /* milliseconds */; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 entry->second.deadSize = stats.deadSize; | 136 entry->second.deadSize = stats.deadSize; |
| 136 entry->second.liveSize = stats.liveSize; | 137 entry->second.liveSize = stats.liveSize; |
| 137 entry->second.maxDeadCapacity = stats.maxDeadCapacity; | 138 entry->second.maxDeadCapacity = stats.maxDeadCapacity; |
| 138 entry->second.minDeadCapacity = stats.minDeadCapacity; | 139 entry->second.minDeadCapacity = stats.minDeadCapacity; |
| 139 | 140 |
| 140 // trigger notification | 141 // trigger notification |
| 141 WebCache::UsageStats stats_details(stats); | 142 WebCache::UsageStats stats_details(stats); |
| 142 // &stats_details is only valid during the notification. | 143 // &stats_details is only valid during the notification. |
| 143 // See notification_types.h. | 144 // See notification_types.h. |
| 144 NotificationService::current()->Notify( | 145 NotificationService::current()->Notify( |
| 145 NotificationType::WEB_CACHE_STATS_OBSERVED, | 146 chrome::WEB_CACHE_STATS_OBSERVED, |
| 146 Source<RenderProcessHost>(RenderProcessHost::FromID(renderer_id)), | 147 Source<RenderProcessHost>(RenderProcessHost::FromID(renderer_id)), |
| 147 Details<WebCache::UsageStats>(&stats_details)); | 148 Details<WebCache::UsageStats>(&stats_details)); |
| 148 } | 149 } |
| 149 | 150 |
| 150 void WebCacheManager::SetGlobalSizeLimit(size_t bytes) { | 151 void WebCacheManager::SetGlobalSizeLimit(size_t bytes) { |
| 151 global_size_limit_ = bytes; | 152 global_size_limit_ = bytes; |
| 152 ReviseAllocationStrategyLater(); | 153 ReviseAllocationStrategyLater(); |
| 153 } | 154 } |
| 154 | 155 |
| 155 void WebCacheManager::ClearCache() { | 156 void WebCacheManager::ClearCache() { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) { | 427 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) { |
| 427 // Moved to inactive status. This invalidates our iterator. | 428 // Moved to inactive status. This invalidates our iterator. |
| 428 inactive_renderers_.insert(*iter); | 429 inactive_renderers_.insert(*iter); |
| 429 active_renderers_.erase(*iter); | 430 active_renderers_.erase(*iter); |
| 430 iter = active_renderers_.begin(); | 431 iter = active_renderers_.begin(); |
| 431 continue; | 432 continue; |
| 432 } | 433 } |
| 433 ++iter; | 434 ++iter; |
| 434 } | 435 } |
| 435 } | 436 } |
| OLD | NEW |