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 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "public/web/WebCache.h" | 32 #include "public/web/WebCache.h" |
33 | 33 |
34 #include "core/fetch/MemoryCache.h" | 34 #include "core/fetch/MemoryCache.h" |
35 | 35 |
36 using WebCore::MemoryCache; | 36 using blink::MemoryCache; |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 // A helper method for coverting a MemoryCache::TypeStatistic to a | 40 // A helper method for coverting a MemoryCache::TypeStatistic to a |
41 // WebCache::ResourceTypeStat. | 41 // WebCache::ResourceTypeStat. |
42 static void ToResourceTypeStat(const MemoryCache::TypeStatistic& from, | 42 static void ToResourceTypeStat(const MemoryCache::TypeStatistic& from, |
43 WebCache::ResourceTypeStat& to) | 43 WebCache::ResourceTypeStat& to) |
44 { | 44 { |
45 to.count = static_cast<size_t>(from.count); | 45 to.count = static_cast<size_t>(from.count); |
46 to.size = static_cast<size_t>(from.size); | 46 to.size = static_cast<size_t>(from.size); |
47 to.liveSize = static_cast<size_t>(from.liveSize); | 47 to.liveSize = static_cast<size_t>(from.liveSize); |
48 to.decodedSize = static_cast<size_t>(from.decodedSize); | 48 to.decodedSize = static_cast<size_t>(from.decodedSize); |
49 } | 49 } |
50 | 50 |
51 void WebCache::setCapacities( | 51 void WebCache::setCapacities( |
52 size_t minDeadCapacity, size_t maxDeadCapacity, size_t capacity) | 52 size_t minDeadCapacity, size_t maxDeadCapacity, size_t capacity) |
53 { | 53 { |
54 MemoryCache* cache = WebCore::memoryCache(); | 54 MemoryCache* cache = blink::memoryCache(); |
55 if (cache) | 55 if (cache) |
56 cache->setCapacities(static_cast<unsigned>(minDeadCapacity), static_cast
<unsigned>(maxDeadCapacity), static_cast<unsigned>(capacity)); | 56 cache->setCapacities(static_cast<unsigned>(minDeadCapacity), static_cast
<unsigned>(maxDeadCapacity), static_cast<unsigned>(capacity)); |
57 } | 57 } |
58 | 58 |
59 void WebCache::clear() | 59 void WebCache::clear() |
60 { | 60 { |
61 MemoryCache* cache = WebCore::memoryCache(); | 61 MemoryCache* cache = blink::memoryCache(); |
62 if (cache) | 62 if (cache) |
63 cache->evictResources(); | 63 cache->evictResources(); |
64 } | 64 } |
65 | 65 |
66 void WebCache::getUsageStats(UsageStats* result) | 66 void WebCache::getUsageStats(UsageStats* result) |
67 { | 67 { |
68 ASSERT(result); | 68 ASSERT(result); |
69 | 69 |
70 MemoryCache* cache = WebCore::memoryCache(); | 70 MemoryCache* cache = blink::memoryCache(); |
71 if (cache) { | 71 if (cache) { |
72 result->minDeadCapacity = cache->minDeadCapacity(); | 72 result->minDeadCapacity = cache->minDeadCapacity(); |
73 result->maxDeadCapacity = cache->maxDeadCapacity(); | 73 result->maxDeadCapacity = cache->maxDeadCapacity(); |
74 result->capacity = cache->capacity(); | 74 result->capacity = cache->capacity(); |
75 result->liveSize = cache->liveSize(); | 75 result->liveSize = cache->liveSize(); |
76 result->deadSize = cache->deadSize(); | 76 result->deadSize = cache->deadSize(); |
77 } else | 77 } else |
78 memset(result, 0, sizeof(UsageStats)); | 78 memset(result, 0, sizeof(UsageStats)); |
79 } | 79 } |
80 | 80 |
81 void WebCache::getResourceTypeStats(ResourceTypeStats* result) | 81 void WebCache::getResourceTypeStats(ResourceTypeStats* result) |
82 { | 82 { |
83 MemoryCache* cache = WebCore::memoryCache(); | 83 MemoryCache* cache = blink::memoryCache(); |
84 if (cache) { | 84 if (cache) { |
85 MemoryCache::Statistics stats = cache->getStatistics(); | 85 MemoryCache::Statistics stats = cache->getStatistics(); |
86 ToResourceTypeStat(stats.images, result->images); | 86 ToResourceTypeStat(stats.images, result->images); |
87 ToResourceTypeStat(stats.cssStyleSheets, result->cssStyleSheets); | 87 ToResourceTypeStat(stats.cssStyleSheets, result->cssStyleSheets); |
88 ToResourceTypeStat(stats.scripts, result->scripts); | 88 ToResourceTypeStat(stats.scripts, result->scripts); |
89 ToResourceTypeStat(stats.xslStyleSheets, result->xslStyleSheets); | 89 ToResourceTypeStat(stats.xslStyleSheets, result->xslStyleSheets); |
90 ToResourceTypeStat(stats.fonts, result->fonts); | 90 ToResourceTypeStat(stats.fonts, result->fonts); |
91 } else | 91 } else |
92 memset(result, 0, sizeof(WebCache::ResourceTypeStats)); | 92 memset(result, 0, sizeof(WebCache::ResourceTypeStats)); |
93 } | 93 } |
94 | 94 |
95 } // namespace blink | 95 } // namespace blink |
OLD | NEW |