Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1399)

Unified Diff: Source/core/loader/ImageLoader.cpp

Issue 19393004: Allow eviction of ImageBitmaps that are created from ImageElements. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Name change. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/loader/ImageLoader.h ('k') | Source/core/loader/cache/CachedImageTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/loader/ImageLoader.cpp
diff --git a/Source/core/loader/ImageLoader.cpp b/Source/core/loader/ImageLoader.cpp
index 9fbabee79622c331ba92247f7abdc00eb8968b9a..eb40978860e3fca808ffaa2067353813a1b43c93 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);
@@ -190,9 +192,11 @@ void ImageLoader::updateFromElement()
m_hasPendingErrorEvent = true;
errorEventSender().dispatchEventSoon(this);
}
-
+
CachedImage* oldImage = m_image.get();
if (newImage != oldImage) {
+ sourceImageChanged();
+
if (m_hasPendingBeforeLoadEvent) {
beforeLoadEventSender().cancelEvent(this);
m_hasPendingBeforeLoadEvent = false;
@@ -423,6 +427,26 @@ void ImageLoader::dispatchPendingErrorEvent()
updatedHasPendingEvent();
}
+void ImageLoader::addClient(ImageLoaderClient* client)
+{
+ if (client->requestsHighLiveResourceCachePriority()) {
+ m_highPriorityClientCount++;
+ if (m_image)
Justin Novosad 2013/07/29 17:47:58 Better to only call setCacheLiveResourcePriority i
+ m_image->setCacheLiveResourcePriority(CachedResource::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(CachedResource::CacheLiveResourcePriorityLow);
+ }
+ m_clients.remove(client);
+}
+
void ImageLoader::dispatchPendingBeforeLoadEvents()
{
beforeLoadEventSender().dispatchPendingEvents();
@@ -444,6 +468,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();
« no previous file with comments | « Source/core/loader/ImageLoader.h ('k') | Source/core/loader/cache/CachedImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698