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

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: cleanup, fix new layout tests Created 4 years, 9 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 abb6414f84a8288205bf85839ff01ec0ab02031b..040fd3e61f1e9ba4d600efa35c90654ed45eb3d2 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 NoBaseWillBeGarbageCollectedFinalized<ImageLoader>, public ResourceClient, public ImageResourceObserver {
WILL_BE_USING_PRE_FINALIZER(ImageLoader, dispose);
USING_FAST_MALLOC_WILL_BE_REMOVED(ImageLoader);
@@ -79,7 +76,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(); }
@@ -89,43 +86,47 @@ 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 notifyFinished(Resource*) override;
+ virtual void finishInternal(ImageResource*) { }
private:
class Task;
+ void notifyFinished(Resource*) 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 scheduleFinish();
+ 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);
@@ -153,10 +154,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;

Powered by Google App Engine
This is Rietveld 408576698