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" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/sys_info.h" | 14 #include "base/sys_info.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/prefs/pref_registry_simple.h" |
17 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
18 #include "chrome/common/chrome_constants.h" | 19 #include "chrome/common/chrome_constants.h" |
19 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
21 #include "chrome/common/render_messages.h" | 22 #include "chrome/common/render_messages.h" |
22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
24 | 25 |
25 using base::Time; | 26 using base::Time; |
26 using base::TimeDelta; | 27 using base::TimeDelta; |
(...skipping 19 matching lines...) Expand all Loading... |
46 | 47 |
47 UMA_HISTOGRAM_MEMORY_MB("Cache.MaxCacheSizeMB", | 48 UMA_HISTOGRAM_MEMORY_MB("Cache.MaxCacheSizeMB", |
48 default_cache_size / 1024 / 1024); | 49 default_cache_size / 1024 / 1024); |
49 | 50 |
50 return default_cache_size; | 51 return default_cache_size; |
51 } | 52 } |
52 | 53 |
53 } // anonymous namespace | 54 } // anonymous namespace |
54 | 55 |
55 // static | 56 // static |
56 void WebCacheManager::RegisterPrefs(PrefServiceSimple* prefs) { | 57 void WebCacheManager::RegisterPrefs(PrefRegistrySimple* prefs) { |
57 prefs->RegisterIntegerPref(prefs::kMemoryCacheSize, GetDefaultCacheSize()); | 58 prefs->RegisterIntegerPref(prefs::kMemoryCacheSize, GetDefaultCacheSize()); |
58 } | 59 } |
59 | 60 |
60 // static | 61 // static |
61 WebCacheManager* WebCacheManager::GetInstance() { | 62 WebCacheManager* WebCacheManager::GetInstance() { |
62 return Singleton<WebCacheManager>::get(); | 63 return Singleton<WebCacheManager>::get(); |
63 } | 64 } |
64 | 65 |
65 WebCacheManager::WebCacheManager() | 66 WebCacheManager::WebCacheManager() |
66 : global_size_limit_(GetDefaultGlobalSizeLimit()), | 67 : global_size_limit_(GetDefaultGlobalSizeLimit()), |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) { | 434 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) { |
434 // Moved to inactive status. This invalidates our iterator. | 435 // Moved to inactive status. This invalidates our iterator. |
435 inactive_renderers_.insert(*iter); | 436 inactive_renderers_.insert(*iter); |
436 active_renderers_.erase(*iter); | 437 active_renderers_.erase(*iter); |
437 iter = active_renderers_.begin(); | 438 iter = active_renderers_.begin(); |
438 continue; | 439 continue; |
439 } | 440 } |
440 ++iter; | 441 ++iter; |
441 } | 442 } |
442 } | 443 } |
OLD | NEW |