Changeset 185570 in webkit


Ignore:
Timestamp:
Jun 15, 2015 4:06:01 PM (9 years ago)
Author:
commit-queue@webkit.org
Message:

Media Session: Improve the safety of playback toggling
https://bugs.webkit.org/show_bug.cgi?id=145986

Patch by Matt Rajca <mrajca@apple.com> on 2015-06-15
Reviewed by Darin Adler.

  • Modules/mediasession/MediaSession.cpp:

(WebCore::MediaSession::togglePlayback): Improved the safety of the loop so that we don't re-visit elements that

may have been deleted underneath us.

  • Modules/mediasession/MediaSession.h: Added a pointer to the set of iterated active participating elements so we can remove any elements that are deleted from the underlying "real" set.
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r185569 r185570  
     12015-06-15  Matt Rajca  <mrajca@apple.com>
     2
     3        Media Session: Improve the safety of playback toggling
     4        https://bugs.webkit.org/show_bug.cgi?id=145986
     5
     6        Reviewed by Darin Adler.
     7
     8        * Modules/mediasession/MediaSession.cpp:
     9        (WebCore::MediaSession::togglePlayback): Improved the safety of the loop so that we don't re-visit elements that
     10          may have been deleted underneath us.
     11        * Modules/mediasession/MediaSession.h: Added a pointer to the set of iterated active participating elements so
     12          we can remove any elements that are deleted from the underlying "real" set.
     13
    1142015-06-15  Brent Fulgham  <bfulgham@apple.com>
    215
  • trunk/Source/WebCore/Modules/mediasession/MediaSession.cpp

    r185560 r185570  
    9595void MediaSession::togglePlayback()
    9696{
     97    ASSERT(!m_iteratedActiveParticipatingElements);
     98
    9799    HashSet<HTMLMediaElement*> activeParticipatingElementsCopy = m_activeParticipatingElements;
     100    m_iteratedActiveParticipatingElements = &activeParticipatingElementsCopy;
    98101
    99     for (auto* element : activeParticipatingElementsCopy) {
     102    while (!activeParticipatingElementsCopy.isEmpty()) {
     103        HTMLMediaElement* element = activeParticipatingElementsCopy.takeAny();
     104
    100105        if (element->paused())
    101106            element->play();
     
    103108            element->pause();
    104109    }
     110
     111    m_iteratedActiveParticipatingElements = nullptr;
    105112}
    106113
  • trunk/Source/WebCore/Modules/mediasession/MediaSession.h

    r185514 r185570  
    7474    Vector<HTMLMediaElement*> m_participatingElements;
    7575    HashSet<HTMLMediaElement*> m_activeParticipatingElements;
     76    HashSet<HTMLMediaElement*>* m_iteratedActiveParticipatingElements { nullptr };
    7677
    7778    const String m_kind;
Note: See TracChangeset for help on using the changeset viewer.