Index: Source/core/loader/ImageLoader.cpp |
diff --git a/Source/core/loader/ImageLoader.cpp b/Source/core/loader/ImageLoader.cpp |
index 612a04bd3dd65a11b07a9979f04f237670db862a..ec0ed7b3c1ebf3788593bcca990c6b48560099a8 100644 |
--- a/Source/core/loader/ImageLoader.cpp |
+++ b/Source/core/loader/ImageLoader.cpp |
@@ -75,6 +75,7 @@ ImageLoader::ImageLoader(Element* element) |
, m_imageComplete(true) |
, m_loadManually(false) |
, m_elementIsProtected(false) |
+ , m_highPriorityClientCount(0) |
{ |
} |
@@ -115,6 +116,7 @@ void ImageLoader::setImageWithoutConsideringPendingLoadEvent(CachedImage* newIma |
ASSERT(m_failedLoadURL.isEmpty()); |
CachedImage* oldImage = m_image.get(); |
if (newImage != oldImage) { |
+ sourceImageChanged(); |
m_image = newImage; |
if (m_hasPendingBeforeLoadEvent) { |
beforeLoadEventSender().cancelEvent(this); |
@@ -193,6 +195,8 @@ void ImageLoader::updateFromElement() |
CachedImage* oldImage = m_image.get(); |
if (newImage != oldImage) { |
+ sourceImageChanged(); |
+ |
if (m_hasPendingBeforeLoadEvent) { |
beforeLoadEventSender().cancelEvent(this); |
m_hasPendingBeforeLoadEvent = false; |
@@ -426,6 +430,25 @@ void ImageLoader::dispatchPendingErrorEvent() |
updatedHasPendingEvent(); |
} |
+void ImageLoader::addClient(ImageLoaderClient* client) |
+{ |
+ if (client->requestsHighLiveResourceCachePriority()) { |
+ if (m_image && !m_highPriorityClientCount++) |
+ m_image->setCacheLiveResourcePriority(Resource::CacheLiveResourcePriorityHigh); |
+ } |
+ m_clients.add(client); |
+} |
+void ImageLoader::removeClient(ImageLoaderClient* client) |
+{ |
+ if (client->requestsHighLiveResourceCachePriority()) { |
+ ASSERT(m_highPriorityClientCount); |
+ m_highPriorityClientCount--; |
+ if (m_image && !m_highPriorityClientCount) |
+ m_image->setCacheLiveResourcePriority(Resource::CacheLiveResourcePriorityLow); |
+ } |
+ m_clients.remove(client); |
+} |
+ |
void ImageLoader::dispatchPendingBeforeLoadEvents() |
{ |
beforeLoadEventSender().dispatchPendingEvents(); |
@@ -447,6 +470,15 @@ void ImageLoader::elementDidMoveToNewDocument() |
setImage(0); |
} |
+void ImageLoader::sourceImageChanged() |
+{ |
+ HashSet<ImageLoaderClient*>::iterator end = m_clients.end(); |
+ for (HashSet<ImageLoaderClient*>::iterator it = m_clients.begin(); it != end; ++it) { |
+ ImageLoaderClient* handle = *it; |
+ handle->notifyImageSourceChanged(); |
+ } |
+} |
+ |
inline void ImageLoader::clearFailedLoadURL() |
{ |
m_failedLoadURL = AtomicString(); |