Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * Copyright (C) 2004, 2009 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2009 Apple Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| 11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
| 15 * | 15 * |
| 16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
| 17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
| 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
| 20 * | 20 * |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #ifndef ImageLoader_h | 23 #ifndef ImageLoader_h |
| 24 #define ImageLoader_h | 24 #define ImageLoader_h |
| 25 | 25 |
| 26 #include "core/loader/cache/CachedImage.h" | 26 #include "core/loader/cache/CachedImage.h" |
| 27 #include "core/loader/cache/CachedImageClient.h" | 27 #include "core/loader/cache/CachedImageClient.h" |
| 28 #include "core/loader/cache/CachedResourceHandle.h" | 28 #include "core/loader/cache/CachedResourceHandle.h" |
| 29 #include "wtf/HashSet.h" | |
| 29 #include "wtf/text/AtomicString.h" | 30 #include "wtf/text/AtomicString.h" |
| 30 | 31 |
| 31 namespace WebCore { | 32 namespace WebCore { |
| 32 | 33 |
| 34 class ImageLoaderClient { | |
| 35 public: | |
| 36 virtual void notifyImageSourceChanged() = 0; | |
| 37 | |
| 38 // Notifies whether the observed CachedImage should have higher priority in the decoded resources cache. | |
| 39 virtual bool isHighPriorityImageLoaderClient() = 0; | |
|
Justin Novosad
2013/07/29 15:29:43
the "ImageLoaderClient" part of themname does not
| |
| 40 | |
| 41 protected: | |
| 42 ImageLoaderClient() { } | |
| 43 }; | |
| 44 | |
| 33 class Element; | 45 class Element; |
| 34 class ImageLoader; | 46 class ImageLoader; |
| 35 class RenderImageResource; | 47 class RenderImageResource; |
| 36 | 48 |
| 37 template<typename T> class EventSender; | 49 template<typename T> class EventSender; |
| 38 typedef EventSender<ImageLoader> ImageEventSender; | 50 typedef EventSender<ImageLoader> ImageEventSender; |
| 39 | 51 |
| 40 class ImageLoader : public CachedImageClient { | 52 class ImageLoader : public CachedImageClient { |
| 41 public: | 53 public: |
| 42 explicit ImageLoader(Element*); | 54 explicit ImageLoader(Element*); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 62 | 74 |
| 63 bool hasPendingBeforeLoadEvent() const { return m_hasPendingBeforeLoadEvent; } | 75 bool hasPendingBeforeLoadEvent() const { return m_hasPendingBeforeLoadEvent; } |
| 64 bool hasPendingActivity() const { return m_hasPendingLoadEvent || m_hasPendi ngErrorEvent; } | 76 bool hasPendingActivity() const { return m_hasPendingLoadEvent || m_hasPendi ngErrorEvent; } |
| 65 | 77 |
| 66 void dispatchPendingEvent(ImageEventSender*); | 78 void dispatchPendingEvent(ImageEventSender*); |
| 67 | 79 |
| 68 static void dispatchPendingBeforeLoadEvents(); | 80 static void dispatchPendingBeforeLoadEvents(); |
| 69 static void dispatchPendingLoadEvents(); | 81 static void dispatchPendingLoadEvents(); |
| 70 static void dispatchPendingErrorEvents(); | 82 static void dispatchPendingErrorEvents(); |
| 71 | 83 |
| 84 void addClient(ImageLoaderClient*); | |
| 85 void removeClient(ImageLoaderClient*); | |
| 86 | |
| 72 protected: | 87 protected: |
| 73 virtual void notifyFinished(CachedResource*); | 88 virtual void notifyFinished(CachedResource*); |
| 74 | 89 |
| 75 private: | 90 private: |
| 76 virtual void dispatchLoadEvent() = 0; | 91 virtual void dispatchLoadEvent() = 0; |
| 77 virtual String sourceURI(const AtomicString&) const = 0; | 92 virtual String sourceURI(const AtomicString&) const = 0; |
| 78 | 93 |
| 79 void updatedHasPendingEvent(); | 94 void updatedHasPendingEvent(); |
| 80 | 95 |
| 81 void dispatchPendingBeforeLoadEvent(); | 96 void dispatchPendingBeforeLoadEvent(); |
| 82 void dispatchPendingLoadEvent(); | 97 void dispatchPendingLoadEvent(); |
| 83 void dispatchPendingErrorEvent(); | 98 void dispatchPendingErrorEvent(); |
| 84 | 99 |
| 85 RenderImageResource* renderImageResource(); | 100 RenderImageResource* renderImageResource(); |
| 86 void updateRenderer(); | 101 void updateRenderer(); |
| 87 | 102 |
| 88 void setImageWithoutConsideringPendingLoadEvent(CachedImage*); | 103 void setImageWithoutConsideringPendingLoadEvent(CachedImage*); |
| 104 void sourceImageChanged(); | |
| 89 void clearFailedLoadURL(); | 105 void clearFailedLoadURL(); |
| 90 | 106 |
| 91 void timerFired(Timer<ImageLoader>*); | 107 void timerFired(Timer<ImageLoader>*); |
| 92 | 108 |
| 93 Element* m_element; | 109 Element* m_element; |
| 94 CachedResourceHandle<CachedImage> m_image; | 110 CachedResourceHandle<CachedImage> m_image; |
| 111 HashSet<ImageLoaderClient*> m_clients; | |
| 95 Timer<ImageLoader> m_derefElementTimer; | 112 Timer<ImageLoader> m_derefElementTimer; |
| 96 AtomicString m_failedLoadURL; | 113 AtomicString m_failedLoadURL; |
| 97 bool m_hasPendingBeforeLoadEvent : 1; | 114 bool m_hasPendingBeforeLoadEvent : 1; |
| 98 bool m_hasPendingLoadEvent : 1; | 115 bool m_hasPendingLoadEvent : 1; |
| 99 bool m_hasPendingErrorEvent : 1; | 116 bool m_hasPendingErrorEvent : 1; |
| 100 bool m_imageComplete : 1; | 117 bool m_imageComplete : 1; |
| 101 bool m_loadManually : 1; | 118 bool m_loadManually : 1; |
| 102 bool m_elementIsProtected : 1; | 119 bool m_elementIsProtected : 1; |
| 120 unsigned m_highPriorityClientCount; | |
| 103 }; | 121 }; |
| 104 | 122 |
| 105 } | 123 } |
| 106 | 124 |
| 107 #endif | 125 #endif |
| OLD | NEW |