Chromium Code Reviews| 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) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
| 7 | 7 |
| 8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
| 9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
| 10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 , m_loadFinishTime(0) | 102 , m_loadFinishTime(0) |
| 103 , m_identifier(0) | 103 , m_identifier(0) |
| 104 , m_encodedSize(0) | 104 , m_encodedSize(0) |
| 105 , m_decodedSize(0) | 105 , m_decodedSize(0) |
| 106 , m_accessCount(0) | 106 , m_accessCount(0) |
| 107 , m_handleCount(0) | 107 , m_handleCount(0) |
| 108 , m_preloadCount(0) | 108 , m_preloadCount(0) |
| 109 , m_protectorCount(0) | 109 , m_protectorCount(0) |
| 110 , m_preloadResult(PreloadNotReferenced) | 110 , m_preloadResult(PreloadNotReferenced) |
| 111 , m_cacheLiveResourcePriority(CacheLiveResourcePriorityLow) | 111 , m_cacheLiveResourcePriority(CacheLiveResourcePriorityLow) |
| 112 , m_inLiveDecodedResourcesList(false) | |
| 113 , m_requestedFromNetworkingLayer(false) | 112 , m_requestedFromNetworkingLayer(false) |
| 114 , m_inCache(false) | 113 , m_inCache(false) |
| 115 , m_loading(false) | 114 , m_loading(false) |
| 116 , m_switchingClientsToRevalidatedResource(false) | 115 , m_switchingClientsToRevalidatedResource(false) |
| 117 , m_type(type) | 116 , m_type(type) |
| 118 , m_status(Pending) | 117 , m_status(Pending) |
| 119 , m_wasPurged(false) | 118 , m_wasPurged(false) |
| 120 , m_needsSynchronousCacheHit(false) | 119 , m_needsSynchronousCacheHit(false) |
| 121 #ifndef NDEBUG | 120 #ifndef NDEBUG |
| 122 , m_deleted(false) | 121 , m_deleted(false) |
| 123 , m_lruIndex(0) | |
| 124 #endif | 122 #endif |
| 125 , m_nextInAllResourcesList(0) | |
| 126 , m_prevInAllResourcesList(0) | |
| 127 , m_nextInLiveResourcesList(0) | |
| 128 , m_prevInLiveResourcesList(0) | |
| 129 , m_resourceToRevalidate(0) | 123 , m_resourceToRevalidate(0) |
| 130 , m_proxyResource(0) | 124 , m_proxyResource(0) |
| 131 { | 125 { |
| 132 ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests car eless updates of the enum. | 126 ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests car eless updates of the enum. |
| 133 #ifndef NDEBUG | 127 #ifndef NDEBUG |
| 134 cachedResourceLeakCounter.increment(); | 128 cachedResourceLeakCounter.increment(); |
| 135 #endif | 129 #endif |
| 136 | 130 |
| 137 if (!m_resourceRequest.url().hasFragmentIdentifier()) | 131 if (!m_resourceRequest.url().hasFragmentIdentifier()) |
| 138 return; | 132 return; |
| 139 KURL urlForCache = MemoryCache::removeFragmentIdentifierIfNeeded(m_resourceR equest.url()); | 133 KURL urlForCache = MemoryCache::removeFragmentIdentifierIfNeeded(m_resourceR equest.url()); |
| 140 if (urlForCache.hasFragmentIdentifier()) | 134 if (urlForCache.hasFragmentIdentifier()) |
| 141 return; | 135 return; |
| 142 m_fragmentIdentifierForRequest = m_resourceRequest.url().fragmentIdentifier( ); | 136 m_fragmentIdentifierForRequest = m_resourceRequest.url().fragmentIdentifier( ); |
| 143 m_resourceRequest.setURL(urlForCache); | 137 m_resourceRequest.setURL(urlForCache); |
| 144 } | 138 } |
| 145 | 139 |
| 146 Resource::~Resource() | 140 Resource::~Resource() |
| 147 { | 141 { |
| 148 ASSERT(!m_resourceToRevalidate); // Should be true because canDelete() check s this. | 142 ASSERT(!m_resourceToRevalidate); // Should be true because canDelete() check s this. |
| 149 ASSERT(canDelete()); | 143 ASSERT(canDelete()); |
| 150 ASSERT(!inCache()); | 144 RELEASE_ASSERT(!inCache()); |
|
abarth-chromium
2014/02/28 06:31:09
:)
| |
| 151 ASSERT(!m_deleted); | 145 ASSERT(!m_deleted); |
| 152 ASSERT(url().isNull() || memoryCache()->resourceForURL(KURL(ParsedURLString, url())) != this); | 146 ASSERT(url().isNull() || memoryCache()->resourceForURL(KURL(ParsedURLString, url())) != this); |
| 153 | 147 |
| 154 #ifndef NDEBUG | 148 #ifndef NDEBUG |
| 155 m_deleted = true; | 149 m_deleted = true; |
| 156 cachedResourceLeakCounter.decrement(); | 150 cachedResourceLeakCounter.decrement(); |
| 157 #endif | 151 #endif |
| 158 } | 152 } |
| 159 | 153 |
| 160 void Resource::failBeforeStarting() | 154 void Resource::failBeforeStarting() |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 | 409 |
| 416 CachedMetadata* Resource::cachedMetadata(unsigned dataTypeID) const | 410 CachedMetadata* Resource::cachedMetadata(unsigned dataTypeID) const |
| 417 { | 411 { |
| 418 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) | 412 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) |
| 419 return 0; | 413 return 0; |
| 420 return m_cachedMetadata.get(); | 414 return m_cachedMetadata.get(); |
| 421 } | 415 } |
| 422 | 416 |
| 423 void Resource::setCacheLiveResourcePriority(CacheLiveResourcePriority priority) | 417 void Resource::setCacheLiveResourcePriority(CacheLiveResourcePriority priority) |
| 424 { | 418 { |
| 425 if (inCache() && m_inLiveDecodedResourcesList && cacheLiveResourcePriority() != static_cast<unsigned>(priority)) { | 419 if (inCache() && memoryCache()->isInLiveDecodedResourcesList(this) && cacheL iveResourcePriority() != static_cast<unsigned>(priority)) { |
| 426 memoryCache()->removeFromLiveDecodedResourcesList(this); | 420 memoryCache()->removeFromLiveDecodedResourcesList(this); |
| 427 m_cacheLiveResourcePriority = priority; | 421 m_cacheLiveResourcePriority = priority; |
| 428 memoryCache()->insertInLiveDecodedResourcesList(this); | 422 memoryCache()->insertInLiveDecodedResourcesList(this); |
| 429 memoryCache()->prune(); | 423 memoryCache()->prune(); |
| 430 } | 424 } |
| 431 } | 425 } |
| 432 | 426 |
| 433 void Resource::clearLoader() | 427 void Resource::clearLoader() |
| 434 { | 428 { |
| 435 m_loader = 0; | 429 m_loader = 0; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 // Now insert into the new LRU list. | 572 // Now insert into the new LRU list. |
| 579 memoryCache()->insertInLRUList(this); | 573 memoryCache()->insertInLRUList(this); |
| 580 | 574 |
| 581 // Insert into or remove from the live decoded list if necessary. | 575 // Insert into or remove from the live decoded list if necessary. |
| 582 // When inserting into the LiveDecodedResourcesList it is possible | 576 // When inserting into the LiveDecodedResourcesList it is possible |
| 583 // that the m_lastDecodedAccessTime is still zero or smaller than | 577 // that the m_lastDecodedAccessTime is still zero or smaller than |
| 584 // the m_lastDecodedAccessTime of the current list head. This is a | 578 // the m_lastDecodedAccessTime of the current list head. This is a |
| 585 // violation of the invariant that the list is to be kept sorted | 579 // violation of the invariant that the list is to be kept sorted |
| 586 // by access time. The weakening of the invariant does not pose | 580 // by access time. The weakening of the invariant does not pose |
| 587 // a problem. For more details please see: https://bugs.webkit.org/show_ bug.cgi?id=30209 | 581 // a problem. For more details please see: https://bugs.webkit.org/show_ bug.cgi?id=30209 |
| 588 if (m_decodedSize && !m_inLiveDecodedResourcesList && hasClients()) | 582 if (m_decodedSize && !memoryCache()->isInLiveDecodedResourcesList(this) && hasClients()) |
| 589 memoryCache()->insertInLiveDecodedResourcesList(this); | 583 memoryCache()->insertInLiveDecodedResourcesList(this); |
| 590 else if (!m_decodedSize && m_inLiveDecodedResourcesList) | 584 else if (!m_decodedSize && memoryCache()->isInLiveDecodedResourcesList(t his)) |
| 591 memoryCache()->removeFromLiveDecodedResourcesList(this); | 585 memoryCache()->removeFromLiveDecodedResourcesList(this); |
| 592 | 586 |
| 593 // Update the cache's size totals. | 587 // Update the cache's size totals. |
| 594 memoryCache()->adjustSize(hasClients(), delta); | 588 memoryCache()->adjustSize(hasClients(), delta); |
| 595 } | 589 } |
| 596 } | 590 } |
| 597 | 591 |
| 598 void Resource::setEncodedSize(size_t size) | 592 void Resource::setEncodedSize(size_t size) |
| 599 { | 593 { |
| 600 if (size == m_encodedSize) | 594 if (size == m_encodedSize) |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 616 | 610 |
| 617 // Update the cache's size totals. | 611 // Update the cache's size totals. |
| 618 memoryCache()->adjustSize(hasClients(), delta); | 612 memoryCache()->adjustSize(hasClients(), delta); |
| 619 } | 613 } |
| 620 } | 614 } |
| 621 | 615 |
| 622 void Resource::didAccessDecodedData(double timeStamp) | 616 void Resource::didAccessDecodedData(double timeStamp) |
| 623 { | 617 { |
| 624 m_lastDecodedAccessTime = timeStamp; | 618 m_lastDecodedAccessTime = timeStamp; |
| 625 if (inCache()) { | 619 if (inCache()) { |
| 626 if (m_inLiveDecodedResourcesList) { | 620 if (memoryCache()->isInLiveDecodedResourcesList(this)) { |
| 627 memoryCache()->removeFromLiveDecodedResourcesList(this); | 621 memoryCache()->removeFromLiveDecodedResourcesList(this); |
| 628 memoryCache()->insertInLiveDecodedResourcesList(this); | 622 memoryCache()->insertInLiveDecodedResourcesList(this); |
| 629 } | 623 } |
| 630 memoryCache()->prune(); | 624 memoryCache()->prune(); |
| 631 } | 625 } |
| 632 } | 626 } |
| 633 | 627 |
| 634 void Resource::finishPendingClients() | 628 void Resource::finishPendingClients() |
| 635 { | 629 { |
| 636 while (!m_clientsAwaitingCallback.isEmpty()) { | 630 while (!m_clientsAwaitingCallback.isEmpty()) { |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1003 return "Shader"; | 997 return "Shader"; |
| 1004 case Resource::ImportResource: | 998 case Resource::ImportResource: |
| 1005 return "ImportResource"; | 999 return "ImportResource"; |
| 1006 } | 1000 } |
| 1007 ASSERT_NOT_REACHED(); | 1001 ASSERT_NOT_REACHED(); |
| 1008 return "Unknown"; | 1002 return "Unknown"; |
| 1009 } | 1003 } |
| 1010 #endif // !LOG_DISABLED | 1004 #endif // !LOG_DISABLED |
| 1011 | 1005 |
| 1012 } | 1006 } |
| OLD | NEW |