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

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: Fix for assertion failure. Created 7 years, 4 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 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();
« 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