Home | History | Annotate | Download | only in cache

Lines Matching refs:Resource

29 #include "core/loader/cache/Resource.h"
99 void MemoryCache::add(Resource* resource)
102 m_resources.set(resource->url(), resource);
103 resource->setInCache(true);
104 resource->updateForAccess();
106 LOG(ResourceLoading, "MemoryCache::add Added '%s', resource %p\n", resource->url().string().latin1().data(), resource);
109 void MemoryCache::replace(Resource* newResource, Resource* oldResource)
123 Resource* MemoryCache::resourceForURL(const KURL& resourceURL)
127 Resource* resource = m_resources.get(url);
128 if (resource && !resource->makePurgeable(false)) {
129 ASSERT(!resource->hasClients());
130 evict(resource);
133 return resource;
138 // Dead resource capacity is whatever space is not occupied by live resources, bounded by an independent minimum and maximum.
147 // Live resource capacity is whatever is left over after calculating dead resource capacity.
174 for (int priority = Resource::CacheLiveResourcePriorityLow; priority <= Resource::CacheLiveResourcePriorityHigh; ++priority) {
175 Resource* current = m_liveDecodedResources[priority].m_tail;
177 Resource* prev = current->m_prevInLiveResourcesList;
210 Resource* current = m_allResources[i].m_tail;
212 Resource* prev = current->m_prevInAllResourcesList;
227 Resource* current = m_allResources[i].m_tail;
232 ResourcePtr<Resource> previous = current->m_prevInAllResourcesList;
253 ResourcePtr<Resource> previous = current->m_prevInAllResourcesList;
284 void MemoryCache::evict(Resource* resource)
287 LOG(ResourceLoading, "Evicting resource %p for '%s' from cache", resource, resource->url().string().latin1().data());
288 // The resource may have already been removed by someone other than our caller,
290 if (resource->inCache()) {
291 // Remove from the resource map.
292 m_resources.remove(resource->url());
293 resource->setInCache(false);
296 removeFromLRUList(resource);
297 removeFromLiveDecodedResourcesList(resource);
298 adjustSize(resource->hasClients(), -static_cast<int>(resource->size()));
300 ASSERT(m_resources.get(resource->url()) != resource);
302 resource->deleteIfPossible();
305 MemoryCache::LRUList* MemoryCache::lruListFor(Resource* resource)
307 unsigned accessCount = max(resource->accessCount(), 1U);
308 unsigned queueIndex = WTF::fastLog2(resource->size() / accessCount);
310 resource->m_lruIndex = queueIndex;
317 void MemoryCache::removeFromLRUList(Resource* resource)
320 if (resource->accessCount() == 0)
324 unsigned oldListIndex = resource->m_lruIndex;
327 LRUList* list = lruListFor(resource);
331 ASSERT(resource->m_lruIndex == oldListIndex);
335 for (Resource* current = list->m_head; current; current = current->m_nextInAllResourcesList) {
336 if (current == resource) {
344 Resource* next = resource->m_nextInAllResourcesList;
345 Resource* prev = resource->m_prevInAllResourcesList;
347 if (next == 0 && prev == 0 && list->m_head != resource)
350 resource->m_nextInAllResourcesList = 0;
351 resource->m_prevInAllResourcesList = 0;
355 else if (list->m_tail == resource)
360 else if (list->m_head == resource)
364 void MemoryCache::insertInLRUList(Resource* resource)
367 ASSERT(!resource->m_nextInAllResourcesList && !resource->m_prevInAllResourcesList);
368 ASSERT(resource->inCache());
369 ASSERT(resource->accessCount() > 0);
371 LRUList* list = lruListFor(resource);
373 resource->m_nextInAllResourcesList = list->m_head;
375 list->m_head->m_prevInAllResourcesList = resource;
376 list->m_head = resource;
378 if (!resource->m_nextInAllResourcesList)
379 list->m_tail = resource;
383 list = lruListFor(resource);
385 for (Resource* current = list->m_head; current; current = current->m_nextInAllResourcesList) {
386 if (current == resource) {
396 void MemoryCache::removeFromLiveDecodedResourcesList(Resource* resource)
399 if (!resource->m_inLiveDecodedResourcesList)
401 resource->m_inLiveDecodedResourcesList = false;
403 LRUList* list = &m_liveDecodedResources[resource->cacheLiveResourcePriority()];
408 for (Resource* current = list->m_head; current; current = current->m_nextInLiveResourcesList) {
409 if (current == resource) {
417 Resource* next = resource->m_nextInLiveResourcesList;
418 Resource* prev = resource->m_prevInLiveResourcesList;
420 if (!next && !prev && list->m_head != resource)
423 resource->m_nextInLiveResourcesList = 0;
424 resource->m_prevInLiveResourcesList = 0;
428 else if (list->m_tail == resource)
433 else if (list->m_head == resource)
437 void MemoryCache::insertInLiveDecodedResourcesList(Resource* resource)
440 ASSERT(!resource->m_nextInLiveResourcesList && !resource->m_prevInLiveResourcesList && !resource->m_inLiveDecodedResourcesList);
441 resource->m_inLiveDecodedResourcesList = true;
443 LRUList* list = &m_liveDecodedResources[resource->cacheLiveResourcePriority()];
444 resource->m_nextInLiveResourcesList = list->m_head;
446 list->m_head->m_prevInLiveResourcesList = resource;
447 list->m_head = resource;
449 if (!resource->m_nextInLiveResourcesList)
450 list->m_tail = resource;
455 for (Resource* current = list->m_head; current; current = current->m_nextInLiveResourcesList) {
456 if (current == resource) {
466 void MemoryCache::addToLiveResourcesSize(Resource* resource)
468 m_liveSize += resource->size();
469 resource->size();
472 void MemoryCache::removeFromLiveResourcesSize(Resource* resource)
474 m_liveSize -= resource->size();
475 m_deadSize += resource->size();
501 if (Resource* resource = memoryCache()->resourceForURL(url))
502 memoryCache()->remove(resource);
505 void MemoryCache::TypeStatistic::addResource(Resource* o)
525 Resource* resource = i->value;
526 switch (resource->type()) {
527 case Resource::Image:
528 stats.images.addResource(resource);
530 case Resource::CSSStyleSheet:
531 stats.cssStyleSheets.addResource(resource);
533 case Resource::Script:
534 stats.scripts.addResource(resource);
536 case Resource::XSLStyleSheet:
537 stats.xslStyleSheets.addResource(resource);
539 case Resource::Font:
540 stats.fonts.addResource(resource);
543 stats.other.addResource(resource);
604 Resource* current = m_allResources[i].m_tail;
606 Resource* prev = current->m_prevInAllResourcesList;