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 Apple Inc. All rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007 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 12 matching lines...) Expand all Loading... |
23 | 23 |
24 #include "core/fetch/ImageResource.h" | 24 #include "core/fetch/ImageResource.h" |
25 | 25 |
26 #include "core/fetch/ImageResourceObserver.h" | 26 #include "core/fetch/ImageResourceObserver.h" |
27 #include "core/fetch/MemoryCache.h" | 27 #include "core/fetch/MemoryCache.h" |
28 #include "core/fetch/ResourceClient.h" | 28 #include "core/fetch/ResourceClient.h" |
29 #include "core/fetch/ResourceFetcher.h" | 29 #include "core/fetch/ResourceFetcher.h" |
30 #include "core/fetch/ResourceLoader.h" | 30 #include "core/fetch/ResourceLoader.h" |
31 #include "core/fetch/ResourceLoadingLog.h" | 31 #include "core/fetch/ResourceLoadingLog.h" |
32 #include "core/svg/graphics/SVGImage.h" | 32 #include "core/svg/graphics/SVGImage.h" |
| 33 #include "platform/Histogram.h" |
33 #include "platform/RuntimeEnabledFeatures.h" | 34 #include "platform/RuntimeEnabledFeatures.h" |
34 #include "platform/SharedBuffer.h" | 35 #include "platform/SharedBuffer.h" |
35 #include "platform/geometry/IntSize.h" | 36 #include "platform/geometry/IntSize.h" |
36 #include "platform/graphics/BitmapImage.h" | 37 #include "platform/graphics/BitmapImage.h" |
37 #include "platform/graphics/PlaceholderImage.h" | 38 #include "platform/graphics/PlaceholderImage.h" |
38 #include "platform/tracing/TraceEvent.h" | 39 #include "platform/tracing/TraceEvent.h" |
39 #include "public/platform/Platform.h" | 40 #include "public/platform/Platform.h" |
40 #include "public/platform/WebCachePolicy.h" | 41 #include "public/platform/WebCachePolicy.h" |
41 #include "wtf/CurrentTime.h" | 42 #include "wtf/CurrentTime.h" |
42 #include "wtf/HashCountedSet.h" | 43 #include "wtf/HashCountedSet.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 108 |
108 ImageResource::ImageResource(const ResourceRequest& resourceRequest, | 109 ImageResource::ImageResource(const ResourceRequest& resourceRequest, |
109 const ResourceLoaderOptions& options, | 110 const ResourceLoaderOptions& options, |
110 bool isPlaceholder) | 111 bool isPlaceholder) |
111 : Resource(resourceRequest, Image, options), | 112 : Resource(resourceRequest, Image, options), |
112 m_devicePixelRatioHeaderValue(1.0), | 113 m_devicePixelRatioHeaderValue(1.0), |
113 m_image(nullptr), | 114 m_image(nullptr), |
114 m_hasDevicePixelRatioHeaderValue(false), | 115 m_hasDevicePixelRatioHeaderValue(false), |
115 m_isSchedulingReload(false), | 116 m_isSchedulingReload(false), |
116 m_isPlaceholder(isPlaceholder), | 117 m_isPlaceholder(isPlaceholder), |
117 m_flushTimer(this, &ImageResource::flushImageIfNeeded) { | 118 m_flushTimer(this, &ImageResource::flushImageIfNeeded), |
| 119 m_isRefetchableDataFromDiskCache(true) { |
118 RESOURCE_LOADING_DVLOG(1) << "new ImageResource(ResourceRequest) " << this; | 120 RESOURCE_LOADING_DVLOG(1) << "new ImageResource(ResourceRequest) " << this; |
119 } | 121 } |
120 | 122 |
121 ImageResource::ImageResource(blink::Image* image, | 123 ImageResource::ImageResource(blink::Image* image, |
122 const ResourceLoaderOptions& options) | 124 const ResourceLoaderOptions& options) |
123 : Resource(ResourceRequest(""), Image, options), | 125 : Resource(ResourceRequest(""), Image, options), |
124 m_devicePixelRatioHeaderValue(1.0), | 126 m_devicePixelRatioHeaderValue(1.0), |
125 m_image(image), | 127 m_image(image), |
126 m_hasDevicePixelRatioHeaderValue(false), | 128 m_hasDevicePixelRatioHeaderValue(false), |
127 m_isSchedulingReload(false), | 129 m_isSchedulingReload(false), |
128 m_isPlaceholder(false), | 130 m_isPlaceholder(false), |
129 m_flushTimer(this, &ImageResource::flushImageIfNeeded) { | 131 m_flushTimer(this, &ImageResource::flushImageIfNeeded), |
| 132 m_isRefetchableDataFromDiskCache(true) { |
130 RESOURCE_LOADING_DVLOG(1) << "new ImageResource(Image) " << this; | 133 RESOURCE_LOADING_DVLOG(1) << "new ImageResource(Image) " << this; |
131 setStatus(Cached); | 134 setStatus(Cached); |
132 } | 135 } |
133 | 136 |
134 ImageResource::~ImageResource() { | 137 ImageResource::~ImageResource() { |
135 RESOURCE_LOADING_DVLOG(1) << "~ImageResource " << this; | 138 RESOURCE_LOADING_DVLOG(1) << "~ImageResource " << this; |
136 clearImage(); | 139 clearImage(); |
137 } | 140 } |
138 | 141 |
139 DEFINE_TRACE(ImageResource) { | 142 DEFINE_TRACE(ImageResource) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 void ImageResource::destroyDecodedDataForFailedRevalidation() { | 256 void ImageResource::destroyDecodedDataForFailedRevalidation() { |
254 clearImage(); | 257 clearImage(); |
255 setDecodedSize(0); | 258 setDecodedSize(0); |
256 } | 259 } |
257 | 260 |
258 void ImageResource::destroyDecodedDataIfPossible() { | 261 void ImageResource::destroyDecodedDataIfPossible() { |
259 if (!m_image) | 262 if (!m_image) |
260 return; | 263 return; |
261 CHECK(!errorOccurred()); | 264 CHECK(!errorOccurred()); |
262 m_image->destroyDecodedData(); | 265 m_image->destroyDecodedData(); |
| 266 if (!isPreloaded() && m_isRefetchableDataFromDiskCache) { |
| 267 UMA_HISTOGRAM_MEMORY_KB("Memory.Renderer.EstimatedDroppableEncodedSize", |
| 268 encodedSize() / 1024); |
| 269 } |
263 } | 270 } |
264 | 271 |
265 void ImageResource::doResetAnimation() { | 272 void ImageResource::doResetAnimation() { |
266 if (m_image) | 273 if (m_image) |
267 m_image->resetAnimation(); | 274 m_image->resetAnimation(); |
268 } | 275 } |
269 | 276 |
270 void ImageResource::allClientsAndObserversRemoved() { | 277 void ImageResource::allClientsAndObserversRemoved() { |
271 if (m_image) { | 278 if (m_image) { |
272 CHECK(!errorOccurred()); | 279 CHECK(!errorOccurred()); |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 WebServiceWorkerResponseTypeOpaque; | 728 WebServiceWorkerResponseTypeOpaque; |
722 } | 729 } |
723 if (!getImage()->currentFrameHasSingleSecurityOrigin()) | 730 if (!getImage()->currentFrameHasSingleSecurityOrigin()) |
724 return false; | 731 return false; |
725 if (passesAccessControlCheck(securityOrigin)) | 732 if (passesAccessControlCheck(securityOrigin)) |
726 return true; | 733 return true; |
727 return !securityOrigin->taintsCanvas(response().url()); | 734 return !securityOrigin->taintsCanvas(response().url()); |
728 } | 735 } |
729 | 736 |
730 } // namespace blink | 737 } // namespace blink |
OLD | NEW |