Fix leaks in WebAVMediaSelectionOptionMac and WebPlaybackControlsManager
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Apr 2016 18:32:19 +0000 (18:32 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Apr 2016 18:32:19 +0000 (18:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=156379

Reviewed by Tim Horton.

These classes should use RetainPtrs.
* platform/mac/WebVideoFullscreenInterfaceMac.mm:
(-[WebAVMediaSelectionOptionMac localizedDisplayName]):
(-[WebAVMediaSelectionOptionMac setLocalizedDisplayName:]):
(-[WebPlaybackControlsManager timing]):
(-[WebPlaybackControlsManager setTiming:]):
(-[WebPlaybackControlsManager seekableTimeRanges]):
(-[WebPlaybackControlsManager setSeekableTimeRanges:]):
(-[WebPlaybackControlsManager audioMediaSelectionOptions]):
(-[WebPlaybackControlsManager setAudioMediaSelectionOptions:]):
(-[WebPlaybackControlsManager currentAudioMediaSelectionOption]):
(-[WebPlaybackControlsManager setCurrentAudioMediaSelectionOption:]):
(-[WebPlaybackControlsManager legibleMediaSelectionOptions]):
(-[WebPlaybackControlsManager setLegibleMediaSelectionOptions:]):
(-[WebPlaybackControlsManager currentLegibleMediaSelectionOption]):
(-[WebPlaybackControlsManager setCurrentLegibleMediaSelectionOption:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199238 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm

index ef17aaf..4299e72 100644 (file)
@@ -1,3 +1,27 @@
+2016-04-08  Beth Dakin  <bdakin@apple.com>
+
+        Fix leaks in WebAVMediaSelectionOptionMac and WebPlaybackControlsManager
+        https://bugs.webkit.org/show_bug.cgi?id=156379
+
+        Reviewed by Tim Horton.
+
+        These classes should use RetainPtrs.
+        * platform/mac/WebVideoFullscreenInterfaceMac.mm:
+        (-[WebAVMediaSelectionOptionMac localizedDisplayName]):
+        (-[WebAVMediaSelectionOptionMac setLocalizedDisplayName:]):
+        (-[WebPlaybackControlsManager timing]):
+        (-[WebPlaybackControlsManager setTiming:]):
+        (-[WebPlaybackControlsManager seekableTimeRanges]):
+        (-[WebPlaybackControlsManager setSeekableTimeRanges:]):
+        (-[WebPlaybackControlsManager audioMediaSelectionOptions]):
+        (-[WebPlaybackControlsManager setAudioMediaSelectionOptions:]):
+        (-[WebPlaybackControlsManager currentAudioMediaSelectionOption]):
+        (-[WebPlaybackControlsManager setCurrentAudioMediaSelectionOption:]):
+        (-[WebPlaybackControlsManager legibleMediaSelectionOptions]):
+        (-[WebPlaybackControlsManager setLegibleMediaSelectionOptions:]):
+        (-[WebPlaybackControlsManager currentLegibleMediaSelectionOption]):
+        (-[WebPlaybackControlsManager setCurrentLegibleMediaSelectionOption:]):
+
 2016-04-08  Fujii Hironori  <Hironori.Fujii@jp.sony.com>
 
         Touching any IDL files rebuilds all bindings in CMake Ninja build
index 4359458..f66acfb 100644 (file)
@@ -49,26 +49,36 @@ SOFT_LINK_CLASS(AVKit, AVValueTiming)
 using namespace WebCore;
 
 @interface WebAVMediaSelectionOptionMac : NSObject {
-    NSString *_localizedDisplayName;
+    RetainPtr<NSString> _localizedDisplayName;
 }
 @property (retain) NSString *localizedDisplayName;
 @end
 
 @implementation WebAVMediaSelectionOptionMac
-@synthesize localizedDisplayName=_localizedDisplayName;
+
+- (NSString *)localizedDisplayName
+{
+    return _localizedDisplayName.get();
+}
+
+- (void)setLocalizedDisplayName:(NSString *)name
+{
+    _localizedDisplayName = name;
+}
+
 @end
 
 @interface WebPlaybackControlsManager : NSObject {
     NSTimeInterval _contentDuration;
-    AVValueTiming *_timing;
+    RetainPtr<AVValueTiming> _timing;
     NSTimeInterval _seekToTime;
-    NSArray *_seekableTimeRanges;
+    RetainPtr<NSArray> _seekableTimeRanges;
     BOOL _hasEnabledAudio;
     BOOL _hasEnabledVideo;
-    NSArray<AVMediaSelectionOption *> *_audioMediaSelectionOptions;
-    AVMediaSelectionOption *_currentAudioMediaSelectionOption;
-    NSArray<AVMediaSelectionOption *> *_legibleMediaSelectionOptions;
-    AVMediaSelectionOption *_currentLegibleMediaSelectionOption;
+    RetainPtr<NSArray<AVMediaSelectionOption *>> _audioMediaSelectionOptions;
+    RetainPtr<AVMediaSelectionOption> _currentAudioMediaSelectionOption;
+    RetainPtr<NSArray<AVMediaSelectionOption *>> _legibleMediaSelectionOptions;
+    RetainPtr<AVMediaSelectionOption> _currentLegibleMediaSelectionOption;
     
     float _rate;
 
@@ -100,16 +110,10 @@ using namespace WebCore;
 @implementation WebPlaybackControlsManager
 
 @synthesize contentDuration=_contentDuration;
-@synthesize timing=_timing;
 @synthesize seekToTime=_seekToTime;
-@synthesize seekableTimeRanges=_seekableTimeRanges;
 @synthesize hasEnabledAudio=_hasEnabledAudio;
 @synthesize hasEnabledVideo=_hasEnabledVideo;
 @synthesize rate=_rate;
-@synthesize audioMediaSelectionOptions=_audioMediaSelectionOptions;
-@synthesize currentAudioMediaSelectionOption=_currentAudioMediaSelectionOption;
-@synthesize legibleMediaSelectionOptions=_legibleMediaSelectionOptions;
-@synthesize currentLegibleMediaSelectionOption=_currentLegibleMediaSelectionOption;
 
 - (instancetype)initWithWebVideoFullscreenInterfaceMac:(WebCore::WebVideoFullscreenInterfaceMac*)webVideoFullscreenInterfaceMac
 {
@@ -121,6 +125,26 @@ using namespace WebCore;
     return self;
 }
 
+- (AVValueTiming *)timing
+{
+    return _timing.get();
+}
+
+- (void)setTiming:(AVValueTiming *)timing
+{
+    _timing = timing;
+}
+
+- (NSArray *)seekableTimeRanges
+{
+    return _seekableTimeRanges.get();
+}
+
+- (void)setSeekableTimeRanges:(NSArray *)timeRanges
+{
+    _seekableTimeRanges = timeRanges;
+}
+
 - (BOOL)isSeeking
 {
     return NO;
@@ -133,6 +157,21 @@ using namespace WebCore;
     _webVideoFullscreenInterfaceMac->webVideoFullscreenModel()->seekToTime(time);
 }
 
+- (NSArray<AVMediaSelectionOption *> *)audioMediaSelectionOptions
+{
+    return _audioMediaSelectionOptions.get();
+}
+
+- (void)setAudioMediaSelectionOptions:(NSArray<AVMediaSelectionOption *> *)audioOptions
+{
+    _audioMediaSelectionOptions = audioOptions;
+}
+
+- (AVMediaSelectionOption *)currentAudioMediaSelectionOption
+{
+    return _currentAudioMediaSelectionOption.get();
+}
+
 - (void)setCurrentAudioMediaSelectionOption:(AVMediaSelectionOption *)audioMediaSelectionOption
 {
     if (audioMediaSelectionOption == _currentAudioMediaSelectionOption)
@@ -148,6 +187,21 @@ using namespace WebCore;
     _webVideoFullscreenInterfaceMac->webVideoFullscreenModel()->selectAudioMediaOption(index != NSNotFound ? index : UINT64_MAX);
 }
 
+- (NSArray<AVMediaSelectionOption *> *)legibleMediaSelectionOptions
+{
+    return _legibleMediaSelectionOptions.get();
+}
+
+- (void)setLegibleMediaSelectionOptions:(NSArray<AVMediaSelectionOption *> *)legibleOptions
+{
+    _legibleMediaSelectionOptions = legibleOptions;
+}
+
+- (AVMediaSelectionOption *)currentLegibleMediaSelectionOption
+{
+    return _currentLegibleMediaSelectionOption.get();
+}
+
 - (void)setCurrentLegibleMediaSelectionOption:(AVMediaSelectionOption *)legibleMediaSelectionOption
 {
     if (legibleMediaSelectionOption == _currentLegibleMediaSelectionOption)