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

Side by Side Diff: third_party/WebKit/Source/core/fetch/ImageResource.cpp

Issue 2499263002: Add UMA to estimate deroppable memory usage of encoded data size in Resources (Closed)
Patch Set: Address on yhirano's review Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. 21 Boston, MA 02110-1301, USA.
22 */ 22 */
23 23
24 #include "core/fetch/ImageResource.h" 24 #include "core/fetch/ImageResource.h"
25 25
26 #include "base/metrics/histogram_macros.h"
26 #include "core/fetch/ImageResourceObserver.h" 27 #include "core/fetch/ImageResourceObserver.h"
27 #include "core/fetch/MemoryCache.h" 28 #include "core/fetch/MemoryCache.h"
28 #include "core/fetch/ResourceClient.h" 29 #include "core/fetch/ResourceClient.h"
29 #include "core/fetch/ResourceFetcher.h" 30 #include "core/fetch/ResourceFetcher.h"
30 #include "core/fetch/ResourceLoader.h" 31 #include "core/fetch/ResourceLoader.h"
31 #include "core/fetch/ResourceLoadingLog.h" 32 #include "core/fetch/ResourceLoadingLog.h"
32 #include "core/svg/graphics/SVGImage.h" 33 #include "core/svg/graphics/SVGImage.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"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698