OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "core/fetch/MemoryCache.h" | 33 #include "core/fetch/MemoryCache.h" |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
36 | 36 |
37 // A helper method for coverting a MemoryCache::TypeStatistic to a | 37 // A helper method for coverting a MemoryCache::TypeStatistic to a |
38 // WebCache::ResourceTypeStat. | 38 // WebCache::ResourceTypeStat. |
39 static void ToResourceTypeStat(const MemoryCache::TypeStatistic& from, | 39 static void ToResourceTypeStat(const MemoryCache::TypeStatistic& from, |
40 WebCache::ResourceTypeStat& to) { | 40 WebCache::ResourceTypeStat& to) { |
41 to.count = from.count; | 41 to.count = from.count; |
42 to.size = from.size; | 42 to.size = from.size; |
43 // TODO(hiroshige): remove |liveSize| as it is no longer meaningful. | |
44 to.liveSize = from.size; | |
45 to.decodedSize = from.decodedSize; | 43 to.decodedSize = from.decodedSize; |
46 } | 44 } |
47 | 45 |
48 // TODO(hiroshige): remove parameters that are no longer meaningful. | 46 void WebCache::setCapacity(size_t capacity) { |
49 void WebCache::setCapacities(size_t, size_t, size_t capacity) { | |
50 MemoryCache* cache = memoryCache(); | 47 MemoryCache* cache = memoryCache(); |
51 if (cache) | 48 if (cache) |
52 cache->setCapacity(static_cast<unsigned>(capacity)); | 49 cache->setCapacity(static_cast<unsigned>(capacity)); |
53 } | 50 } |
54 | 51 |
55 void WebCache::clear() { | 52 void WebCache::clear() { |
56 MemoryCache* cache = memoryCache(); | 53 MemoryCache* cache = memoryCache(); |
57 if (cache) | 54 if (cache) |
58 cache->evictResources(); | 55 cache->evictResources(); |
59 } | 56 } |
60 | 57 |
61 void WebCache::getUsageStats(UsageStats* result) { | 58 void WebCache::getUsageStats(UsageStats* result) { |
62 DCHECK(result); | 59 DCHECK(result); |
63 | 60 |
64 MemoryCache* cache = memoryCache(); | 61 MemoryCache* cache = memoryCache(); |
65 if (cache) { | 62 if (cache) { |
66 // TODO(hiroshige): remove members that are no longer meaningful. | |
67 result->minDeadCapacity = 0; | |
68 result->maxDeadCapacity = 0; | |
69 result->capacity = cache->capacity(); | 63 result->capacity = cache->capacity(); |
70 result->liveSize = cache->size(); | 64 result->size = cache->size(); |
71 result->deadSize = 0; | |
72 } else | 65 } else |
73 memset(result, 0, sizeof(UsageStats)); | 66 memset(result, 0, sizeof(UsageStats)); |
74 } | 67 } |
75 | 68 |
76 void WebCache::getResourceTypeStats(ResourceTypeStats* result) { | 69 void WebCache::getResourceTypeStats(ResourceTypeStats* result) { |
77 MemoryCache* cache = memoryCache(); | 70 MemoryCache* cache = memoryCache(); |
78 if (cache) { | 71 if (cache) { |
79 MemoryCache::Statistics stats = cache->getStatistics(); | 72 MemoryCache::Statistics stats = cache->getStatistics(); |
80 ToResourceTypeStat(stats.images, result->images); | 73 ToResourceTypeStat(stats.images, result->images); |
81 ToResourceTypeStat(stats.cssStyleSheets, result->cssStyleSheets); | 74 ToResourceTypeStat(stats.cssStyleSheets, result->cssStyleSheets); |
82 ToResourceTypeStat(stats.scripts, result->scripts); | 75 ToResourceTypeStat(stats.scripts, result->scripts); |
83 ToResourceTypeStat(stats.xslStyleSheets, result->xslStyleSheets); | 76 ToResourceTypeStat(stats.xslStyleSheets, result->xslStyleSheets); |
84 ToResourceTypeStat(stats.fonts, result->fonts); | 77 ToResourceTypeStat(stats.fonts, result->fonts); |
85 ToResourceTypeStat(stats.other, result->other); | 78 ToResourceTypeStat(stats.other, result->other); |
86 } else | 79 } else |
87 memset(result, 0, sizeof(WebCache::ResourceTypeStats)); | 80 memset(result, 0, sizeof(WebCache::ResourceTypeStats)); |
88 } | 81 } |
89 | 82 |
90 } // namespace blink | 83 } // namespace blink |
OLD | NEW |