⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244815 in webkit


Ignore:
Timestamp:
Apr 30, 2019, 5:13:08 PM (7 years ago)
Author:
youenn@apple.com
Message:

Make Document audio producers use WeakPtr
https://bugs.webkit.org/show_bug.cgi?id=197382

Reviewed by Eric Carlson.

Source/WebCore:

Move from a hash set of raw pointers to a hash set of weak pointers.
This helps make the code cleaner.
No observable change of behavior.

  • Modules/mediastream/MediaStreamTrack.h:
  • dom/Document.cpp:

(WebCore::Document::addAudioProducer):
(WebCore::Document::removeAudioProducer):
(WebCore::Document::updateIsPlayingMedia):
(WebCore::Document::pageMutedStateDidChange):

  • dom/Document.h:
  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::updateActiveTextTrackCues):

  • html/HTMLMediaElement.h:
  • page/MediaProducer.h:

Source/WTF:

  • wtf/WeakHashSet.h:

(WTF::WeakHashSet::hasNullReferences const):

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r244801 r244815  
     12019-04-30  Youenn Fablet  <youenn@apple.com>
     2
     3        Make Document audio producers use WeakPtr
     4        https://bugs.webkit.org/show_bug.cgi?id=197382
     5
     6        Reviewed by Eric Carlson.
     7
     8        * wtf/WeakHashSet.h:
     9        (WTF::WeakHashSet::hasNullReferences const):
     10
    1112019-04-30  Commit Queue  <commit-queue@webkit.org>
    212
  • trunk/Source/WTF/wtf/WeakHashSet.h

    r244801 r244815  
    2626#pragma once
    2727
     28#include <wtf/Algorithms.h>
    2829#include <wtf/HashSet.h>
    2930#include <wtf/HashTraits.h>
     
    124125    }
    125126
     127    bool hasNullReferences() const
     128    {
     129        return WTF::anyOf(m_set, [] (auto& value) { return !value->get(); });
     130    }
     131
    126132    unsigned computeSize() const
    127133    {
  • trunk/Source/WebCore/ChangeLog

    r244813 r244815  
     12019-04-30  Youenn Fablet  <youenn@apple.com>
     2
     3        Make Document audio producers use WeakPtr
     4        https://bugs.webkit.org/show_bug.cgi?id=197382
     5
     6        Reviewed by Eric Carlson.
     7
     8        Move from a hash set of raw pointers to a hash set of weak pointers.
     9        This helps make the code cleaner.
     10        No observable change of behavior.
     11
     12        * Modules/mediastream/MediaStreamTrack.h:
     13        * dom/Document.cpp:
     14        (WebCore::Document::addAudioProducer):
     15        (WebCore::Document::removeAudioProducer):
     16        (WebCore::Document::updateIsPlayingMedia):
     17        (WebCore::Document::pageMutedStateDidChange):
     18        * dom/Document.h:
     19        * html/HTMLMediaElement.cpp:
     20        (WebCore::HTMLMediaElement::updateActiveTextTrackCues):
     21        * html/HTMLMediaElement.h:
     22        * page/MediaProducer.h:
     23
    1242019-04-30  Youenn Fablet  <youenn@apple.com>
    225
  • trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h

    r244801 r244815  
    5252    , public ActiveDOMObject
    5353    , public EventTargetWithInlineData
    54     , public CanMakeWeakPtr<MediaStreamTrack>
    55     , private MediaProducer
     54    , public MediaProducer
    5655    , private MediaStreamTrackPrivate::Observer
    5756#if !RELEASE_LOG_DISABLED
  • trunk/Source/WebCore/dom/Document.cpp

    r244801 r244815  
    39033903void Document::addAudioProducer(MediaProducer& audioProducer)
    39043904{
    3905     m_audioProducers.add(&audioProducer);
     3905    m_audioProducers.add(audioProducer);
    39063906    updateIsPlayingMedia();
    39073907}
     
    39093909void Document::removeAudioProducer(MediaProducer& audioProducer)
    39103910{
    3911     m_audioProducers.remove(&audioProducer);
     3911    m_audioProducers.remove(audioProducer);
    39123912    updateIsPlayingMedia();
    39133913}
     
    39283928{
    39293929    MediaProducer::MediaStateFlags state = MediaProducer::IsNotPlaying;
    3930     for (auto* audioProducer : m_audioProducers)
    3931         state |= audioProducer->mediaState();
     3930    for (auto& audioProducer : m_audioProducers)
     3931        state |= audioProducer.mediaState();
    39323932
    39333933#if ENABLE(MEDIA_SESSION)
     
    39703970void Document::pageMutedStateDidChange()
    39713971{
    3972     for (auto* audioProducer : m_audioProducers)
    3973         audioProducer->pageMutedStateDidChange();
     3972    for (auto& audioProducer : m_audioProducers)
     3973        audioProducer.pageMutedStateDidChange();
    39743974}
    39753975
  • trunk/Source/WebCore/dom/Document.h

    r244801 r244815  
    6767#include <wtf/ObjectIdentifier.h>
    6868#include <wtf/UniqueRef.h>
     69#include <wtf/WeakHashSet.h>
    6970#include <wtf/WeakPtr.h>
    7071#include <wtf/text/AtomicStringHash.h>
     
    18921893    Ref<CSSFontSelector> m_fontSelector;
    18931894
    1894     HashSet<MediaProducer*> m_audioProducers;
     1895    WeakHashSet<MediaProducer> m_audioProducers;
    18951896
    18961897    HashSet<ShadowRoot*> m_inDocumentShadowRoots;
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r244801 r244815  
    17691769                return;
    17701770
    1771             auto currentMediaTime = weakThis->currentMediaTime();
     1771            auto currentMediaTime = this->currentMediaTime();
    17721772            INFO_LOG(LOGIDENTIFIER, " lambda, currentMediaTime: ", currentMediaTime);
    1773             weakThis->updateActiveTextTrackCues(currentMediaTime);
     1773            this->updateActiveTextTrackCues(currentMediaTime);
    17741774        }, nextInterestingTime);
    17751775    }
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r244801 r244815  
    574574    enum class AutoplayEventPlaybackState { None, PreventedAutoplay, StartedWithUserGesture, StartedWithoutUserGesture };
    575575
     576    using HTMLElement::weakPtrFactory;
     577
    576578protected:
    577579    HTMLMediaElement(const QualifiedName&, Document&, bool createdByParser);
  • trunk/Source/WebCore/page/MediaProducer.h

    r244801 r244815  
    2626#pragma once
    2727
     28#include <wtf/WeakPtr.h>
     29
    2830namespace WebCore {
    2931
    30 class MediaProducer {
     32class MediaProducer : public CanMakeWeakPtr<MediaProducer> {
    3133public:
    3234    enum MediaState {
Note: See TracChangeset for help on using the changeset viewer.