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

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

Issue 2411243004: [WeakMemoryCache] Remove LRU lists, prune order control and live/dead distinction (Closed)
Patch Set: Reflect yhirano's comment Created 4 years, 1 month 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 | « third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp ('k') | no next file » | 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 22 matching lines...) Expand all
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 to.liveSize = from.liveSize; 43 // TODO(hiroshige): remove |liveSize| as it is no longer meaningful.
44 to.liveSize = from.size;
44 to.decodedSize = from.decodedSize; 45 to.decodedSize = from.decodedSize;
45 } 46 }
46 47
47 void WebCache::setCapacities(size_t minDeadCapacity, 48 // TODO(hiroshige): remove parameters that are no longer meaningful.
48 size_t maxDeadCapacity, 49 void WebCache::setCapacities(size_t, size_t, size_t capacity) {
49 size_t capacity) {
50 MemoryCache* cache = memoryCache(); 50 MemoryCache* cache = memoryCache();
51 if (cache) 51 if (cache)
52 cache->setCapacities(static_cast<unsigned>(minDeadCapacity), 52 cache->setCapacity(static_cast<unsigned>(capacity));
53 static_cast<unsigned>(maxDeadCapacity),
54 static_cast<unsigned>(capacity));
55 } 53 }
56 54
57 void WebCache::clear() { 55 void WebCache::clear() {
58 MemoryCache* cache = memoryCache(); 56 MemoryCache* cache = memoryCache();
59 if (cache) 57 if (cache)
60 cache->evictResources(); 58 cache->evictResources();
61 } 59 }
62 60
63 void WebCache::getUsageStats(UsageStats* result) { 61 void WebCache::getUsageStats(UsageStats* result) {
64 DCHECK(result); 62 DCHECK(result);
65 63
66 MemoryCache* cache = memoryCache(); 64 MemoryCache* cache = memoryCache();
67 if (cache) { 65 if (cache) {
68 result->minDeadCapacity = cache->minDeadCapacity(); 66 // TODO(hiroshige): remove members that are no longer meaningful.
69 result->maxDeadCapacity = cache->maxDeadCapacity(); 67 result->minDeadCapacity = 0;
68 result->maxDeadCapacity = 0;
70 result->capacity = cache->capacity(); 69 result->capacity = cache->capacity();
71 result->liveSize = cache->liveSize(); 70 result->liveSize = cache->size();
72 result->deadSize = cache->deadSize(); 71 result->deadSize = 0;
73 } else 72 } else
74 memset(result, 0, sizeof(UsageStats)); 73 memset(result, 0, sizeof(UsageStats));
75 } 74 }
76 75
77 void WebCache::getResourceTypeStats(ResourceTypeStats* result) { 76 void WebCache::getResourceTypeStats(ResourceTypeStats* result) {
78 MemoryCache* cache = memoryCache(); 77 MemoryCache* cache = memoryCache();
79 if (cache) { 78 if (cache) {
80 MemoryCache::Statistics stats = cache->getStatistics(); 79 MemoryCache::Statistics stats = cache->getStatistics();
81 ToResourceTypeStat(stats.images, result->images); 80 ToResourceTypeStat(stats.images, result->images);
82 ToResourceTypeStat(stats.cssStyleSheets, result->cssStyleSheets); 81 ToResourceTypeStat(stats.cssStyleSheets, result->cssStyleSheets);
83 ToResourceTypeStat(stats.scripts, result->scripts); 82 ToResourceTypeStat(stats.scripts, result->scripts);
84 ToResourceTypeStat(stats.xslStyleSheets, result->xslStyleSheets); 83 ToResourceTypeStat(stats.xslStyleSheets, result->xslStyleSheets);
85 ToResourceTypeStat(stats.fonts, result->fonts); 84 ToResourceTypeStat(stats.fonts, result->fonts);
86 ToResourceTypeStat(stats.other, result->other); 85 ToResourceTypeStat(stats.other, result->other);
87 } else 86 } else
88 memset(result, 0, sizeof(WebCache::ResourceTypeStats)); 87 memset(result, 0, sizeof(WebCache::ResourceTypeStats));
89 } 88 }
90 89
91 } // namespace blink 90 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698