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

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: More consistent Client/Observer Created 4 years, 10 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 16 matching lines...) Expand all
27 #include "core/fetch/Resource.h" 27 #include "core/fetch/Resource.h"
28 #include "platform/geometry/IntRect.h" 28 #include "platform/geometry/IntRect.h"
29 #include "platform/geometry/IntSizeHash.h" 29 #include "platform/geometry/IntSizeHash.h"
30 #include "platform/geometry/LayoutSize.h" 30 #include "platform/geometry/LayoutSize.h"
31 #include "platform/graphics/ImageObserver.h" 31 #include "platform/graphics/ImageObserver.h"
32 #include "platform/graphics/ImageOrientation.h" 32 #include "platform/graphics/ImageOrientation.h"
33 #include "wtf/HashMap.h" 33 #include "wtf/HashMap.h"
34 34
35 namespace blink { 35 namespace blink {
36 36
37 class ImageResourceClient;
38 class FetchRequest; 37 class FetchRequest;
39 class ResourceFetcher;
40 class FloatSize; 38 class FloatSize;
39 class ImageResourceObserver;
41 class Length; 40 class Length;
42 class MemoryCache; 41 class MemoryCache;
42 class ResourceClient;
43 class ResourceFetcher;
43 class SecurityOrigin; 44 class SecurityOrigin;
44 45
45 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver { 46 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver {
46 friend class MemoryCache; 47 friend class MemoryCache;
47 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageResource); 48 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageResource);
48 public: 49 public:
49 using ClientType = ImageResourceClient; 50 using ClientType = ResourceClient;
50 51
51 static PassRefPtrWillBeRawPtr<ImageResource> fetch(FetchRequest&, ResourceFe tcher*); 52 static PassRefPtrWillBeRawPtr<ImageResource> fetch(FetchRequest&, ResourceFe tcher*);
52 53
53 static PassRefPtrWillBeRawPtr<ImageResource> create(blink::Image* image) 54 static PassRefPtrWillBeRawPtr<ImageResource> create(blink::Image* image)
54 { 55 {
55 return adoptRefWillBeNoop(new ImageResource(image)); 56 return adoptRefWillBeNoop(new ImageResource(image));
56 } 57 }
57 58
58 // Exposed for testing 59 // Exposed for testing
59 static PassRefPtrWillBeRawPtr<ImageResource> create(const ResourceRequest& r equest, blink::Image* image) 60 static PassRefPtrWillBeRawPtr<ImageResource> create(const ResourceRequest& r equest, blink::Image* image)
(...skipping 30 matching lines...) Expand all
90 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei ght, FloatSize& intrinsicRatio); 91 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei ght, FloatSize& intrinsicRatio);
91 92
92 bool isAccessAllowed(SecurityOrigin*); 93 bool isAccessAllowed(SecurityOrigin*);
93 94
94 void updateImageAnimationPolicy(); 95 void updateImageAnimationPolicy();
95 96
96 // If this ImageResource has the Lo-Fi response headers, reload it with 97 // If this ImageResource has the Lo-Fi response headers, reload it with
97 // the Lo-Fi state set to off and bypassing the cache. 98 // the Lo-Fi state set to off and bypassing the cache.
98 void reloadIfLoFi(ResourceFetcher*); 99 void reloadIfLoFi(ResourceFetcher*);
99 100
100 void didAddClient(ResourceClient*) override; 101 void addObserver(ImageResourceObserver*);
101 void didRemoveClient(ResourceClient*) override; 102 void removeObserver(ImageResourceObserver*);
103 bool hasClients() const override { return Resource::hasClients() || !m_obser vers.isEmpty(); }
104
105 ResourcePriority priorityFromClients() override;
102 106
103 void allClientsRemoved() override; 107 void allClientsRemoved() override;
104 108
105 void appendData(const char*, size_t) override; 109 void appendData(const char*, size_t) override;
106 void error(Resource::Status) override; 110 void error(Resource::Status) override;
107 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan dle>) override; 111 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan dle>) override;
108 void finishOnePart() override; 112 void finishOnePart() override;
109 113
110 // For compatibility, images keep loading even if there are HTTP errors. 114 // For compatibility, images keep loading even if there are HTTP errors.
111 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } 115 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 void updateImage(bool allDataReceived); 155 void updateImage(bool allDataReceived);
152 void clearImage(); 156 void clearImage();
153 // If not null, changeRect is the changed part of the image. 157 // If not null, changeRect is the changed part of the image.
154 void notifyObservers(const IntRect* changeRect = nullptr); 158 void notifyObservers(const IntRect* changeRect = nullptr);
155 bool loadingMultipartContent() const; 159 bool loadingMultipartContent() const;
156 160
157 float m_devicePixelRatioHeaderValue; 161 float m_devicePixelRatioHeaderValue;
158 162
159 RefPtr<blink::Image> m_image; 163 RefPtr<blink::Image> m_image;
160 bool m_hasDevicePixelRatioHeaderValue; 164 bool m_hasDevicePixelRatioHeaderValue;
165 HashCountedSet<ImageResourceObserver*> m_observers;
161 }; 166 };
162 167
163 DEFINE_RESOURCE_TYPE_CASTS(Image); 168 DEFINE_RESOURCE_TYPE_CASTS(Image);
164 169
165 } // namespace blink 170 } // namespace blink
166 171
167 #endif 172 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698