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

Unified Diff: third_party/WebKit/Source/core/loader/ImageLoader.h

Issue 1833303002: [Not committed] Make image load completion async and remove EventSender from ImageLoader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Loader_asyncImageLoadEvent_1
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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/loader/ImageLoader.h
diff --git a/third_party/WebKit/Source/core/loader/ImageLoader.h b/third_party/WebKit/Source/core/loader/ImageLoader.h
index 5758a11bfc30f5c930b967c96875addd577c297c..e317e49e6157d796b26dd4d6c6e82fb955c6a3b3 100644
--- a/third_party/WebKit/Source/core/loader/ImageLoader.h
+++ b/third_party/WebKit/Source/core/loader/ImageLoader.h
@@ -41,9 +41,6 @@ class Element;
class ImageLoader;
class LayoutImageResource;
-template<typename T> class EventSender;
-using ImageEventSender = EventSender<ImageLoader>;
-
class CORE_EXPORT ImageLoader : public GarbageCollectedFinalized<ImageLoader>, public ImageResourceObserver {
USING_PRE_FINALIZER(ImageLoader, dispose);
public:
@@ -78,7 +75,7 @@ public:
Element* element() const { return m_element; }
bool imageComplete() const
{
- return m_imageComplete && !m_pendingTask;
+ return m_imageComplete && !m_pendingMicrotask;
}
ImageResource* image() const { return m_image.get(); }
@@ -88,43 +85,46 @@ public:
bool hasPendingActivity() const
{
- return m_hasPendingLoadEvent || m_hasPendingErrorEvent || m_pendingTask;
+ return m_hasPendingLoadEvent || hasPendingError() || m_pendingMicrotask;
}
bool hasPendingError() const
{
- return m_hasPendingErrorEvent;
+ return m_loadDelayCounterForError;
}
- void dispatchPendingEvent(ImageEventSender*);
-
- static void dispatchPendingLoadEvents();
- static void dispatchPendingErrorEvents();
-
bool getImageAnimationPolicy(ImageAnimationPolicy&) final;
+
protected:
- void imageNotifyFinished(ImageResource*) override;
+ virtual void finishInternal(ImageResource*) { }
private:
class Task;
+ void imageNotifyFinished(ImageResource*) final;
+
// Called from the task or from updateFromElement to initiate the load.
void doUpdateFromElement(BypassMainWorldBehavior, UpdateFromElementBehavior, ReferrerPolicy = ReferrerPolicyDefault);
- virtual void dispatchLoadEvent() = 0;
virtual void noImageResourceToLoad() { }
void updatedHasPendingEvent();
- void dispatchPendingLoadEvent();
- void dispatchPendingErrorEvent();
+ void cancelPendingFinish();
+ void finish();
+
+ virtual void dispatchLoadEvent() = 0;
+
+ void scheduleErrorEvent();
+ void cancelPendingErrorEvent();
+ void dispatchErrorEvent();
+ void dispatchErrorEventWithoutUpdatedHasPendingEvent();
LayoutImageResource* layoutImageResource();
void updateLayoutObject();
void setImageWithoutConsideringPendingLoadEvent(ImageResource*);
void clearFailedLoadURL();
- void dispatchErrorEvent();
void crossSiteOrCSPViolationOccurred(AtomicString);
void enqueueImageLoadingMicroTask(UpdateFromElementBehavior, ReferrerPolicy);
@@ -152,10 +152,16 @@ private:
Timer<ImageLoader> m_derefElementTimer;
AtomicString m_failedLoadURL;
- WeakPtr<Task> m_pendingTask; // owned by Microtask
- OwnPtr<IncrementLoadEventDelayCount> m_loadDelayCounter;
+
+ WeakPtr<Task> m_pendingMicrotask; // owned by Microtask
+ OwnPtr<CancellableTaskFactory> m_finishTask;
+ OwnPtr<CancellableTaskFactory> m_dispatchErrorEventTask;
+
+ OwnPtr<IncrementLoadEventDelayCount> m_loadDelayCounterForMicrotask;
+ OwnPtr<IncrementLoadEventDelayCount> m_loadDelayCounterForFinish;
+ OwnPtr<IncrementLoadEventDelayCount> m_loadDelayCounterForError;
+
bool m_hasPendingLoadEvent : 1;
- bool m_hasPendingErrorEvent : 1;
bool m_imageComplete : 1;
bool m_loadingImageDocument : 1;
bool m_elementIsProtected : 1;
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLImageLoader.cpp ('k') | third_party/WebKit/Source/core/loader/ImageLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698