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

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

Issue 2329243002: Implement WTF::WeakPtr in terms of base::WeakPtr (Closed)
Patch Set: Thread-safety fix with comment Created 4 years, 3 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
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 reserv ed. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserv ed.
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 *
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up dateFromElementBehavior updateBehavior, const KURL& url, ReferrerPolicy referrer Policy) 257 void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up dateFromElementBehavior updateBehavior, const KURL& url, ReferrerPolicy referrer Policy)
258 { 258 {
259 // FIXME: According to 259 // FIXME: According to
260 // http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-cont ent.html#the-img-element:the-img-element-55 260 // http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-cont ent.html#the-img-element:the-img-element-55
261 // When "update image" is called due to environment changes and the load fai ls, onerror should not be called. 261 // When "update image" is called due to environment changes and the load fai ls, onerror should not be called.
262 // That is currently not the case. 262 // That is currently not the case.
263 // 263 //
264 // We don't need to call clearLoader here: Either we were called from the 264 // We don't need to call clearLoader here: Either we were called from the
265 // task, or our caller updateFromElement cleared the task's loader (and set 265 // task, or our caller updateFromElement cleared the task's loader (and set
266 // m_pendingTask to null). 266 // m_pendingTask to null).
267 m_pendingTask.clear(); 267 m_pendingTask.reset();
268 // Make sure to only decrement the count when we exit this function 268 // Make sure to only decrement the count when we exit this function
269 std::unique_ptr<IncrementLoadEventDelayCount> loadDelayCounter; 269 std::unique_ptr<IncrementLoadEventDelayCount> loadDelayCounter;
270 loadDelayCounter.swap(m_loadDelayCounter); 270 loadDelayCounter.swap(m_loadDelayCounter);
271 271
272 Document& document = m_element->document(); 272 Document& document = m_element->document();
273 if (!document.isActive()) 273 if (!document.isActive())
274 return; 274 return;
275 275
276 AtomicString imageSourceURL = m_element->imageSourceURL(); 276 AtomicString imageSourceURL = m_element->imageSourceURL();
277 ImageResource* newImage = nullptr; 277 ImageResource* newImage = nullptr;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 if (m_loadingImageDocument && updateBehavior != UpdateForcedReload) { 368 if (m_loadingImageDocument && updateBehavior != UpdateForcedReload) {
369 setImage(ImageResource::create(imageSourceToKURL(m_element->imageSourceU RL()))); 369 setImage(ImageResource::create(imageSourceToKURL(m_element->imageSourceU RL())));
370 m_image->setStatus(Resource::Pending); 370 m_image->setStatus(Resource::Pending);
371 return; 371 return;
372 } 372 }
373 373
374 // If we have a pending task, we have to clear it -- either we're 374 // If we have a pending task, we have to clear it -- either we're
375 // now loading immediately, or we need to reset the task's state. 375 // now loading immediately, or we need to reset the task's state.
376 if (m_pendingTask) { 376 if (m_pendingTask) {
377 m_pendingTask->clearLoader(); 377 m_pendingTask->clearLoader();
378 m_pendingTask.clear(); 378 m_pendingTask.reset();
379 } 379 }
380 380
381 KURL url = imageSourceToKURL(imageSourceURL); 381 KURL url = imageSourceToKURL(imageSourceURL);
382 if (shouldLoadImmediately(url)) { 382 if (shouldLoadImmediately(url)) {
383 doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior, url, referr erPolicy); 383 doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior, url, referr erPolicy);
384 return; 384 return;
385 } 385 }
386 // Allow the idiom "img.src=''; img.src='.." to clear down the image before 386 // Allow the idiom "img.src=''; img.src='.." to clear down the image before
387 // an asynchronous load completes. 387 // an asynchronous load completes.
388 if (imageSourceURL.isEmpty()) { 388 if (imageSourceURL.isEmpty()) {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 605
606 void ImageLoader::elementDidMoveToNewDocument() 606 void ImageLoader::elementDidMoveToNewDocument()
607 { 607 {
608 if (m_loadDelayCounter) 608 if (m_loadDelayCounter)
609 m_loadDelayCounter->documentChanged(m_element->document()); 609 m_loadDelayCounter->documentChanged(m_element->document());
610 clearFailedLoadURL(); 610 clearFailedLoadURL();
611 setImage(0); 611 setImage(0);
612 } 612 }
613 613
614 } // namespace blink 614 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698