Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: Source/web/WebCache.cpp

Issue 468083003: Cleanup namespace usage in Source/web/Web[A-H]*.cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebasing Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/web/WebBlob.cpp ('k') | Source/web/WebCachedURLRequest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 blink::MemoryCache;
37
38 namespace blink { 36 namespace blink {
39 37
40 // A helper method for coverting a MemoryCache::TypeStatistic to a 38 // A helper method for coverting a MemoryCache::TypeStatistic to a
41 // WebCache::ResourceTypeStat. 39 // WebCache::ResourceTypeStat.
42 static void ToResourceTypeStat(const MemoryCache::TypeStatistic& from, 40 static void ToResourceTypeStat(const MemoryCache::TypeStatistic& from,
43 WebCache::ResourceTypeStat& to) 41 WebCache::ResourceTypeStat& to)
44 { 42 {
45 to.count = static_cast<size_t>(from.count); 43 to.count = static_cast<size_t>(from.count);
46 to.size = static_cast<size_t>(from.size); 44 to.size = static_cast<size_t>(from.size);
47 to.liveSize = static_cast<size_t>(from.liveSize); 45 to.liveSize = static_cast<size_t>(from.liveSize);
48 to.decodedSize = static_cast<size_t>(from.decodedSize); 46 to.decodedSize = static_cast<size_t>(from.decodedSize);
49 } 47 }
50 48
51 void WebCache::setCapacities( 49 void WebCache::setCapacities(
52 size_t minDeadCapacity, size_t maxDeadCapacity, size_t capacity) 50 size_t minDeadCapacity, size_t maxDeadCapacity, size_t capacity)
53 { 51 {
54 MemoryCache* cache = blink::memoryCache(); 52 MemoryCache* cache = memoryCache();
55 if (cache) 53 if (cache)
56 cache->setCapacities(static_cast<unsigned>(minDeadCapacity), static_cast <unsigned>(maxDeadCapacity), static_cast<unsigned>(capacity)); 54 cache->setCapacities(static_cast<unsigned>(minDeadCapacity), static_cast <unsigned>(maxDeadCapacity), static_cast<unsigned>(capacity));
57 } 55 }
58 56
59 void WebCache::clear() 57 void WebCache::clear()
60 { 58 {
61 MemoryCache* cache = blink::memoryCache(); 59 MemoryCache* cache = memoryCache();
62 if (cache) 60 if (cache)
63 cache->evictResources(); 61 cache->evictResources();
64 } 62 }
65 63
66 void WebCache::getUsageStats(UsageStats* result) 64 void WebCache::getUsageStats(UsageStats* result)
67 { 65 {
68 ASSERT(result); 66 ASSERT(result);
69 67
70 MemoryCache* cache = blink::memoryCache(); 68 MemoryCache* cache = memoryCache();
71 if (cache) { 69 if (cache) {
72 result->minDeadCapacity = cache->minDeadCapacity(); 70 result->minDeadCapacity = cache->minDeadCapacity();
73 result->maxDeadCapacity = cache->maxDeadCapacity(); 71 result->maxDeadCapacity = cache->maxDeadCapacity();
74 result->capacity = cache->capacity(); 72 result->capacity = cache->capacity();
75 result->liveSize = cache->liveSize(); 73 result->liveSize = cache->liveSize();
76 result->deadSize = cache->deadSize(); 74 result->deadSize = cache->deadSize();
77 } else 75 } else
78 memset(result, 0, sizeof(UsageStats)); 76 memset(result, 0, sizeof(UsageStats));
79 } 77 }
80 78
81 void WebCache::getResourceTypeStats(ResourceTypeStats* result) 79 void WebCache::getResourceTypeStats(ResourceTypeStats* result)
82 { 80 {
83 MemoryCache* cache = blink::memoryCache(); 81 MemoryCache* cache = memoryCache();
84 if (cache) { 82 if (cache) {
85 MemoryCache::Statistics stats = cache->getStatistics(); 83 MemoryCache::Statistics stats = cache->getStatistics();
86 ToResourceTypeStat(stats.images, result->images); 84 ToResourceTypeStat(stats.images, result->images);
87 ToResourceTypeStat(stats.cssStyleSheets, result->cssStyleSheets); 85 ToResourceTypeStat(stats.cssStyleSheets, result->cssStyleSheets);
88 ToResourceTypeStat(stats.scripts, result->scripts); 86 ToResourceTypeStat(stats.scripts, result->scripts);
89 ToResourceTypeStat(stats.xslStyleSheets, result->xslStyleSheets); 87 ToResourceTypeStat(stats.xslStyleSheets, result->xslStyleSheets);
90 ToResourceTypeStat(stats.fonts, result->fonts); 88 ToResourceTypeStat(stats.fonts, result->fonts);
91 } else 89 } else
92 memset(result, 0, sizeof(WebCache::ResourceTypeStats)); 90 memset(result, 0, sizeof(WebCache::ResourceTypeStats));
93 } 91 }
94 92
95 } // namespace blink 93 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebBlob.cpp ('k') | Source/web/WebCachedURLRequest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698