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/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_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
18 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
19 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
21 #include "chrome/common/render_messages.h" | 21 #include "chrome/common/render_messages.h" |
22 #include "content/browser/renderer_host/browser_render_process_host.h" | |
23 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/render_process_host.h" |
24 | 24 |
25 using base::Time; | 25 using base::Time; |
26 using base::TimeDelta; | 26 using base::TimeDelta; |
27 using WebKit::WebCache; | 27 using WebKit::WebCache; |
28 | 28 |
29 static const unsigned int kReviseAllocationDelayMS = 200 /* milliseconds */; | 29 static const unsigned int kReviseAllocationDelayMS = 200 /* milliseconds */; |
30 | 30 |
31 // The default size limit of the in-memory cache is 8 MB | 31 // The default size limit of the in-memory cache is 8 MB |
32 static const int kDefaultMemoryCacheSize = 8 * 1024 * 1024; | 32 static const int kDefaultMemoryCacheSize = 8 * 1024 * 1024; |
33 | 33 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 ClearRendederCache(inactive_renderers_, ON_NAVIGATION); | 158 ClearRendederCache(inactive_renderers_, ON_NAVIGATION); |
159 } | 159 } |
160 | 160 |
161 void WebCacheManager::Observe(int type, | 161 void WebCacheManager::Observe(int type, |
162 const content::NotificationSource& source, | 162 const content::NotificationSource& source, |
163 const content::NotificationDetails& details) { | 163 const content::NotificationDetails& details) { |
164 switch (type) { | 164 switch (type) { |
165 case content::NOTIFICATION_RENDERER_PROCESS_CREATED: { | 165 case content::NOTIFICATION_RENDERER_PROCESS_CREATED: { |
166 RenderProcessHost* process = | 166 RenderProcessHost* process = |
167 content::Source<RenderProcessHost>(source).ptr(); | 167 content::Source<RenderProcessHost>(source).ptr(); |
168 Add(process->id()); | 168 Add(process->GetID()); |
169 break; | 169 break; |
170 } | 170 } |
171 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: { | 171 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: { |
172 RenderProcessHost* process = | 172 RenderProcessHost* process = |
173 content::Source<RenderProcessHost>(source).ptr(); | 173 content::Source<RenderProcessHost>(source).ptr(); |
174 Remove(process->id()); | 174 Remove(process->GetID()); |
175 break; | 175 break; |
176 } | 176 } |
177 default: | 177 default: |
178 NOTREACHED(); | 178 NOTREACHED(); |
179 break; | 179 break; |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 // static | 183 // static |
184 size_t WebCacheManager::GetDefaultGlobalSizeLimit() { | 184 size_t WebCacheManager::GetDefaultGlobalSizeLimit() { |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) { | 431 if (idle >= TimeDelta::FromMinutes(kRendererInactiveThresholdMinutes)) { |
432 // Moved to inactive status. This invalidates our iterator. | 432 // Moved to inactive status. This invalidates our iterator. |
433 inactive_renderers_.insert(*iter); | 433 inactive_renderers_.insert(*iter); |
434 active_renderers_.erase(*iter); | 434 active_renderers_.erase(*iter); |
435 iter = active_renderers_.begin(); | 435 iter = active_renderers_.begin(); |
436 continue; | 436 continue; |
437 } | 437 } |
438 ++iter; | 438 ++iter; |
439 } | 439 } |
440 } | 440 } |
OLD | NEW |