OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ImageResourceContent_h | 5 #ifndef ImageResourceContent_h |
6 #define ImageResourceContent_h | 6 #define ImageResourceContent_h |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
10 #include "platform/geometry/IntRect.h" | 10 #include "platform/geometry/IntRect.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 // TODO(hiroshige): Make ImageResourceContent ResourceClient and remove the | 39 // TODO(hiroshige): Make ImageResourceContent ResourceClient and remove the |
40 // word 'observer' from ImageResource. | 40 // word 'observer' from ImageResource. |
41 // TODO(hiroshige): Rename local variables of type ImageResourceContent to | 41 // TODO(hiroshige): Rename local variables of type ImageResourceContent to |
42 // e.g. |imageContent|. Currently they have Resource-like names. | 42 // e.g. |imageContent|. Currently they have Resource-like names. |
43 class CORE_EXPORT ImageResourceContent final | 43 class CORE_EXPORT ImageResourceContent final |
44 : public GarbageCollectedFinalized<ImageResourceContent>, | 44 : public GarbageCollectedFinalized<ImageResourceContent>, |
45 public ImageObserver { | 45 public ImageObserver { |
46 USING_GARBAGE_COLLECTED_MIXIN(ImageResourceContent); | 46 USING_GARBAGE_COLLECTED_MIXIN(ImageResourceContent); |
47 | 47 |
48 public: | 48 public: |
49 static ImageResourceContent* Create( | 49 // Used for loading. |
50 PassRefPtr<blink::Image> image = nullptr) { | 50 // Returned content will be associated immediately later with ImageResource. |
51 return new ImageResourceContent(std::move(image)); | 51 static ImageResourceContent* CreateNotStarted() { |
| 52 return new ImageResourceContent(nullptr); |
52 } | 53 } |
| 54 |
| 55 // Creates ImageResourceContent from an already loaded image. |
| 56 static ImageResourceContent* CreateLoaded(PassRefPtr<blink::Image>); |
| 57 |
53 static ImageResourceContent* Fetch(FetchParameters&, ResourceFetcher*); | 58 static ImageResourceContent* Fetch(FetchParameters&, ResourceFetcher*); |
54 | 59 |
55 // Returns the nullImage() if the image is not available yet. | 60 // Returns the nullImage() if the image is not available yet. |
56 blink::Image* GetImage(); | 61 blink::Image* GetImage(); |
57 bool HasImage() const { return image_.Get(); } | 62 bool HasImage() const { return image_.Get(); } |
58 | 63 |
59 static std::pair<blink::Image*, float> BrokenImage( | 64 static std::pair<blink::Image*, float> BrokenImage( |
60 float | 65 float |
61 device_scale_factor); // Returns an image and the image's resolution | 66 device_scale_factor); // Returns an image and the image's resolution |
62 // scale factor. | 67 // scale factor. |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 HashCountedSet<ImageResourceObserver*> finished_observers_; | 225 HashCountedSet<ImageResourceObserver*> finished_observers_; |
221 | 226 |
222 #if DCHECK_IS_ON() | 227 #if DCHECK_IS_ON() |
223 bool is_update_image_being_called_ = false; | 228 bool is_update_image_being_called_ = false; |
224 #endif | 229 #endif |
225 }; | 230 }; |
226 | 231 |
227 } // namespace blink | 232 } // namespace blink |
228 | 233 |
229 #endif | 234 #endif |
OLD | NEW |