Changeset 243337 in webkit
- Timestamp:
- Mar 21, 2019 3:36:08 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r243336 r243337 1 2019-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 1 37 2019-03-21 Said Abou-Hallawa <said@apple.com> 2 38 -
trunk/Source/WebCore/platform/cocoa/PlaybackSessionModel.h
r237266 r243337 1 1 /* 2 * Copyright (C) 2016-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 31 31 #include <wtf/Ref.h> 32 32 #include <wtf/Vector.h> 33 #include <wtf/WeakPtr.h> 33 34 34 35 namespace WebCore { … … 38 39 struct MediaSelectionOption; 39 40 40 class PlaybackSessionModel {41 class PlaybackSessionModel : public CanMakeWeakPtr<PlaybackSessionModel> { 41 42 public: 42 43 virtual ~PlaybackSessionModel() { }; -
trunk/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.h
r237266 r243337 1 1 /* 2 * Copyright (C) 2016-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 63 63 } 64 64 virtual ~PlaybackSessionInterfaceAVKit(); 65 PlaybackSessionModel* playbackSessionModel() const { return m_playbackSessionModel; }65 PlaybackSessionModel* playbackSessionModel() const; 66 66 67 67 // PlaybackSessionModelClient … … 87 87 88 88 RetainPtr<WebAVPlayerController> m_playerController; 89 PlaybackSessionModel* m_playbackSessionModel { nullptr };89 WeakPtr<PlaybackSessionModel> m_playbackSessionModel; 90 90 }; 91 91 -
trunk/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.mm
r238952 r243337 1 1 /* 2 * Copyright (C) 2014 , 2015Apple Inc. All rights reserved.2 * Copyright (C) 2014-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 52 52 PlaybackSessionInterfaceAVKit::PlaybackSessionInterfaceAVKit(PlaybackSessionModel& model) 53 53 : m_playerController(adoptNS([[WebAVPlayerController alloc] init])) 54 , m_playbackSessionModel( &model)54 , m_playbackSessionModel(makeWeakPtr(model)) 55 55 { 56 56 model.addClient(*this); … … 78 78 } 79 79 80 PlaybackSessionModel* playbackSessionModel() const 81 { 82 return m_playbackSessionModel.get(); 83 } 84 80 85 void PlaybackSessionInterfaceAVKit::durationChanged(double duration) 81 86 { -
trunk/Source/WebCore/platform/mac/PlaybackSessionInterfaceMac.h
r236933 r243337 1 1 /* 2 * Copyright (C) 2016-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 #include <wtf/RefCounted.h> 34 34 #include <wtf/RetainPtr.h> 35 #include <wtf/WeakObjCPtr.h> 36 #include <wtf/WeakPtr.h> 35 37 #include <wtf/text/WTFString.h> 36 38 … … 75 77 private: 76 78 PlaybackSessionInterfaceMac(PlaybackSessionModel&); 77 PlaybackSessionModel* m_playbackSessionModel { nullptr };79 WeakPtr<PlaybackSessionModel> m_playbackSessionModel; 78 80 #if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER) 79 We bPlaybackControlsManager *m_playbackControlsManager { nullptr };81 WeakObjCPtr<WebPlaybackControlsManager> m_playbackControlsManager; 80 82 81 83 void updatePlaybackControlsManagerTiming(double currentTime, double anchorTime, double playbackRate, bool isPlaying); -
trunk/Source/WebCore/platform/mac/PlaybackSessionInterfaceMac.mm
r236933 r243337 1 1 /* 2 * Copyright (C) 2016-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 53 53 54 54 PlaybackSessionInterfaceMac::PlaybackSessionInterfaceMac(PlaybackSessionModel& model) 55 : m_playbackSessionModel( &model)55 : m_playbackSessionModel(makeWeakPtr(model)) 56 56 { 57 57 } … … 64 64 PlaybackSessionModel* PlaybackSessionInterfaceMac::playbackSessionModel() const 65 65 { 66 return m_playbackSessionModel ;66 return m_playbackSessionModel.get(); 67 67 } 68 68 … … 111 111 updatePlaybackControlsManagerTiming(m_playbackSessionModel ? m_playbackSessionModel->currentTime() : 0, [[NSProcessInfo processInfo] systemUptime], 0, false); 112 112 #endif 113 playbackSessionModel()->beginScrubbing(); 113 if (auto* model = playbackSessionModel()) 114 model->beginScrubbing(); 114 115 } 115 116 116 117 void PlaybackSessionInterfaceMac::endScrubbing() 117 118 { 118 playbackSessionModel()->endScrubbing(); 119 if (auto* model = playbackSessionModel()) 120 model->endScrubbing(); 119 121 } 120 122 … … 215 217 WebPlaybackControlsManager *PlaybackSessionInterfaceMac::playBackControlsManager() 216 218 { 217 return m_playbackControlsManager ;219 return m_playbackControlsManager.getAutoreleased(); 218 220 } 219 221 -
trunk/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm
r243298 r243337 367 367 VideoFullscreenInterfaceMac::~VideoFullscreenInterfaceMac() 368 368 { 369 if ( m_playbackSessionInterface->playbackSessionModel())370 m _playbackSessionInterface->playbackSessionModel()->removeClient(*this);369 if (auto* model = m_playbackSessionInterface->playbackSessionModel()) 370 model->removeClient(*this); 371 371 if (m_videoFullscreenModel) 372 372 m_videoFullscreenModel->removeClient(*this); -
trunk/Source/WebCore/platform/mac/WebPlaybackControlsManager.mm
r239255 r243337 1 1 /* 2 * Copyright (C) 2016-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 95 95 UNUSED_PARAM(toleranceBefore); 96 96 UNUSED_PARAM(toleranceAfter); 97 _playbackSessionInterfaceMac->playbackSessionModel()->seekToTime(time); 97 if (auto* model = _playbackSessionInterfaceMac->playbackSessionModel()) 98 model->seekToTime(time); 98 99 } 99 100 … … 194 195 index = [_audioTouchBarMediaSelectionOptions indexOfObject:audioMediaSelectionOption]; 195 196 196 _playbackSessionInterfaceMac->playbackSessionModel()->selectAudioMediaOption(index != NSNotFound ? index : UINT64_MAX); 197 if (auto* model = _playbackSessionInterfaceMac->playbackSessionModel()) 198 model->selectAudioMediaOption(index != NSNotFound ? index : UINT64_MAX); 197 199 } 198 200 … … 224 226 index = [_legibleTouchBarMediaSelectionOptions indexOfObject:legibleMediaSelectionOption]; 225 227 226 _playbackSessionInterfaceMac->playbackSessionModel()->selectLegibleMediaOption(index != NSNotFound ? index : UINT64_MAX); 228 if (auto* model = _playbackSessionInterfaceMac->playbackSessionModel()) 229 model->selectLegibleMediaOption(index != NSNotFound ? index : UINT64_MAX); 227 230 } 228 231
Note: See TracChangeset
for help on using the changeset viewer.