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

Side by Side Diff: third_party/WebKit/Source/core/loader/ImageLoader.cpp

Issue 2893993002: Make ImageLoader have at most one pending error event on EventSender (Closed)
Patch Set: Add comment Created 3 years, 7 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
« no previous file with comments | « third_party/WebKit/LayoutTests/images/multiple-inflight-error-event-crash.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights 4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights
5 * reserved. 5 * 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 params.SetCrossOriginAccessControl( 266 params.SetCrossOriginAccessControl(
267 element.GetDocument().GetSecurityOrigin(), cross_origin); 267 element.GetDocument().GetSecurityOrigin(), cross_origin);
268 } 268 }
269 269
270 if (client_hints_preferences.ShouldSendResourceWidth() && 270 if (client_hints_preferences.ShouldSendResourceWidth() &&
271 isHTMLImageElement(element)) 271 isHTMLImageElement(element))
272 params.SetResourceWidth(toHTMLImageElement(element).GetResourceWidth()); 272 params.SetResourceWidth(toHTMLImageElement(element).GetResourceWidth());
273 } 273 }
274 274
275 inline void ImageLoader::DispatchErrorEvent() { 275 inline void ImageLoader::DispatchErrorEvent() {
276 // There can be cases where DispatchErrorEvent() is called when there is
277 // already a scheduled error event for the previous load attempt.
278 // In such cases we cancel the previous event and then re-schedule a new
279 // error event here. crbug.com/722500
280 if (has_pending_error_event_)
281 ErrorEventSender().CancelEvent(this);
282
276 has_pending_error_event_ = true; 283 has_pending_error_event_ = true;
277 ErrorEventSender().DispatchEventSoon(this); 284 ErrorEventSender().DispatchEventSoon(this);
278 } 285 }
279 286
280 inline void ImageLoader::CrossSiteOrCSPViolationOccurred( 287 inline void ImageLoader::CrossSiteOrCSPViolationOccurred(
281 AtomicString image_source_url) { 288 AtomicString image_source_url) {
282 failed_load_url_ = image_source_url; 289 failed_load_url_ = image_source_url;
283 } 290 }
284 291
285 inline void ImageLoader::ClearFailedLoadURL() { 292 inline void ImageLoader::ClearFailedLoadURL() {
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 if (GetElement()->GetDocument().GetFrame()) 679 if (GetElement()->GetDocument().GetFrame())
673 DispatchLoadEvent(); 680 DispatchLoadEvent();
674 681
675 // Only consider updating the protection ref-count of the Element immediately 682 // Only consider updating the protection ref-count of the Element immediately
676 // before returning from this function as doing so might result in the 683 // before returning from this function as doing so might result in the
677 // destruction of this ImageLoader. 684 // destruction of this ImageLoader.
678 UpdatedHasPendingEvent(); 685 UpdatedHasPendingEvent();
679 } 686 }
680 687
681 void ImageLoader::DispatchPendingErrorEvent() { 688 void ImageLoader::DispatchPendingErrorEvent() {
682 // Currently this if condition is needed because there can be multiple 689 CHECK(has_pending_error_event_);
683 // in-flight error event tasks and we process only the first here.
684 // crbug.com/722500
685 // TODO(hiroshige): Replace this with |CHECK(has_pending_load_event_)|.
686 if (!has_pending_error_event_)
687 return;
688 has_pending_error_event_ = false; 690 has_pending_error_event_ = false;
689 691
690 if (GetElement()->GetDocument().GetFrame()) 692 if (GetElement()->GetDocument().GetFrame())
691 GetElement()->DispatchEvent(Event::Create(EventTypeNames::error)); 693 GetElement()->DispatchEvent(Event::Create(EventTypeNames::error));
692 694
693 // Only consider updating the protection ref-count of the Element immediately 695 // Only consider updating the protection ref-count of the Element immediately
694 // before returning from this function as doing so might result in the 696 // before returning from this function as doing so might result in the
695 // destruction of this ImageLoader. 697 // destruction of this ImageLoader.
696 UpdatedHasPendingEvent(); 698 UpdatedHasPendingEvent();
697 } 699 }
(...skipping 21 matching lines...) Expand all
719 } 721 }
720 if (delay_until_image_notify_finished_) { 722 if (delay_until_image_notify_finished_) {
721 delay_until_image_notify_finished_->DocumentChanged( 723 delay_until_image_notify_finished_->DocumentChanged(
722 element_->GetDocument()); 724 element_->GetDocument());
723 } 725 }
724 ClearFailedLoadURL(); 726 ClearFailedLoadURL();
725 ClearImage(); 727 ClearImage();
726 } 728 }
727 729
728 } // namespace blink 730 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/images/multiple-inflight-error-event-crash.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698