| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
| 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
| 5 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 6 | 6 |
| 7 This library is free software; you can redistribute it and/or | 7 This library is free software; you can redistribute it and/or |
| 8 modify it under the terms of the GNU Library General Public | 8 modify it under the terms of the GNU Library General Public |
| 9 License as published by the Free Software Foundation; either | 9 License as published by the Free Software Foundation; either |
| 10 version 2 of the License, or (at your option) any later version. | 10 version 2 of the License, or (at your option) any later version. |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 ASSERT(WTF::isMainThread()); | 169 ASSERT(WTF::isMainThread()); |
| 170 ASSERT(resource->url().isValid()); | 170 ASSERT(resource->url().isValid()); |
| 171 ResourceMap* resources = ensureResourceMap(resource->cacheIdentifier()); | 171 ResourceMap* resources = ensureResourceMap(resource->cacheIdentifier()); |
| 172 RELEASE_ASSERT(!resources->contains(resource->url())); | 172 RELEASE_ASSERT(!resources->contains(resource->url())); |
| 173 resources->set(resource->url(), MemoryCacheEntry::create(resource)); | 173 resources->set(resource->url(), MemoryCacheEntry::create(resource)); |
| 174 update(resource, 0, resource->size(), true); | 174 update(resource, 0, resource->size(), true); |
| 175 | 175 |
| 176 WTF_LOG(ResourceLoading, "MemoryCache::add Added '%s', resource %p\n", resou
rce->url().string().latin1().data(), resource); | 176 WTF_LOG(ResourceLoading, "MemoryCache::add Added '%s', resource %p\n", resou
rce->url().string().latin1().data(), resource); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void MemoryCache::replace(Resource* newResource, Resource* oldResource) | |
| 180 { | |
| 181 ASSERT(newResource->cacheIdentifier() == oldResource->cacheIdentifier()); | |
| 182 ResourceMap* resources = ensureResourceMap(oldResource->cacheIdentifier()); | |
| 183 if (MemoryCacheEntry* oldEntry = resources->get(oldResource->url())) | |
| 184 evict(oldEntry); | |
| 185 add(newResource); | |
| 186 if (newResource->decodedSize() && newResource->hasClients()) | |
| 187 insertInLiveDecodedResourcesList(resources->get(newResource->url())); | |
| 188 } | |
| 189 | |
| 190 void MemoryCache::remove(Resource* resource) | 179 void MemoryCache::remove(Resource* resource) |
| 191 { | 180 { |
| 192 // The resource may have already been removed by someone other than our call
er, | 181 // The resource may have already been removed by someone other than our call
er, |
| 193 // who needed a fresh copy for a reload. | 182 // who needed a fresh copy for a reload. |
| 194 if (MemoryCacheEntry* entry = getEntryForResource(resource)) | 183 if (MemoryCacheEntry* entry = getEntryForResource(resource)) |
| 195 evict(entry); | 184 evict(entry); |
| 196 } | 185 } |
| 197 | 186 |
| 198 bool MemoryCache::contains(const Resource* resource) const | 187 bool MemoryCache::contains(const Resource* resource) const |
| 199 { | 188 { |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 printf("(%.1fK, %.1fK, %uA, %dR, %d, %d); ", currentResource->de
codedSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overhe
adSize()) / 1024.0f, current->m_accessCount, currentResource->hasClients(), curr
entResource->isPurgeable(), currentResource->wasPurged()); | 836 printf("(%.1fK, %.1fK, %uA, %dR, %d, %d); ", currentResource->de
codedSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overhe
adSize()) / 1024.0f, current->m_accessCount, currentResource->hasClients(), curr
entResource->isPurgeable(), currentResource->wasPurged()); |
| 848 | 837 |
| 849 current = current->m_previousInAllResourcesList; | 838 current = current->m_previousInAllResourcesList; |
| 850 } | 839 } |
| 851 } | 840 } |
| 852 } | 841 } |
| 853 | 842 |
| 854 #endif // MEMORY_CACHE_STATS | 843 #endif // MEMORY_CACHE_STATS |
| 855 | 844 |
| 856 } // namespace blink | 845 } // namespace blink |
| OLD | NEW |