summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser.scons2
-rw-r--r--chrome/browser/browser.vcproj16
-rw-r--r--chrome/browser/browser_prefs.cc4
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc12
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.h4
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc8
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h4
-rw-r--r--chrome/browser/renderer_host/web_cache_manager.cc (renamed from chrome/browser/cache_manager_host.cc)89
-rw-r--r--chrome/browser/renderer_host/web_cache_manager.h (renamed from chrome/browser/cache_manager_host.h)41
-rw-r--r--chrome/browser/renderer_host/web_cache_manager_unittest.cc (renamed from chrome/browser/cache_manager_host_unittest.cc)136
-rw-r--r--chrome/browser/tab_contents/web_contents.cc4
-rw-r--r--chrome/browser/task_manager.h2
12 files changed, 164 insertions, 158 deletions
diff --git a/chrome/browser/browser.scons b/chrome/browser/browser.scons
index 222f1e6..4d51802a 100644
--- a/chrome/browser/browser.scons
+++ b/chrome/browser/browser.scons
@@ -96,7 +96,6 @@ input_files = ChromeFileList([
'browsing_data_remover.h',
'browsing_instance.cc',
'browsing_instance.h',
- 'cache_manager_host.cc',
'cache_manager_host.h',
'cancelable_request.cc',
'cancelable_request.h',
@@ -568,6 +567,7 @@ input_files = ChromeFileList([
'renderer_host/save_file_resource_handler.h',
'renderer_host/sync_resource_handler.cc',
'renderer_host/sync_resource_handler.h',
+ 'renderer_host/web_cache_manager.cc',
]),
MSVSFilter('Tab Contents', [
'tab_contents/constrained_window.h',
diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj
index 2d792bf..5c80c9e 100644
--- a/chrome/browser/browser.vcproj
+++ b/chrome/browser/browser.vcproj
@@ -314,14 +314,6 @@
>
</File>
<File
- RelativePath=".\cache_manager_host.cc"
- >
- </File>
- <File
- RelativePath=".\cache_manager_host.h"
- >
- </File>
- <File
RelativePath=".\cancelable_request.cc"
>
</File>
@@ -2157,6 +2149,14 @@
RelativePath=".\renderer_host\sync_resource_handler.h"
>
</File>
+ <File
+ RelativePath=".\renderer_host\web_cache_manager.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\renderer_host\web_cache_manager.h"
+ >
+ </File>
</Filter>
<Filter
Name="Tab Contents"
diff --git a/chrome/browser/browser_prefs.cc b/chrome/browser/browser_prefs.cc
index 570763f..7e9d6d8 100644
--- a/chrome/browser/browser_prefs.cc
+++ b/chrome/browser/browser_prefs.cc
@@ -8,7 +8,6 @@
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_shutdown.h"
-#include "chrome/browser/cache_manager_host.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/external_protocol_handler.h"
#include "chrome/browser/google_url_tracker.h"
@@ -16,6 +15,7 @@
#include "chrome/browser/net/dns_global.h"
#include "chrome/browser/password_manager/password_manager.h"
#include "chrome/browser/renderer_host/browser_render_process_host.h"
+#include "chrome/browser/renderer_host/web_cache_manager.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
#include "chrome/browser/session_startup_pref.h"
@@ -35,7 +35,7 @@ namespace browser {
void RegisterAllPrefs(PrefService* user_prefs, PrefService* local_state) {
// Prefs in Local State
Browser::RegisterPrefs(local_state);
- CacheManagerHost::RegisterPrefs(local_state);
+ WebCacheManager::RegisterPrefs(local_state);
ExternalProtocolHandler::RegisterPrefs(local_state);
GoogleURLTracker::RegisterPrefs(local_state);
MetricsLog::RegisterPrefs(local_state);
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 810ec1d..c694fdd 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -23,7 +23,6 @@
#include "base/string_util.h"
#include "base/thread.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/cache_manager_host.h"
#include "chrome/browser/extensions/user_script_master.h"
#include "chrome/browser/history/history.h"
#include "chrome/browser/plugin_service.h"
@@ -31,6 +30,7 @@
#include "chrome/browser/renderer_host/render_widget_helper.h"
#include "chrome/browser/renderer_host/renderer_security_policy.h"
#include "chrome/browser/renderer_host/resource_message_filter.h"
+#include "chrome/browser/renderer_host/web_cache_manager.h"
#include "chrome/browser/visitedlink_master.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/child_process_info.h"
@@ -44,6 +44,8 @@
#include "chrome/renderer/render_process.h"
#include "grit/generated_resources.h"
+using WebKit::WebCache;
+
#if defined(OS_WIN)
// TODO(port): see comment by the only usage of RenderViewHost in this file.
@@ -153,7 +155,7 @@ BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile)
BrowserRenderProcessHost::~BrowserRenderProcessHost() {
if (pid() >= 0) {
- CacheManagerHost::GetInstance()->Remove(pid());
+ WebCacheManager::GetInstance()->Remove(pid());
RendererSecurityPolicy::GetInstance()->Remove(pid());
}
@@ -335,7 +337,7 @@ bool BrowserRenderProcessHost::Init() {
}
resource_message_filter->Init(pid());
- CacheManagerHost::GetInstance()->Add(pid());
+ WebCacheManager::GetInstance()->Add(pid());
RendererSecurityPolicy::GetInstance()->Add(pid());
// Now that the process is created, set it's backgrounding accordingly.
@@ -697,8 +699,8 @@ void BrowserRenderProcessHost::OnPageContents(const GURL& url,
}
void BrowserRenderProcessHost::OnUpdatedCacheStats(
- const CacheManager::UsageStats& stats) {
- CacheManagerHost::GetInstance()->ObserveStats(pid(), stats);
+ const WebCache::UsageStats& stats) {
+ WebCacheManager::GetInstance()->ObserveStats(pid(), stats);
}
void BrowserRenderProcessHost::SetBackgrounded(bool backgrounded) {
diff --git a/chrome/browser/renderer_host/browser_render_process_host.h b/chrome/browser/renderer_host/browser_render_process_host.h
index 3cc05a8..d6f821e 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.h
+++ b/chrome/browser/renderer_host/browser_render_process_host.h
@@ -19,7 +19,7 @@
#include "chrome/browser/renderer_host/audio_renderer_host.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/common/notification_observer.h"
-#include "webkit/glue/cache_manager.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebCache.h"
class CommandLine;
class GURL;
@@ -99,7 +99,7 @@ class BrowserRenderProcessHost : public RenderProcessHost,
void OnClipboardReadAsciiText(std::string* result);
void OnClipboardReadHTML(string16* markup, GURL* src_url);
- void OnUpdatedCacheStats(const CacheManager::UsageStats& stats);
+ void OnUpdatedCacheStats(const WebKit::WebCache::UsageStats& stats);
// Initialize support for visited links. Send the renderer process its initial
// set of visited links.
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 2ea6ac8..377bfc7 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -41,6 +41,8 @@
#include "chrome/common/temp_scaffolding_stubs.h"
#endif
+using WebKit::WebCache;
+
namespace {
// Context menus are somewhat complicated. We need to intercept them here on
@@ -555,15 +557,15 @@ void ResourceMessageFilter::OnDuplicateSection(
}
void ResourceMessageFilter::OnResourceTypeStats(
- const CacheManager::ResourceTypeStats& stats) {
+ const WebCache::ResourceTypeStats& stats) {
HISTOGRAM_COUNTS("WebCoreCache.ImagesSizeKB",
static_cast<int>(stats.images.size / 1024));
HISTOGRAM_COUNTS("WebCoreCache.CSSStylesheetsSizeKB",
- static_cast<int>(stats.css_stylesheets.size / 1024));
+ static_cast<int>(stats.cssStyleSheets.size / 1024));
HISTOGRAM_COUNTS("WebCoreCache.ScriptsSizeKB",
static_cast<int>(stats.scripts.size / 1024));
HISTOGRAM_COUNTS("WebCoreCache.XSLStylesheetsSizeKB",
- static_cast<int>(stats.xsl_stylesheets.size / 1024));
+ static_cast<int>(stats.xslStyleSheets.size / 1024));
HISTOGRAM_COUNTS("WebCoreCache.FontsSizeKB",
static_cast<int>(stats.fonts.size / 1024));
}
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index 7f05d85..29ae829 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -22,7 +22,7 @@
#include "chrome/common/modal_dialog_event.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/transport_dib.h"
-#include "webkit/glue/cache_manager.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebCache.h"
#if defined(OS_WIN)
#include <windows.h>
@@ -164,7 +164,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
void OnGetCPBrowsingContext(uint32* context);
void OnDuplicateSection(base::SharedMemoryHandle renderer_handle,
base::SharedMemoryHandle* browser_handle);
- void OnResourceTypeStats(const CacheManager::ResourceTypeStats& stats);
+ void OnResourceTypeStats(const WebKit::WebCache::ResourceTypeStats& stats);
void OnResolveProxy(const GURL& url, IPC::Message* reply_msg);
diff --git a/chrome/browser/cache_manager_host.cc b/chrome/browser/renderer_host/web_cache_manager.cc
index da6ec4c..91b740e 100644
--- a/chrome/browser/cache_manager_host.cc
+++ b/chrome/browser/renderer_host/web_cache_manager.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/cache_manager_host.h"
+#include "chrome/browser/renderer_host/web_cache_manager.h"
#include <algorithm>
@@ -19,6 +19,7 @@
using base::Time;
using base::TimeDelta;
+using WebKit::WebCache;
static const unsigned int kReviseAllocationDelayMS = 200 /* milliseconds */;
@@ -44,24 +45,24 @@ int GetDefaultCacheSize() {
} // anonymous namespace
// static
-void CacheManagerHost::RegisterPrefs(PrefService* prefs) {
+void WebCacheManager::RegisterPrefs(PrefService* prefs) {
prefs->RegisterIntegerPref(prefs::kMemoryCacheSize, GetDefaultCacheSize());
}
// static
-CacheManagerHost* CacheManagerHost::GetInstance() {
- return Singleton<CacheManagerHost>::get();
+WebCacheManager* WebCacheManager::GetInstance() {
+ return Singleton<WebCacheManager>::get();
}
-CacheManagerHost::CacheManagerHost()
+WebCacheManager::WebCacheManager()
: global_size_limit_(GetDefaultGlobalSizeLimit()),
ALLOW_THIS_IN_INITIALIZER_LIST(revise_allocation_factory_(this)) {
}
-CacheManagerHost::~CacheManagerHost() {
+WebCacheManager::~WebCacheManager() {
}
-void CacheManagerHost::Add(int renderer_id) {
+void WebCacheManager::Add(int renderer_id) {
DCHECK(inactive_renderers_.count(renderer_id) == 0);
// It is tempting to make the following DCHECK here, but it fails when a new
@@ -83,7 +84,7 @@ void CacheManagerHost::Add(int renderer_id) {
ReviseAllocationStrategyLater();
}
-void CacheManagerHost::Remove(int renderer_id) {
+void WebCacheManager::Remove(int renderer_id) {
DCHECK(active_renderers_.count(renderer_id) > 0 ||
inactive_renderers_.count(renderer_id) > 0);
@@ -96,7 +97,7 @@ void CacheManagerHost::Remove(int renderer_id) {
ReviseAllocationStrategyLater();
}
-void CacheManagerHost::ObserveActivity(int renderer_id) {
+void WebCacheManager::ObserveActivity(int renderer_id) {
// Record activity.
active_renderers_.insert(renderer_id);
@@ -115,36 +116,36 @@ void CacheManagerHost::ObserveActivity(int renderer_id) {
}
}
-void CacheManagerHost::ObserveStats(int renderer_id,
- const CacheManager::UsageStats& stats) {
+void WebCacheManager::ObserveStats(int renderer_id,
+ const WebCache::UsageStats& stats) {
StatsMap::iterator entry = stats_.find(renderer_id);
if (entry == stats_.end())
return; // We might see stats for a renderer that has been destroyed.
// Record the updated stats.
entry->second.capacity = stats.capacity;
- entry->second.dead_size = stats.dead_size;
- entry->second.live_size = stats.live_size;
- entry->second.max_dead_capacity = stats.max_dead_capacity;
- entry->second.min_dead_capacity = stats.min_dead_capacity;
+ entry->second.deadSize = stats.deadSize;
+ entry->second.liveSize = stats.liveSize;
+ entry->second.maxDeadCapacity = stats.maxDeadCapacity;
+ entry->second.minDeadCapacity = stats.minDeadCapacity;
// trigger notification
- CacheManager::UsageStats stats_details(stats);
+ WebCache::UsageStats stats_details(stats);
// &stats_details is only valid during the notification.
// See notification_types.h.
NotificationService::current()->Notify(
NotificationType::WEB_CACHE_STATS_OBSERVED,
Source<RenderProcessHost>(RenderProcessHost::FromID(renderer_id)),
- Details<CacheManager::UsageStats>(&stats_details));
+ Details<WebCache::UsageStats>(&stats_details));
}
-void CacheManagerHost::SetGlobalSizeLimit(size_t bytes) {
+void WebCacheManager::SetGlobalSizeLimit(size_t bytes) {
global_size_limit_ = bytes;
ReviseAllocationStrategyLater();
}
// static
-size_t CacheManagerHost::GetDefaultGlobalSizeLimit() {
+size_t WebCacheManager::GetDefaultGlobalSizeLimit() {
PrefService* perf_service = g_browser_process->local_state();
if (perf_service)
return perf_service->GetInteger(prefs::kMemoryCacheSize);
@@ -152,29 +153,29 @@ size_t CacheManagerHost::GetDefaultGlobalSizeLimit() {
return GetDefaultCacheSize();
}
-void CacheManagerHost::GatherStats(const std::set<int>& renderers,
- CacheManager::UsageStats* stats) {
+void WebCacheManager::GatherStats(const std::set<int>& renderers,
+ WebCache::UsageStats* stats) {
DCHECK(stats);
- memset(stats, 0, sizeof(CacheManager::UsageStats));
+ memset(stats, 0, sizeof(WebCache::UsageStats));
std::set<int>::const_iterator iter = renderers.begin();
while (iter != renderers.end()) {
StatsMap::iterator elmt = stats_.find(*iter);
if (elmt != stats_.end()) {
- stats->min_dead_capacity += elmt->second.min_dead_capacity;
- stats->max_dead_capacity += elmt->second.max_dead_capacity;
+ stats->minDeadCapacity += elmt->second.minDeadCapacity;
+ stats->maxDeadCapacity += elmt->second.maxDeadCapacity;
stats->capacity += elmt->second.capacity;
- stats->live_size += elmt->second.live_size;
- stats->dead_size += elmt->second.dead_size;
+ stats->liveSize += elmt->second.liveSize;
+ stats->deadSize += elmt->second.deadSize;
}
++iter;
}
}
// static
-size_t CacheManagerHost::GetSize(AllocationTactic tactic,
- const CacheManager::UsageStats& stats) {
+size_t WebCacheManager::GetSize(AllocationTactic tactic,
+ const WebCache::UsageStats& stats) {
switch (tactic) {
case DIVIDE_EVENLY:
// We aren't going to reserve any space for existing objects.
@@ -184,24 +185,24 @@ size_t CacheManagerHost::GetSize(AllocationTactic tactic,
return 3 * GetSize(KEEP_CURRENT, stats) / 2;
case KEEP_CURRENT:
// We need enough space to keep our current objects.
- return stats.live_size + stats.dead_size;
+ return stats.liveSize + stats.deadSize;
case KEEP_LIVE_WITH_HEADROOM:
// We need enough space to keep out live resources, plus some headroom.
return 3 * GetSize(KEEP_LIVE, stats) / 2;
case KEEP_LIVE:
// We need enough space to keep our live resources.
- return stats.live_size;
+ return stats.liveSize;
default:
NOTREACHED() << "Unknown cache allocation tactic";
return 0;
}
}
-bool CacheManagerHost::AttemptTactic(
+bool WebCacheManager::AttemptTactic(
AllocationTactic active_tactic,
- const CacheManager::UsageStats& active_stats,
+ const WebCache::UsageStats& active_stats,
AllocationTactic inactive_tactic,
- const CacheManager::UsageStats& inactive_stats,
+ const WebCache::UsageStats& inactive_stats,
AllocationStrategy* strategy) {
DCHECK(strategy);
@@ -238,10 +239,10 @@ bool CacheManagerHost::AttemptTactic(
return true;
}
-void CacheManagerHost::AddToStrategy(std::set<int> renderers,
- AllocationTactic tactic,
- size_t extra_bytes_to_allocate,
- AllocationStrategy* strategy) {
+void WebCacheManager::AddToStrategy(std::set<int> renderers,
+ AllocationTactic tactic,
+ size_t extra_bytes_to_allocate,
+ AllocationStrategy* strategy) {
DCHECK(strategy);
// Nothing to do if there are no renderers. It is common for there to be no
@@ -267,7 +268,7 @@ void CacheManagerHost::AddToStrategy(std::set<int> renderers,
}
}
-void CacheManagerHost::EnactStrategy(const AllocationStrategy& strategy) {
+void WebCacheManager::EnactStrategy(const AllocationStrategy& strategy) {
// Inform each render process of its cache allocation.
AllocationStrategy::const_iterator allocation = strategy.begin();
while (allocation != strategy.end()) {
@@ -294,7 +295,7 @@ void CacheManagerHost::EnactStrategy(const AllocationStrategy& strategy) {
}
}
-void CacheManagerHost::ReviseAllocationStrategy() {
+void WebCacheManager::ReviseAllocationStrategy() {
DCHECK(stats_.size() <=
active_renderers_.size() + inactive_renderers_.size());
@@ -302,8 +303,8 @@ void CacheManagerHost::ReviseAllocationStrategy() {
FindInactiveRenderers();
// Gather statistics
- CacheManager::UsageStats active;
- CacheManager::UsageStats inactive;
+ WebCache::UsageStats active;
+ WebCache::UsageStats inactive;
GatherStats(active_renderers_, &active);
GatherStats(inactive_renderers_, &inactive);
@@ -349,16 +350,16 @@ void CacheManagerHost::ReviseAllocationStrategy() {
}
}
-void CacheManagerHost::ReviseAllocationStrategyLater() {
+void WebCacheManager::ReviseAllocationStrategyLater() {
// Ask to be called back in a few milliseconds to actually recompute our
// allocation.
MessageLoop::current()->PostDelayedTask(FROM_HERE,
revise_allocation_factory_.NewRunnableMethod(
- &CacheManagerHost::ReviseAllocationStrategy),
+ &WebCacheManager::ReviseAllocationStrategy),
kReviseAllocationDelayMS);
}
-void CacheManagerHost::FindInactiveRenderers() {
+void WebCacheManager::FindInactiveRenderers() {
std::set<int>::const_iterator iter = active_renderers_.begin();
while (iter != active_renderers_.end()) {
StatsMap::iterator elmt = stats_.find(*iter);
diff --git a/chrome/browser/cache_manager_host.h b/chrome/browser/renderer_host/web_cache_manager.h
index f1313dc..1e9b642 100644
--- a/chrome/browser/cache_manager_host.h
+++ b/chrome/browser/renderer_host/web_cache_manager.h
@@ -5,8 +5,8 @@
// This is the browser side of the cache manager, it tracks the activity of the
// render processes and allocates available memory cache resources.
-#ifndef CHROME_BROWSER_CACHE_MANAGER_HOST_H__
-#define CHROME_BROWSER_CACHE_MANAGER_HOST_H__
+#ifndef CHROME_BROWSER_WEB_CACHE_MANAGER_H_
+#define CHROME_BROWSER_WEB_CACHE_MANAGER_H_
#include <map>
#include <list>
@@ -17,21 +17,21 @@
#include "base/singleton.h"
#include "base/task.h"
#include "base/time.h"
-#include "webkit/glue/cache_manager.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebCache.h"
class PrefService;
-class CacheManagerHost {
+class WebCacheManager {
// Unit tests are our friends.
- friend class CacheManagerHostTest;
+ friend class WebCacheManagerTest;
public:
static void RegisterPrefs(PrefService* prefs);
- // Gets the singleton CacheManagerHost object. The first time this method
- // is called, a CacheManagerHost object is constructed and returned.
+ // Gets the singleton WebCacheManager object. The first time this method
+ // is called, a WebCacheManager object is constructed and returned.
// Subsequent calls will return the same object.
- static CacheManagerHost* GetInstance();
+ static WebCacheManager* GetInstance();
// When a render process is created, it registers itself with the cache
// manager host, causing the renderer to be allocated cache resources.
@@ -53,7 +53,8 @@ class CacheManagerHost {
// Periodically, renderers should inform the cache manager of their current
// statistics. The more up-to-date the cache manager's statistics, the
// better it can allocate cache resources.
- void ObserveStats(int renderer_id, const CacheManager::UsageStats& stats);
+ void ObserveStats(
+ int renderer_id, const WebKit::WebCache::UsageStats& stats);
// The global limit on the number of bytes in all the in-memory caches.
size_t global_size_limit() const { return global_size_limit_; }
@@ -70,7 +71,7 @@ class CacheManagerHost {
static const int kRendererInactiveThresholdMinutes = 5;
// Keep track of some renderer information.
- struct RendererInfo : CacheManager::UsageStats {
+ struct RendererInfo : WebKit::WebCache::UsageStats {
// The access time for this renderer.
base::Time access;
};
@@ -86,10 +87,10 @@ class CacheManagerHost {
typedef std::list<Allocation> AllocationStrategy;
// This class is a singleton. Do not instantiate directly.
- CacheManagerHost();
- friend struct DefaultSingletonTraits<CacheManagerHost>;
+ WebCacheManager();
+ friend struct DefaultSingletonTraits<WebCacheManager>;
- ~CacheManagerHost();
+ ~WebCacheManager();
// Recomputes the allocation of cache resources among the renderers. Also
// informs the renderers of their new allocation.
@@ -132,13 +133,13 @@ class CacheManagerHost {
// Add up all the stats from the given set of renderers and place the result
// in |stats|.
void GatherStats(const std::set<int>& renderers,
- CacheManager::UsageStats* stats);
+ WebKit::WebCache::UsageStats* stats);
// Get the amount of memory that would be required to implement |tactic|
// using the specified allocation tactic. This function defines the
// semantics for each of the tactics.
static size_t GetSize(AllocationTactic tactic,
- const CacheManager::UsageStats& stats);
+ const WebKit::WebCache::UsageStats& stats);
// Attempt to use the specified tactics to compute an allocation strategy
// and place the result in |strategy|. |active_stats| and |inactive_stats|
@@ -148,9 +149,9 @@ class CacheManagerHost {
// Returns |true| on success and |false| on failure. Does not modify
// |strategy| on failure.
bool AttemptTactic(AllocationTactic active_tactic,
- const CacheManager::UsageStats& active_stats,
+ const WebKit::WebCache::UsageStats& active_stats,
AllocationTactic inactive_tactic,
- const CacheManager::UsageStats& inactive_stats,
+ const WebKit::WebCache::UsageStats& inactive_stats,
AllocationStrategy* strategy);
// For each renderer in |renderers|, computes its allocation according to
@@ -183,9 +184,9 @@ class CacheManagerHost {
// recently than they have been active.
std::set<int> inactive_renderers_;
- ScopedRunnableMethodFactory<CacheManagerHost> revise_allocation_factory_;
+ ScopedRunnableMethodFactory<WebCacheManager> revise_allocation_factory_;
- DISALLOW_EVIL_CONSTRUCTORS(CacheManagerHost);
+ DISALLOW_COPY_AND_ASSIGN(WebCacheManager);
};
-#endif // CHROME_BROWSER_CACHE_MANAGER_HOST_H__
+#endif // CHROME_BROWSER_WEB_CACHE_MANAGER_H_
diff --git a/chrome/browser/cache_manager_host_unittest.cc b/chrome/browser/renderer_host/web_cache_manager_unittest.cc
index 9164a47..9592582 100644
--- a/chrome/browser/cache_manager_host_unittest.cc
+++ b/chrome/browser/renderer_host/web_cache_manager_unittest.cc
@@ -5,82 +5,82 @@
#include <string>
#include "base/message_loop.h"
-#include "chrome/browser/cache_manager_host.h"
+#include "chrome/browser/renderer_host/web_cache_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/glue/cache_manager.h"
using base::Time;
using base::TimeDelta;
+using WebKit::WebCache;
-class CacheManagerHostTest : public testing::Test {
+class WebCacheManagerTest : public testing::Test {
protected:
- typedef CacheManagerHost::StatsMap StatsMap;
- typedef CacheManagerHost::Allocation Allocation;
- typedef CacheManagerHost::AllocationStrategy AllocationStrategy;
+ typedef WebCacheManager::StatsMap StatsMap;
+ typedef WebCacheManager::Allocation Allocation;
+ typedef WebCacheManager::AllocationStrategy AllocationStrategy;
static const int kRendererID;
static const int kRendererID2;
- static const CacheManager::UsageStats kStats;
- static const CacheManager::UsageStats kStats2;
+ static const WebCache::UsageStats kStats;
+ static const WebCache::UsageStats kStats2;
- // Thunks to access protected members of CacheManagerHost
- static std::map<int, CacheManagerHost::RendererInfo>& stats(
- CacheManagerHost* h) {
+ // Thunks to access protected members of WebCacheManager
+ static std::map<int, WebCacheManager::RendererInfo>& stats(
+ WebCacheManager* h) {
return h->stats_;
}
- static void SimulateInactivity(CacheManagerHost* h, int renderer_id) {
+ static void SimulateInactivity(WebCacheManager* h, int renderer_id) {
stats(h)[renderer_id].access = Time::Now() - TimeDelta::FromMinutes(
- CacheManagerHost::kRendererInactiveThresholdMinutes);
+ WebCacheManager::kRendererInactiveThresholdMinutes);
h->FindInactiveRenderers();
}
- static std::set<int>& active_renderers(CacheManagerHost* h) {
+ static std::set<int>& active_renderers(WebCacheManager* h) {
return h->active_renderers_;
}
- static std::set<int>& inactive_renderers(CacheManagerHost* h) {
+ static std::set<int>& inactive_renderers(WebCacheManager* h) {
return h->inactive_renderers_;
}
- static void GatherStats(CacheManagerHost* h,
+ static void GatherStats(WebCacheManager* h,
std::set<int> renderers,
- CacheManager::UsageStats* stats) {
+ WebCache::UsageStats* stats) {
h->GatherStats(renderers, stats);
}
static size_t GetSize(int tactic,
- const CacheManager::UsageStats& stats) {
- return CacheManagerHost::GetSize(
- static_cast<CacheManagerHost::AllocationTactic>(tactic), stats);
+ const WebCache::UsageStats& stats) {
+ return WebCacheManager::GetSize(
+ static_cast<WebCacheManager::AllocationTactic>(tactic), stats);
}
- static bool AttemptTactic(CacheManagerHost* h,
+ static bool AttemptTactic(WebCacheManager* h,
int active_tactic,
- const CacheManager::UsageStats& active_stats,
+ const WebCache::UsageStats& active_stats,
int inactive_tactic,
- const CacheManager::UsageStats& inactive_stats,
+ const WebCache::UsageStats& inactive_stats,
std::list< std::pair<int,size_t> >* strategy) {
return h->AttemptTactic(
- static_cast<CacheManagerHost::AllocationTactic>(active_tactic),
+ static_cast<WebCacheManager::AllocationTactic>(active_tactic),
active_stats,
- static_cast<CacheManagerHost::AllocationTactic>(inactive_tactic),
+ static_cast<WebCacheManager::AllocationTactic>(inactive_tactic),
inactive_stats,
strategy);
}
- static void AddToStrategy(CacheManagerHost* h,
+ static void AddToStrategy(WebCacheManager* h,
std::set<int> renderers,
int tactic,
size_t extra_bytes_to_allocate,
std::list< std::pair<int,size_t> >* strategy) {
h->AddToStrategy(renderers,
- static_cast<CacheManagerHost::AllocationTactic>(tactic),
+ static_cast<WebCacheManager::AllocationTactic>(tactic),
extra_bytes_to_allocate,
strategy);
}
enum {
- DIVIDE_EVENLY = CacheManagerHost::DIVIDE_EVENLY,
- KEEP_CURRENT_WITH_HEADROOM = CacheManagerHost::KEEP_CURRENT_WITH_HEADROOM,
- KEEP_CURRENT = CacheManagerHost::KEEP_CURRENT,
- KEEP_LIVE_WITH_HEADROOM = CacheManagerHost::KEEP_LIVE_WITH_HEADROOM,
- KEEP_LIVE = CacheManagerHost::KEEP_LIVE,
+ DIVIDE_EVENLY = WebCacheManager::DIVIDE_EVENLY,
+ KEEP_CURRENT_WITH_HEADROOM = WebCacheManager::KEEP_CURRENT_WITH_HEADROOM,
+ KEEP_CURRENT = WebCacheManager::KEEP_CURRENT,
+ KEEP_LIVE_WITH_HEADROOM = WebCacheManager::KEEP_LIVE_WITH_HEADROOM,
+ KEEP_LIVE = WebCacheManager::KEEP_LIVE,
};
private:
@@ -88,13 +88,13 @@ class CacheManagerHostTest : public testing::Test {
};
// static
-const int CacheManagerHostTest::kRendererID = 146;
+const int WebCacheManagerTest::kRendererID = 146;
// static
-const int CacheManagerHostTest::kRendererID2 = 245;
+const int WebCacheManagerTest::kRendererID2 = 245;
// static
-const CacheManager::UsageStats CacheManagerHostTest::kStats = {
+const WebCache::UsageStats WebCacheManagerTest::kStats = {
0,
1024 * 1024,
1024 * 1024,
@@ -103,7 +103,7 @@ const CacheManager::UsageStats CacheManagerHostTest::kStats = {
};
// static
-const CacheManager::UsageStats CacheManagerHostTest::kStats2 = {
+const WebCache::UsageStats WebCacheManagerTest::kStats2 = {
0,
2 * 1024 * 1024,
2 * 1024 * 1024,
@@ -111,13 +111,13 @@ const CacheManager::UsageStats CacheManagerHostTest::kStats2 = {
2 * 512,
};
-static bool operator==(const CacheManager::UsageStats& lhs,
- const CacheManager::UsageStats& rhs) {
- return !::memcmp(&lhs, &rhs, sizeof(CacheManager::UsageStats));
+static bool operator==(const WebCache::UsageStats& lhs,
+ const WebCache::UsageStats& rhs) {
+ return !::memcmp(&lhs, &rhs, sizeof(WebCache::UsageStats));
}
-TEST_F(CacheManagerHostTest, AddRemoveRendererTest) {
- CacheManagerHost* h = CacheManagerHost::GetInstance();
+TEST_F(WebCacheManagerTest, AddRemoveRendererTest) {
+ WebCacheManager* h = WebCacheManager::GetInstance();
EXPECT_EQ(0U, active_renderers(h).size());
EXPECT_EQ(0U, inactive_renderers(h).size());
@@ -131,8 +131,8 @@ TEST_F(CacheManagerHostTest, AddRemoveRendererTest) {
EXPECT_EQ(0U, inactive_renderers(h).size());
}
-TEST_F(CacheManagerHostTest, ActiveInactiveTest) {
- CacheManagerHost* h = CacheManagerHost::GetInstance();
+TEST_F(WebCacheManagerTest, ActiveInactiveTest) {
+ WebCacheManager* h = WebCacheManager::GetInstance();
h->Add(kRendererID);
@@ -151,8 +151,8 @@ TEST_F(CacheManagerHostTest, ActiveInactiveTest) {
h->Remove(kRendererID);
}
-TEST_F(CacheManagerHostTest, ObserveStatsTest) {
- CacheManagerHost* h = CacheManagerHost::GetInstance();
+TEST_F(WebCacheManagerTest, ObserveStatsTest) {
+ WebCacheManager* h = WebCacheManager::GetInstance();
h->Add(kRendererID);
@@ -166,8 +166,8 @@ TEST_F(CacheManagerHostTest, ObserveStatsTest) {
h->Remove(kRendererID);
}
-TEST_F(CacheManagerHostTest, SetGlobalSizeLimitTest) {
- CacheManagerHost* h = CacheManagerHost::GetInstance();
+TEST_F(WebCacheManagerTest, SetGlobalSizeLimitTest) {
+ WebCacheManager* h = WebCacheManager::GetInstance();
size_t limit = h->GetDefaultGlobalSizeLimit();
h->SetGlobalSizeLimit(limit);
@@ -177,8 +177,8 @@ TEST_F(CacheManagerHostTest, SetGlobalSizeLimitTest) {
EXPECT_EQ(0U, h->global_size_limit());
}
-TEST_F(CacheManagerHostTest, GatherStatsTest) {
- CacheManagerHost* h = CacheManagerHost::GetInstance();
+TEST_F(WebCacheManagerTest, GatherStatsTest) {
+ WebCacheManager* h = WebCacheManager::GetInstance();
h->Add(kRendererID);
h->Add(kRendererID2);
@@ -189,7 +189,7 @@ TEST_F(CacheManagerHostTest, GatherStatsTest) {
std::set<int> renderer_set;
renderer_set.insert(kRendererID);
- CacheManager::UsageStats stats;
+ WebCache::UsageStats stats;
GatherStats(h, renderer_set, &stats);
EXPECT_TRUE(kStats == stats);
@@ -197,12 +197,12 @@ TEST_F(CacheManagerHostTest, GatherStatsTest) {
renderer_set.insert(kRendererID2);
GatherStats(h, renderer_set, &stats);
- CacheManager::UsageStats expected_stats = kStats;
- expected_stats.min_dead_capacity += kStats2.min_dead_capacity;
- expected_stats.max_dead_capacity += kStats2.max_dead_capacity;
+ WebCache::UsageStats expected_stats = kStats;
+ expected_stats.minDeadCapacity += kStats2.minDeadCapacity;
+ expected_stats.maxDeadCapacity += kStats2.maxDeadCapacity;
expected_stats.capacity += kStats2.capacity;
- expected_stats.live_size += kStats2.live_size;
- expected_stats.dead_size += kStats2.dead_size;
+ expected_stats.liveSize += kStats2.liveSize;
+ expected_stats.deadSize += kStats2.deadSize;
EXPECT_TRUE(expected_stats == stats);
@@ -210,7 +210,7 @@ TEST_F(CacheManagerHostTest, GatherStatsTest) {
h->Remove(kRendererID2);
}
-TEST_F(CacheManagerHostTest, GetSizeTest) {
+TEST_F(WebCacheManagerTest, GetSizeTest) {
EXPECT_EQ(0U, GetSize(DIVIDE_EVENLY, kStats));
EXPECT_LT(256 * 1024u + 512, GetSize(KEEP_CURRENT_WITH_HEADROOM, kStats));
EXPECT_EQ(256 * 1024u + 512, GetSize(KEEP_CURRENT, kStats));
@@ -218,8 +218,8 @@ TEST_F(CacheManagerHostTest, GetSizeTest) {
EXPECT_EQ(256 * 1024u, GetSize(KEEP_LIVE, kStats));
}
-TEST_F(CacheManagerHostTest, AttemptTacticTest) {
- CacheManagerHost* h = CacheManagerHost::GetInstance();
+TEST_F(WebCacheManagerTest, AttemptTacticTest) {
+ WebCacheManager* h = WebCacheManager::GetInstance();
h->Add(kRendererID);
h->Add(kRendererID2);
@@ -230,8 +230,8 @@ TEST_F(CacheManagerHostTest, AttemptTacticTest) {
h->ObserveStats(kRendererID, kStats);
h->ObserveStats(kRendererID2, kStats2);
- h->SetGlobalSizeLimit(kStats.live_size + kStats.dead_size +
- kStats2.live_size + kStats2.dead_size/2);
+ h->SetGlobalSizeLimit(kStats.liveSize + kStats.deadSize +
+ kStats2.liveSize + kStats2.deadSize/2);
AllocationStrategy strategy;
@@ -254,9 +254,9 @@ TEST_F(CacheManagerHostTest, AttemptTacticTest) {
AllocationStrategy::iterator iter = strategy.begin();
while (iter != strategy.end()) {
if (iter->first == kRendererID)
- EXPECT_LE(kStats.live_size + kStats.dead_size, iter->second);
+ EXPECT_LE(kStats.liveSize + kStats.deadSize, iter->second);
else if (iter->first == kRendererID2)
- EXPECT_LE(kStats2.live_size, iter->second);
+ EXPECT_LE(kStats2.liveSize, iter->second);
else
EXPECT_FALSE("Unexpected entry in strategy");
++iter;
@@ -266,8 +266,8 @@ TEST_F(CacheManagerHostTest, AttemptTacticTest) {
h->Remove(kRendererID2);
}
-TEST_F(CacheManagerHostTest, AddToStrategyTest) {
- CacheManagerHost* h = CacheManagerHost::GetInstance();
+TEST_F(WebCacheManagerTest, AddToStrategyTest) {
+ WebCacheManager* h = WebCacheManager::GetInstance();
h->Add(kRendererID);
h->Add(kRendererID2);
@@ -296,17 +296,17 @@ TEST_F(CacheManagerHostTest, AddToStrategyTest) {
total_bytes += iter->second;
if (iter->first == kRendererID)
- EXPECT_LE(kStats.live_size + kStats.dead_size, iter->second);
+ EXPECT_LE(kStats.liveSize + kStats.deadSize, iter->second);
else if (iter->first == kRendererID2)
- EXPECT_LE(kStats2.live_size + kStats2.dead_size, iter->second);
+ EXPECT_LE(kStats2.liveSize + kStats2.deadSize, iter->second);
else
EXPECT_FALSE("Unexpected entry in strategy");
++iter;
}
size_t expected_total_bytes = kExtraBytesToAllocate +
- kStats.live_size + kStats.dead_size +
- kStats2.live_size + kStats2.dead_size;
+ kStats.liveSize + kStats.deadSize +
+ kStats2.liveSize + kStats2.deadSize;
EXPECT_GE(expected_total_bytes, total_bytes);
diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc
index f377c96..a6fc32c 100644
--- a/chrome/browser/tab_contents/web_contents.cc
+++ b/chrome/browser/tab_contents/web_contents.cc
@@ -29,6 +29,7 @@
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
+#include "chrome/browser/renderer_host/web_cache_manager.h"
#include "chrome/browser/search_engines/template_url_model.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/provisional_load_details.h"
@@ -49,7 +50,6 @@
#if defined(OS_WIN)
// TODO(port): fill these in as we flesh out the implementation of this class
-#include "chrome/browser/cache_manager_host.h"
#include "chrome/browser/download/download_request_manager.h"
#include "chrome/browser/modal_html_dialog_delegate.h"
#include "chrome/browser/plugin_service.h"
@@ -471,7 +471,7 @@ void WebContents::DidBecomeSelected() {
// If pid() is -1, that means the RenderProcessHost still hasn't been
// initialized. It'll register with CacheManagerHost when it is.
if (process()->pid() != -1)
- CacheManagerHost::GetInstance()->ObserveActivity(process()->pid());
+ WebCacheManager::GetInstance()->ObserveActivity(process()->pid());
}
void WebContents::WasHidden() {
diff --git a/chrome/browser/task_manager.h b/chrome/browser/task_manager.h
index ab27fef..8f67eb8 100644
--- a/chrome/browser/task_manager.h
+++ b/chrome/browser/task_manager.h
@@ -13,7 +13,7 @@
#include "base/singleton.h"
#include "base/ref_counted.h"
#include "base/timer.h"
-#include "chrome/browser/cache_manager_host.h"
+#include "chrome/browser/renderer_host/web_cache_manager.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/views/controls/table/group_table_view.h"
#include "chrome/views/window/dialog_delegate.h"