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

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

Issue 1706083002: Split ImageResourceClient into ResourceClient and ImageResourceObserver [1/2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 8 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 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) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
(...skipping 17 matching lines...) Expand all
28 #include "core/fetch/Resource.h" 28 #include "core/fetch/Resource.h"
29 #include "platform/geometry/IntRect.h" 29 #include "platform/geometry/IntRect.h"
30 #include "platform/geometry/IntSizeHash.h" 30 #include "platform/geometry/IntSizeHash.h"
31 #include "platform/geometry/LayoutSize.h" 31 #include "platform/geometry/LayoutSize.h"
32 #include "platform/graphics/ImageObserver.h" 32 #include "platform/graphics/ImageObserver.h"
33 #include "platform/graphics/ImageOrientation.h" 33 #include "platform/graphics/ImageOrientation.h"
34 #include "wtf/HashMap.h" 34 #include "wtf/HashMap.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 class ImageResourceClient;
39 class FetchRequest; 38 class FetchRequest;
40 class ResourceFetcher;
41 class FloatSize; 39 class FloatSize;
40 class ImageResourceObserver;
42 class Length; 41 class Length;
43 class MemoryCache; 42 class MemoryCache;
43 class ResourceClient;
44 class ResourceFetcher;
44 class SecurityOrigin; 45 class SecurityOrigin;
45 46
46 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver, p ublic MultipartImageResourceParser::Client { 47 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver, p ublic MultipartImageResourceParser::Client {
47 friend class MemoryCache; 48 friend class MemoryCache;
48 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageResource); 49 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageResource);
49 public: 50 public:
50 using ClientType = ImageResourceClient; 51 using ClientType = ResourceClient;
51 52
52 static PassRefPtrWillBeRawPtr<ImageResource> fetch(FetchRequest&, ResourceFe tcher*); 53 static PassRefPtrWillBeRawPtr<ImageResource> fetch(FetchRequest&, ResourceFe tcher*);
53 54
54 static PassRefPtrWillBeRawPtr<ImageResource> create(blink::Image* image) 55 static PassRefPtrWillBeRawPtr<ImageResource> create(blink::Image* image)
55 { 56 {
56 return adoptRefWillBeNoop(new ImageResource(image, ResourceLoaderOptions ())); 57 return adoptRefWillBeNoop(new ImageResource(image, ResourceLoaderOptions ()));
57 } 58 }
58 59
59 // Exposed for testing 60 // Exposed for testing
60 static PassRefPtrWillBeRawPtr<ImageResource> create(const ResourceRequest& r equest, blink::Image* image) 61 static PassRefPtrWillBeRawPtr<ImageResource> create(const ResourceRequest& r equest, blink::Image* image)
(...skipping 23 matching lines...) Expand all
84 LayoutSize imageSize(RespectImageOrientationEnum shouldRespectImageOrientati on, float multiplier, SizeType = IntrinsicSize); 85 LayoutSize imageSize(RespectImageOrientationEnum shouldRespectImageOrientati on, float multiplier, SizeType = IntrinsicSize);
85 86
86 bool isAccessAllowed(SecurityOrigin*); 87 bool isAccessAllowed(SecurityOrigin*);
87 88
88 void updateImageAnimationPolicy(); 89 void updateImageAnimationPolicy();
89 90
90 // If this ImageResource has the Lo-Fi response headers, reload it with 91 // If this ImageResource has the Lo-Fi response headers, reload it with
91 // the Lo-Fi state set to off and bypassing the cache. 92 // the Lo-Fi state set to off and bypassing the cache.
92 void reloadIfLoFi(ResourceFetcher*); 93 void reloadIfLoFi(ResourceFetcher*);
93 94
94 void didAddClient(ResourceClient*) override; 95 void addObserver(ImageResourceObserver*);
95 void didRemoveClient(ResourceClient*) override; 96 void removeObserver(ImageResourceObserver*);
97 bool hasClientsOrObservers() const override { return Resource::hasClientsOrO bservers() || !m_observers.isEmpty(); }
96 98
97 void allClientsRemoved() override; 99 ResourcePriority priorityFromObservers() override;
100
101 void allClientsAndObserversRemoved() override;
98 102
99 void appendData(const char*, size_t) override; 103 void appendData(const char*, size_t) override;
100 void error(Resource::Status) override; 104 void error(Resource::Status) override;
101 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan dle>) override; 105 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan dle>) override;
102 void finish() override; 106 void finish() override;
103 107
104 // For compatibility, images keep loading even if there are HTTP errors. 108 // For compatibility, images keep loading even if there are HTTP errors.
105 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } 109 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; }
106 110
107 bool isImage() const override { return true; } 111 bool isImage() const override { return true; }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 void clearImage(); 159 void clearImage();
156 // If not null, changeRect is the changed part of the image. 160 // If not null, changeRect is the changed part of the image.
157 void notifyObservers(const IntRect* changeRect = nullptr); 161 void notifyObservers(const IntRect* changeRect = nullptr);
158 162
159 float m_devicePixelRatioHeaderValue; 163 float m_devicePixelRatioHeaderValue;
160 164
161 PersistentWillBeMember<MultipartImageResourceParser> m_multipartParser; 165 PersistentWillBeMember<MultipartImageResourceParser> m_multipartParser;
162 RefPtr<blink::Image> m_image; 166 RefPtr<blink::Image> m_image;
163 MultipartParsingState m_multipartParsingState = MultipartParsingState::Waiti ngForFirstPart; 167 MultipartParsingState m_multipartParsingState = MultipartParsingState::Waiti ngForFirstPart;
164 bool m_hasDevicePixelRatioHeaderValue; 168 bool m_hasDevicePixelRatioHeaderValue;
169 HashCountedSet<ImageResourceObserver*> m_observers;
165 }; 170 };
166 171
167 DEFINE_RESOURCE_TYPE_CASTS(Image); 172 DEFINE_RESOURCE_TYPE_CASTS(Image);
168 173
169 } // namespace blink 174 } // namespace blink
170 175
171 #endif 176 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/FontResource.cpp ('k') | third_party/WebKit/Source/core/fetch/ImageResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698