This source file includes following definitions.
- ToResourceTypeStat
- setCapacities
- clear
- getUsageStats
- getResourceTypeStats
#include "config.h"
#include "WebCache.h"
#include "core/fetch/MemoryCache.h"
using WebCore::MemoryCache;
namespace blink {
static void ToResourceTypeStat(const MemoryCache::TypeStatistic& from,
WebCache::ResourceTypeStat& to)
{
to.count = static_cast<size_t>(from.count);
to.size = static_cast<size_t>(from.size);
to.liveSize = static_cast<size_t>(from.liveSize);
to.decodedSize = static_cast<size_t>(from.decodedSize);
}
void WebCache::setCapacities(
size_t minDeadCapacity, size_t maxDeadCapacity, size_t capacity)
{
MemoryCache* cache = WebCore::memoryCache();
if (cache)
cache->setCapacities(static_cast<unsigned>(minDeadCapacity), static_cast<unsigned>(maxDeadCapacity), static_cast<unsigned>(capacity));
}
void WebCache::clear()
{
MemoryCache* cache = WebCore::memoryCache();
if (cache)
cache->evictResources();
}
void WebCache::getUsageStats(UsageStats* result)
{
ASSERT(result);
MemoryCache* cache = WebCore::memoryCache();
if (cache) {
result->minDeadCapacity = cache->minDeadCapacity();
result->maxDeadCapacity = cache->maxDeadCapacity();
result->capacity = cache->capacity();
result->liveSize = cache->liveSize();
result->deadSize = cache->deadSize();
} else
memset(result, 0, sizeof(UsageStats));
}
void WebCache::getResourceTypeStats(ResourceTypeStats* result)
{
MemoryCache* cache = WebCore::memoryCache();
if (cache) {
MemoryCache::Statistics stats = cache->getStatistics();
ToResourceTypeStat(stats.images, result->images);
ToResourceTypeStat(stats.cssStyleSheets, result->cssStyleSheets);
ToResourceTypeStat(stats.scripts, result->scripts);
ToResourceTypeStat(stats.xslStyleSheets, result->xslStyleSheets);
ToResourceTypeStat(stats.fonts, result->fonts);
} else
memset(result, 0, sizeof(WebCache::ResourceTypeStats));
}
}