| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 , m_requestedFromNetworkingLayer(false) | 109 , m_requestedFromNetworkingLayer(false) |
| 110 , m_loading(false) | 110 , m_loading(false) |
| 111 , m_switchingClientsToRevalidatedResource(false) | 111 , m_switchingClientsToRevalidatedResource(false) |
| 112 , m_type(type) | 112 , m_type(type) |
| 113 , m_status(Pending) | 113 , m_status(Pending) |
| 114 , m_wasPurged(false) | 114 , m_wasPurged(false) |
| 115 , m_needsSynchronousCacheHit(false) | 115 , m_needsSynchronousCacheHit(false) |
| 116 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK | 116 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK |
| 117 , m_deleted(false) | 117 , m_deleted(false) |
| 118 #endif | 118 #endif |
| 119 , m_resourceToRevalidate(0) | 119 , m_resourceToRevalidate(nullptr) |
| 120 , m_proxyResource(0) | 120 , m_proxyResource(nullptr) |
| 121 { | 121 { |
| 122 ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests car
eless updates of the enum. | 122 ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests car
eless updates of the enum. |
| 123 #ifndef NDEBUG | 123 #ifndef NDEBUG |
| 124 cachedResourceLeakCounter.increment(); | 124 cachedResourceLeakCounter.increment(); |
| 125 #endif | 125 #endif |
| 126 memoryCache()->registerLiveResource(*this); |
| 126 | 127 |
| 127 if (!m_resourceRequest.url().hasFragmentIdentifier()) | 128 if (!m_resourceRequest.url().hasFragmentIdentifier()) |
| 128 return; | 129 return; |
| 129 KURL urlForCache = MemoryCache::removeFragmentIdentifierIfNeeded(m_resourceR
equest.url()); | 130 KURL urlForCache = MemoryCache::removeFragmentIdentifierIfNeeded(m_resourceR
equest.url()); |
| 130 if (urlForCache.hasFragmentIdentifier()) | 131 if (urlForCache.hasFragmentIdentifier()) |
| 131 return; | 132 return; |
| 132 m_fragmentIdentifierForRequest = m_resourceRequest.url().fragmentIdentifier(
); | 133 m_fragmentIdentifierForRequest = m_resourceRequest.url().fragmentIdentifier(
); |
| 133 m_resourceRequest.setURL(urlForCache); | 134 m_resourceRequest.setURL(urlForCache); |
| 134 } | 135 } |
| 135 | 136 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 147 #endif | 148 #endif |
| 148 #ifndef NDEBUG | 149 #ifndef NDEBUG |
| 149 cachedResourceLeakCounter.decrement(); | 150 cachedResourceLeakCounter.decrement(); |
| 150 #endif | 151 #endif |
| 151 } | 152 } |
| 152 | 153 |
| 153 void Resource::dispose() | 154 void Resource::dispose() |
| 154 { | 155 { |
| 155 } | 156 } |
| 156 | 157 |
| 158 void Resource::trace(Visitor* visitor) |
| 159 { |
| 160 visitor->trace(m_resourceToRevalidate); |
| 161 visitor->trace(m_proxyResource); |
| 162 } |
| 163 |
| 157 void Resource::failBeforeStarting() | 164 void Resource::failBeforeStarting() |
| 158 { | 165 { |
| 159 WTF_LOG(ResourceLoading, "Cannot start loading '%s'", url().string().latin1(
).data()); | 166 WTF_LOG(ResourceLoading, "Cannot start loading '%s'", url().string().latin1(
).data()); |
| 160 error(Resource::LoadError); | 167 error(Resource::LoadError); |
| 161 } | 168 } |
| 162 | 169 |
| 163 void Resource::load(ResourceFetcher* fetcher, const ResourceLoaderOptions& optio
ns) | 170 void Resource::load(ResourceFetcher* fetcher, const ResourceLoaderOptions& optio
ns) |
| 164 { | 171 { |
| 165 if (!fetcher->frame()) { | 172 if (!fetcher->frame()) { |
| 166 failBeforeStarting(); | 173 failBeforeStarting(); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 m_loader->cancelIfNotFinishing(); | 556 m_loader->cancelIfNotFinishing(); |
| 550 if (m_status != Cached) | 557 if (m_status != Cached) |
| 551 memoryCache()->remove(this); | 558 memoryCache()->remove(this); |
| 552 } | 559 } |
| 553 | 560 |
| 554 bool Resource::deleteIfPossible() | 561 bool Resource::deleteIfPossible() |
| 555 { | 562 { |
| 556 if (canDelete() && !memoryCache()->contains(this)) { | 563 if (canDelete() && !memoryCache()->contains(this)) { |
| 557 InspectorInstrumentation::willDestroyResource(this); | 564 InspectorInstrumentation::willDestroyResource(this); |
| 558 dispose(); | 565 dispose(); |
| 566 memoryCache()->unregisterLiveResource(*this); |
| 567 #if !ENABLE(OILPAN) |
| 559 delete this; | 568 delete this; |
| 569 #endif |
| 560 return true; | 570 return true; |
| 561 } | 571 } |
| 562 return false; | 572 return false; |
| 563 } | 573 } |
| 564 | 574 |
| 565 void Resource::setDecodedSize(size_t decodedSize) | 575 void Resource::setDecodedSize(size_t decodedSize) |
| 566 { | 576 { |
| 567 if (decodedSize == m_decodedSize) | 577 if (decodedSize == m_decodedSize) |
| 568 return; | 578 return; |
| 569 size_t oldSize = size(); | 579 size_t oldSize = size(); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 } | 657 } |
| 648 | 658 |
| 649 void Resource::clearResourceToRevalidate() | 659 void Resource::clearResourceToRevalidate() |
| 650 { | 660 { |
| 651 ASSERT(m_resourceToRevalidate); | 661 ASSERT(m_resourceToRevalidate); |
| 652 if (m_switchingClientsToRevalidatedResource) | 662 if (m_switchingClientsToRevalidatedResource) |
| 653 return; | 663 return; |
| 654 | 664 |
| 655 // A resource may start revalidation before this method has been called, so
check that this resource is still the proxy resource before clearing it out. | 665 // A resource may start revalidation before this method has been called, so
check that this resource is still the proxy resource before clearing it out. |
| 656 if (m_resourceToRevalidate->m_proxyResource == this) { | 666 if (m_resourceToRevalidate->m_proxyResource == this) { |
| 657 m_resourceToRevalidate->m_proxyResource = 0; | 667 m_resourceToRevalidate->m_proxyResource = nullptr; |
| 658 m_resourceToRevalidate->deleteIfPossible(); | 668 m_resourceToRevalidate->deleteIfPossible(); |
| 659 } | 669 } |
| 660 m_handlesToRevalidate.clear(); | 670 m_handlesToRevalidate.clear(); |
| 661 m_resourceToRevalidate = 0; | 671 m_resourceToRevalidate = nullptr; |
| 662 deleteIfPossible(); | 672 deleteIfPossible(); |
| 663 } | 673 } |
| 664 | 674 |
| 665 void Resource::switchClientsToRevalidatedResource() | 675 void Resource::switchClientsToRevalidatedResource() |
| 666 { | 676 { |
| 667 ASSERT(m_resourceToRevalidate); | 677 ASSERT(m_resourceToRevalidate); |
| 668 ASSERT(memoryCache()->contains(m_resourceToRevalidate)); | 678 ASSERT(memoryCache()->contains(m_resourceToRevalidate)); |
| 669 ASSERT(!memoryCache()->contains(this)); | 679 ASSERT(!memoryCache()->contains(this)); |
| 670 | 680 |
| 671 WTF_LOG(ResourceLoading, "Resource %p switchClientsToRevalidatedResource %p"
, this, m_resourceToRevalidate); | 681 WTF_LOG(ResourceLoading, "Resource %p switchClientsToRevalidatedResource %p"
, this, m_resourceToRevalidate.get()); |
| 672 | 682 |
| 673 m_resourceToRevalidate->m_identifier = m_identifier; | 683 m_resourceToRevalidate->m_identifier = m_identifier; |
| 674 | 684 |
| 675 m_switchingClientsToRevalidatedResource = true; | 685 m_switchingClientsToRevalidatedResource = true; |
| 676 HashSet<ResourcePtrBase*>::iterator end = m_handlesToRevalidate.end(); | 686 HashSet<ResourcePtrBase*>::iterator end = m_handlesToRevalidate.end(); |
| 677 for (HashSet<ResourcePtrBase*>::iterator it = m_handlesToRevalidate.begin();
it != end; ++it) { | 687 for (HashSet<ResourcePtrBase*>::iterator it = m_handlesToRevalidate.begin();
it != end; ++it) { |
| 678 ResourcePtrBase* handle = *it; | 688 ResourcePtrBase* handle = *it; |
| 679 handle->m_resource = m_resourceToRevalidate; | 689 handle->m_resource = m_resourceToRevalidate; |
| 680 m_resourceToRevalidate->registerHandle(handle); | 690 m_resourceToRevalidate->registerHandle(handle); |
| 681 --m_handleCount; | 691 --m_handleCount; |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 return "ImportResource"; | 1005 return "ImportResource"; |
| 996 case Resource::Media: | 1006 case Resource::Media: |
| 997 return "Media"; | 1007 return "Media"; |
| 998 } | 1008 } |
| 999 ASSERT_NOT_REACHED(); | 1009 ASSERT_NOT_REACHED(); |
| 1000 return "Unknown"; | 1010 return "Unknown"; |
| 1001 } | 1011 } |
| 1002 #endif // !LOG_DISABLED | 1012 #endif // !LOG_DISABLED |
| 1003 | 1013 |
| 1004 } | 1014 } |
| OLD | NEW |