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, 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 if (m_image) | 115 if (m_image) |
| 116 m_image->removeClient(this); | 116 m_image->removeClient(this); |
| 117 | 117 |
| 118 ASSERT(m_hasPendingLoadEvent || !loadEventSender().hasPendingEvents(this)); | 118 ASSERT(m_hasPendingLoadEvent || !loadEventSender().hasPendingEvents(this)); |
| 119 if (m_hasPendingLoadEvent) | 119 if (m_hasPendingLoadEvent) |
| 120 loadEventSender().cancelEvent(this); | 120 loadEventSender().cancelEvent(this); |
| 121 | 121 |
| 122 ASSERT(m_hasPendingErrorEvent || !errorEventSender().hasPendingEvents(this)) ; | 122 ASSERT(m_hasPendingErrorEvent || !errorEventSender().hasPendingEvents(this)) ; |
| 123 if (m_hasPendingErrorEvent) | 123 if (m_hasPendingErrorEvent) |
| 124 errorEventSender().cancelEvent(this); | 124 errorEventSender().cancelEvent(this); |
| 125 | 125 #if !ENABLE(OILPAN) |
| 126 // If the ImageLoader is being destroyed but it is still protecting its imag e-loading Element, | 126 // If the ImageLoader is being destroyed but it is still protecting its imag e-loading Element, |
| 127 // remove that protection here. | 127 // remove that protection here. |
| 128 if (m_elementIsProtected) | 128 if (m_elementIsProtected) |
| 129 m_element->deref(); | 129 m_element->deref(); |
|
haraken
2014/06/09 11:12:33
It looks strange that we don't have corresponding
tkent
2014/06/10 01:43:09
The corresponding code is the destructor of m_keep
| |
| 130 #endif | |
| 131 } | |
| 132 | |
| 133 void ImageLoader::trace(Visitor* visitor) | |
| 134 { | |
| 135 visitor->trace(m_element); | |
| 136 visitor->trace(m_clients); | |
|
tkent
2014/06/10 01:43:09
Will remove this.
| |
| 130 } | 137 } |
| 131 | 138 |
| 132 void ImageLoader::setImage(ImageResource* newImage) | 139 void ImageLoader::setImage(ImageResource* newImage) |
| 133 { | 140 { |
| 134 setImageWithoutConsideringPendingLoadEvent(newImage); | 141 setImageWithoutConsideringPendingLoadEvent(newImage); |
| 135 | 142 |
| 136 // Only consider updating the protection ref-count of the Element immediatel y before returning | 143 // Only consider updating the protection ref-count of the Element immediatel y before returning |
| 137 // from this function as doing so might result in the destruction of this Im ageLoader. | 144 // from this function as doing so might result in the destruction of this Im ageLoader. |
| 138 updatedHasPendingEvent(); | 145 updatedHasPendingEvent(); |
| 139 } | 146 } |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 // If an Element that does image loading is removed from the DOM the load/er ror event for the image is still observable. | 413 // If an Element that does image loading is removed from the DOM the load/er ror event for the image is still observable. |
| 407 // As long as the ImageLoader is actively loading, the Element itself needs to be ref'ed to keep it from being | 414 // As long as the ImageLoader is actively loading, the Element itself needs to be ref'ed to keep it from being |
| 408 // destroyed by DOM manipulation or garbage collection. | 415 // destroyed by DOM manipulation or garbage collection. |
| 409 // If such an Element wishes for the load to stop when removed from the DOM it needs to stop the ImageLoader explicitly. | 416 // If such an Element wishes for the load to stop when removed from the DOM it needs to stop the ImageLoader explicitly. |
| 410 bool wasProtected = m_elementIsProtected; | 417 bool wasProtected = m_elementIsProtected; |
| 411 m_elementIsProtected = m_hasPendingLoadEvent || m_hasPendingErrorEvent; | 418 m_elementIsProtected = m_hasPendingLoadEvent || m_hasPendingErrorEvent; |
| 412 if (wasProtected == m_elementIsProtected) | 419 if (wasProtected == m_elementIsProtected) |
| 413 return; | 420 return; |
| 414 | 421 |
| 415 if (m_elementIsProtected) { | 422 if (m_elementIsProtected) { |
| 416 if (m_derefElementTimer.isActive()) | 423 if (m_derefElementTimer.isActive()) { |
| 417 m_derefElementTimer.stop(); | 424 m_derefElementTimer.stop(); |
| 418 else | 425 } else { |
| 426 #if ENABLE(OILPAN) | |
| 427 m_keepAlive = this; | |
|
haraken
2014/06/09 11:12:34
I'm afraid this will cause memory leak. If timerFi
tkent
2014/06/10 01:43:09
I think timerFired() is always triggered. m_keepAl
haraken
2014/06/10 01:59:05
It's not clear to me if timerFired() is always tri
tkent
2014/06/10 02:37:59
If enable_oilpan=0 and the owner element releases
| |
| 428 #else | |
| 419 m_element->ref(); | 429 m_element->ref(); |
| 430 #endif | |
| 431 } | |
| 420 } else { | 432 } else { |
| 421 ASSERT(!m_derefElementTimer.isActive()); | 433 ASSERT(!m_derefElementTimer.isActive()); |
| 422 m_derefElementTimer.startOneShot(0, FROM_HERE); | 434 m_derefElementTimer.startOneShot(0, FROM_HERE); |
| 423 } | 435 } |
| 424 } | 436 } |
| 425 | 437 |
| 426 void ImageLoader::timerFired(Timer<ImageLoader>*) | 438 void ImageLoader::timerFired(Timer<ImageLoader>*) |
| 427 { | 439 { |
| 440 #if ENABLE(OILPAN) | |
| 441 m_keepAlive.clear(); | |
| 442 #else | |
| 428 m_element->deref(); | 443 m_element->deref(); |
| 444 #endif | |
| 429 } | 445 } |
| 430 | 446 |
| 431 void ImageLoader::dispatchPendingEvent(ImageEventSender* eventSender) | 447 void ImageLoader::dispatchPendingEvent(ImageEventSender* eventSender) |
| 432 { | 448 { |
| 433 ASSERT(eventSender == &loadEventSender() || eventSender == &errorEventSender ()); | 449 ASSERT(eventSender == &loadEventSender() || eventSender == &errorEventSender ()); |
| 434 const AtomicString& eventType = eventSender->eventType(); | 450 const AtomicString& eventType = eventSender->eventType(); |
| 435 if (eventType == EventTypeNames::load) | 451 if (eventType == EventTypeNames::load) |
| 436 dispatchPendingLoadEvent(); | 452 dispatchPendingLoadEvent(); |
| 437 if (eventType == EventTypeNames::error) | 453 if (eventType == EventTypeNames::error) |
| 438 dispatchPendingErrorEvent(); | 454 dispatchPendingErrorEvent(); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 } | 555 } |
| 540 | 556 |
| 541 #if ENABLE(OILPAN) | 557 #if ENABLE(OILPAN) |
| 542 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover() | 558 ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover() |
| 543 { | 559 { |
| 544 m_loader.willRemoveClient(m_client); | 560 m_loader.willRemoveClient(m_client); |
| 545 } | 561 } |
| 546 #endif | 562 #endif |
| 547 | 563 |
| 548 } | 564 } |
| OLD | NEW |