Changeset 243337 in webkit


Ignore:
Timestamp:
Mar 21, 2019 3:36:08 PM (5 years ago)
Author:
Brent Fulgham
Message:

Hardening: Use WeakPtrs in PlaybackSessionInterface{Mac,AVKit}
https://bugs.webkit.org/show_bug.cgi?id=195935
<rdar://problem/49007015>

Reviewed by Eric Carlson.

The PlaybackSessionInterface{Mac,AVKit} implementations store their playback session model
and playback controls manager members as bare pointers, something we've been working
to eliminate.

This patch corrects this oversight.

No new tests since no changes in behavior.

  • platform/cocoa/PlaybackSessionModel.h:
  • platform/ios/PlaybackSessionInterfaceAVKit.h:
  • platform/ios/PlaybackSessionInterfaceAVKit.mm:

(WebCore::PlaybackSessionInterfaceAVKit::PlaybackSessionInterfaceAVKit):
(WebCore::playbackSessionModel const): Moved to implementation since WEBCORE_EXPORT is not
supposed to be used with inline methods.

  • platform/mac/PlaybackSessionInterfaceMac.h:
  • platform/mac/PlaybackSessionInterfaceMac.mm:

(WebCore::PlaybackSessionInterfaceMac::PlaybackSessionInterfaceMac):
(WebCore::PlaybackSessionInterfaceMac::playbackSessionModel const):
(WebCore::PlaybackSessionInterfaceMac::beginScrubbing):
(WebCore::PlaybackSessionInterfaceMac::endScrubbing):
(WebCore::PlaybackSessionInterfaceMac::playBackControlsManager):

  • platform/mac/VideoFullscreenInterfaceMac.mm:

(WebCore::VideoFullscreenInterfaceMac::~VideoFullscreenInterfaceMac):

  • platform/mac/WebPlaybackControlsManager.mm:

(-[WebPlaybackControlsManager seekToTime:toleranceBefore:toleranceAfter:]):
(-[WebPlaybackControlsManager setCurrentAudioTouchBarMediaSelectionOption:]):
(-[WebPlaybackControlsManager setCurrentLegibleTouchBarMediaSelectionOption:]):

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243336 r243337  
     12019-03-21  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Hardening: Use WeakPtrs in PlaybackSessionInterface{Mac,AVKit}
     4        https://bugs.webkit.org/show_bug.cgi?id=195935
     5        <rdar://problem/49007015>
     6
     7        Reviewed by Eric Carlson.
     8
     9        The PlaybackSessionInterface{Mac,AVKit} implementations store their playback session model
     10        and playback controls manager members as bare pointers, something we've been working
     11        to eliminate.
     12       
     13        This patch corrects this oversight.
     14
     15        No new tests since no changes in behavior.
     16
     17        * platform/cocoa/PlaybackSessionModel.h:
     18        * platform/ios/PlaybackSessionInterfaceAVKit.h:
     19        * platform/ios/PlaybackSessionInterfaceAVKit.mm:
     20        (WebCore::PlaybackSessionInterfaceAVKit::PlaybackSessionInterfaceAVKit):
     21        (WebCore::playbackSessionModel const): Moved to implementation since WEBCORE_EXPORT is not
     22        supposed to be used with inline methods.
     23        * platform/mac/PlaybackSessionInterfaceMac.h:
     24        * platform/mac/PlaybackSessionInterfaceMac.mm:
     25        (WebCore::PlaybackSessionInterfaceMac::PlaybackSessionInterfaceMac):
     26        (WebCore::PlaybackSessionInterfaceMac::playbackSessionModel const):
     27        (WebCore::PlaybackSessionInterfaceMac::beginScrubbing):
     28        (WebCore::PlaybackSessionInterfaceMac::endScrubbing):
     29        (WebCore::PlaybackSessionInterfaceMac::playBackControlsManager):
     30        * platform/mac/VideoFullscreenInterfaceMac.mm:
     31        (WebCore::VideoFullscreenInterfaceMac::~VideoFullscreenInterfaceMac):
     32        * platform/mac/WebPlaybackControlsManager.mm:
     33        (-[WebPlaybackControlsManager seekToTime:toleranceBefore:toleranceAfter:]):
     34        (-[WebPlaybackControlsManager setCurrentAudioTouchBarMediaSelectionOption:]):
     35        (-[WebPlaybackControlsManager setCurrentLegibleTouchBarMediaSelectionOption:]):
     36
    1372019-03-21  Said Abou-Hallawa  <said@apple.com>
    238
  • trunk/Source/WebCore/platform/cocoa/PlaybackSessionModel.h

    r237266 r243337  
    11/*
    2  * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3131#include <wtf/Ref.h>
    3232#include <wtf/Vector.h>
     33#include <wtf/WeakPtr.h>
    3334
    3435namespace WebCore {
     
    3839struct MediaSelectionOption;
    3940
    40 class PlaybackSessionModel {
     41class PlaybackSessionModel : public CanMakeWeakPtr<PlaybackSessionModel> {
    4142public:
    4243    virtual ~PlaybackSessionModel() { };
  • trunk/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.h

    r237266 r243337  
    11/*
    2  * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    6363    }
    6464    virtual ~PlaybackSessionInterfaceAVKit();
    65     PlaybackSessionModel* playbackSessionModel() const { return m_playbackSessionModel; }
     65    PlaybackSessionModel* playbackSessionModel() const;
    6666
    6767    // PlaybackSessionModelClient
     
    8787
    8888    RetainPtr<WebAVPlayerController> m_playerController;
    89     PlaybackSessionModel* m_playbackSessionModel { nullptr };
     89    WeakPtr<PlaybackSessionModel> m_playbackSessionModel;
    9090};
    9191
  • trunk/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.mm

    r238952 r243337  
    11/*
    2  * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5252PlaybackSessionInterfaceAVKit::PlaybackSessionInterfaceAVKit(PlaybackSessionModel& model)
    5353    : m_playerController(adoptNS([[WebAVPlayerController alloc] init]))
    54     , m_playbackSessionModel(&model)
     54    , m_playbackSessionModel(makeWeakPtr(model))
    5555{
    5656    model.addClient(*this);
     
    7878}
    7979
     80PlaybackSessionModel* playbackSessionModel() const
     81{
     82    return m_playbackSessionModel.get();
     83}
     84
    8085void PlaybackSessionInterfaceAVKit::durationChanged(double duration)
    8186{
  • trunk/Source/WebCore/platform/mac/PlaybackSessionInterfaceMac.h

    r236933 r243337  
    11/*
    2  * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3333#include <wtf/RefCounted.h>
    3434#include <wtf/RetainPtr.h>
     35#include <wtf/WeakObjCPtr.h>
     36#include <wtf/WeakPtr.h>
    3537#include <wtf/text/WTFString.h>
    3638
     
    7577private:
    7678    PlaybackSessionInterfaceMac(PlaybackSessionModel&);
    77     PlaybackSessionModel* m_playbackSessionModel { nullptr };
     79    WeakPtr<PlaybackSessionModel> m_playbackSessionModel;
    7880#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
    79     WebPlaybackControlsManager *m_playbackControlsManager  { nullptr };
     81    WeakObjCPtr<WebPlaybackControlsManager> m_playbackControlsManager;
    8082
    8183    void updatePlaybackControlsManagerTiming(double currentTime, double anchorTime, double playbackRate, bool isPlaying);
  • trunk/Source/WebCore/platform/mac/PlaybackSessionInterfaceMac.mm

    r236933 r243337  
    11/*
    2  * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5353
    5454PlaybackSessionInterfaceMac::PlaybackSessionInterfaceMac(PlaybackSessionModel& model)
    55     : m_playbackSessionModel(&model)
     55    : m_playbackSessionModel(makeWeakPtr(model))
    5656{
    5757}
     
    6464PlaybackSessionModel* PlaybackSessionInterfaceMac::playbackSessionModel() const
    6565{
    66     return m_playbackSessionModel;
     66    return m_playbackSessionModel.get();
    6767}
    6868
     
    111111    updatePlaybackControlsManagerTiming(m_playbackSessionModel ? m_playbackSessionModel->currentTime() : 0, [[NSProcessInfo processInfo] systemUptime], 0, false);
    112112#endif
    113     playbackSessionModel()->beginScrubbing();
     113    if (auto* model = playbackSessionModel())
     114        model->beginScrubbing();
    114115}
    115116
    116117void PlaybackSessionInterfaceMac::endScrubbing()
    117118{
    118     playbackSessionModel()->endScrubbing();
     119    if (auto* model = playbackSessionModel())
     120        model->endScrubbing();
    119121}
    120122
     
    215217WebPlaybackControlsManager *PlaybackSessionInterfaceMac::playBackControlsManager()
    216218{
    217     return m_playbackControlsManager;
     219    return m_playbackControlsManager.getAutoreleased();
    218220}
    219221
  • trunk/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm

    r243298 r243337  
    367367VideoFullscreenInterfaceMac::~VideoFullscreenInterfaceMac()
    368368{
    369     if (m_playbackSessionInterface->playbackSessionModel())
    370         m_playbackSessionInterface->playbackSessionModel()->removeClient(*this);
     369    if (auto* model = m_playbackSessionInterface->playbackSessionModel())
     370        model->removeClient(*this);
    371371    if (m_videoFullscreenModel)
    372372        m_videoFullscreenModel->removeClient(*this);
  • trunk/Source/WebCore/platform/mac/WebPlaybackControlsManager.mm

    r239255 r243337  
    11/*
    2  * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    9595    UNUSED_PARAM(toleranceBefore);
    9696    UNUSED_PARAM(toleranceAfter);
    97     _playbackSessionInterfaceMac->playbackSessionModel()->seekToTime(time);
     97    if (auto* model = _playbackSessionInterfaceMac->playbackSessionModel())
     98        model->seekToTime(time);
    9899}
    99100
     
    194195        index = [_audioTouchBarMediaSelectionOptions indexOfObject:audioMediaSelectionOption];
    195196
    196     _playbackSessionInterfaceMac->playbackSessionModel()->selectAudioMediaOption(index != NSNotFound ? index : UINT64_MAX);
     197    if (auto* model = _playbackSessionInterfaceMac->playbackSessionModel())
     198        model->selectAudioMediaOption(index != NSNotFound ? index : UINT64_MAX);
    197199}
    198200
     
    224226        index = [_legibleTouchBarMediaSelectionOptions indexOfObject:legibleMediaSelectionOption];
    225227
    226     _playbackSessionInterfaceMac->playbackSessionModel()->selectLegibleMediaOption(index != NSNotFound ? index : UINT64_MAX);
     228    if (auto* model = _playbackSessionInterfaceMac->playbackSessionModel())
     229        model->selectLegibleMediaOption(index != NSNotFound ? index : UINT64_MAX);
    227230}
    228231
Note: See TracChangeset for help on using the changeset viewer.