OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserv
ed. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserv
ed. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 160 } |
161 | 161 |
162 void ImageLoader::dispose() | 162 void ImageLoader::dispose() |
163 { | 163 { |
164 WTF_LOG(Timers, "~ImageLoader %p; m_hasPendingLoadEvent=%d, m_hasPendingErro
rEvent=%d", | 164 WTF_LOG(Timers, "~ImageLoader %p; m_hasPendingLoadEvent=%d, m_hasPendingErro
rEvent=%d", |
165 this, m_hasPendingLoadEvent, m_hasPendingErrorEvent); | 165 this, m_hasPendingLoadEvent, m_hasPendingErrorEvent); |
166 | 166 |
167 if (m_pendingTask) | 167 if (m_pendingTask) |
168 m_pendingTask->clearLoader(); | 168 m_pendingTask->clearLoader(); |
169 | 169 |
| 170 #if ENABLE(OILPAN) |
| 171 for (const auto& client : m_clients) |
| 172 willRemoveClient(*client); |
| 173 #endif |
| 174 |
170 if (m_image) | 175 if (m_image) |
171 m_image->removeClient(this); | 176 m_image->removeClient(this); |
172 | 177 |
173 ASSERT(m_hasPendingLoadEvent || !loadEventSender().hasPendingEvents(this)); | 178 ASSERT(m_hasPendingLoadEvent || !loadEventSender().hasPendingEvents(this)); |
174 if (m_hasPendingLoadEvent) | 179 if (m_hasPendingLoadEvent) |
175 loadEventSender().cancelEvent(this); | 180 loadEventSender().cancelEvent(this); |
176 | 181 |
177 ASSERT(m_hasPendingErrorEvent || !errorEventSender().hasPendingEvents(this))
; | 182 ASSERT(m_hasPendingErrorEvent || !errorEventSender().hasPendingEvents(this))
; |
178 if (m_hasPendingErrorEvent) | 183 if (m_hasPendingErrorEvent) |
179 errorEventSender().cancelEvent(this); | 184 errorEventSender().cancelEvent(this); |
180 } | 185 } |
181 | 186 |
| 187 #if ENABLE(OILPAN) |
| 188 void ImageLoader::clearWeakMembers(Visitor* visitor) |
| 189 { |
| 190 Vector<ImageLoaderClient*> deadClients; |
| 191 for (const auto& client : m_clients) { |
| 192 if (!Heap::isHeapObjectAlive(client)) { |
| 193 willRemoveClient(*client); |
| 194 deadClients.append(client); |
| 195 } |
| 196 } |
| 197 for (unsigned i = 0; i < deadClients.size(); ++i) |
| 198 m_clients.remove(deadClients[i]); |
| 199 } |
| 200 #endif |
| 201 |
182 DEFINE_TRACE(ImageLoader) | 202 DEFINE_TRACE(ImageLoader) |
183 { | 203 { |
184 visitor->trace(m_element); | 204 visitor->trace(m_element); |
| 205 #if ENABLE(OILPAN) |
| 206 visitor->template registerWeakMembers<ImageLoader, &ImageLoader::clearWeakMe
mbers>(this); |
| 207 #endif |
185 } | 208 } |
186 | 209 |
187 void ImageLoader::setImage(ImageResource* newImage) | 210 void ImageLoader::setImage(ImageResource* newImage) |
188 { | 211 { |
189 setImageWithoutConsideringPendingLoadEvent(newImage); | 212 setImageWithoutConsideringPendingLoadEvent(newImage); |
190 | 213 |
191 // Only consider updating the protection ref-count of the Element immediatel
y before returning | 214 // Only consider updating the protection ref-count of the Element immediatel
y before returning |
192 // from this function as doing so might result in the destruction of this Im
ageLoader. | 215 // from this function as doing so might result in the destruction of this Im
ageLoader. |
193 updatedHasPendingEvent(); | 216 updatedHasPendingEvent(); |
194 } | 217 } |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 // from this function as doing so might result in the destruction of this Im
ageLoader. | 609 // from this function as doing so might result in the destruction of this Im
ageLoader. |
587 updatedHasPendingEvent(); | 610 updatedHasPendingEvent(); |
588 } | 611 } |
589 | 612 |
590 void ImageLoader::addClient(ImageLoaderClient* client) | 613 void ImageLoader::addClient(ImageLoaderClient* client) |
591 { | 614 { |
592 if (client->requestsHighLiveResourceCachePriority()) { | 615 if (client->requestsHighLiveResourceCachePriority()) { |
593 if (m_image && !m_highPriorityClientCount++) | 616 if (m_image && !m_highPriorityClientCount++) |
594 memoryCache()->updateDecodedResource(m_image.get(), UpdateForPropert
yChange, MemoryCacheLiveResourcePriorityHigh); | 617 memoryCache()->updateDecodedResource(m_image.get(), UpdateForPropert
yChange, MemoryCacheLiveResourcePriorityHigh); |
595 } | 618 } |
596 #if ENABLE(OILPAN) | |
597 m_clients.add(client, adoptPtr(new ImageLoaderClientRemover(*this, *client))
); | |
598 #else | |
599 m_clients.add(client); | 619 m_clients.add(client); |
600 #endif | |
601 } | 620 } |
602 | 621 |
603 void ImageLoader::willRemoveClient(ImageLoaderClient& client) | 622 void ImageLoader::willRemoveClient(ImageLoaderClient& client) |
604 { | 623 { |
605 if (client.requestsHighLiveResourceCachePriority()) { | 624 if (client.requestsHighLiveResourceCachePriority()) { |
606 ASSERT(m_highPriorityClientCount); | 625 ASSERT(m_highPriorityClientCount); |
607 m_highPriorityClientCount--; | 626 m_highPriorityClientCount--; |
608 if (m_image && !m_highPriorityClientCount) | 627 if (m_image && !m_highPriorityClientCount) |
609 memoryCache()->updateDecodedResource(m_image.get(), UpdateForPropert
yChange, MemoryCacheLiveResourcePriorityLow); | 628 memoryCache()->updateDecodedResource(m_image.get(), UpdateForPropert
yChange, MemoryCacheLiveResourcePriorityLow); |
610 } | 629 } |
(...skipping 27 matching lines...) Expand all Loading... |
638 void ImageLoader::elementDidMoveToNewDocument() | 657 void ImageLoader::elementDidMoveToNewDocument() |
639 { | 658 { |
640 if (m_loadDelayCounter) | 659 if (m_loadDelayCounter) |
641 m_loadDelayCounter->documentChanged(m_element->document()); | 660 m_loadDelayCounter->documentChanged(m_element->document()); |
642 clearFailedLoadURL(); | 661 clearFailedLoadURL(); |
643 setImage(0); | 662 setImage(0); |
644 } | 663 } |
645 | 664 |
646 void ImageLoader::sourceImageChanged() | 665 void ImageLoader::sourceImageChanged() |
647 { | 666 { |
648 #if ENABLE(OILPAN) | |
649 for (auto& client : m_clients) | |
650 client.key->notifyImageSourceChanged(); | |
651 #else | |
652 for (auto& client : m_clients) { | 667 for (auto& client : m_clients) { |
653 ImageLoaderClient* handle = client; | 668 ImageLoaderClient* handle = client; |
654 handle->notifyImageSourceChanged(); | 669 handle->notifyImageSourceChanged(); |
655 } | 670 } |
656 #endif | |
657 } | 671 } |
658 | 672 |
659 #if ENABLE(OILPAN) | 673 } // namespace blink |
660 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover() | |
661 { | |
662 m_loader.willRemoveClient(m_client); | |
663 } | |
664 #endif | |
665 } | |
OLD | NEW |