Changeset 166101 in webkit
- Timestamp:
- Mar 21, 2014 3:21:29 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r166100 r166101 1 2014-03-21 Eric Carlson <eric.carlson@apple.com> 2 3 [iOS] remote command callbacks must happen on the WebThread 4 https://bugs.webkit.org/show_bug.cgi?id=130618 5 6 Reviewed by Jer Noble. 7 8 * platform/ios/RemoteCommandListenerIOS.h: 9 (WebCore::RemoteCommandListenerIOS::createWeakPtr): 10 * platform/ios/RemoteCommandListenerIOS.mm: 11 (WebCore::RemoteCommandListenerIOS::RemoteCommandListenerIOS): Dispatch commands to the 12 main thread before making listener callbacks. 13 1 14 2014-03-21 Zalan Bujtas <zalan@apple.com> 2 15 -
trunk/Source/WebCore/platform/ios/RemoteCommandListenerIOS.h
r165676 r166101 32 32 33 33 #include <wtf/RetainPtr.h> 34 #include <wtf/WeakPtr.h> 34 35 35 36 #ifndef __OBJC__ … … 45 46 46 47 protected: 48 WeakPtr<RemoteCommandListenerIOS> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); } 49 50 WeakPtrFactory<RemoteCommandListenerIOS> m_weakPtrFactory; 47 51 RetainPtr<id> m_playTarget; 48 52 RetainPtr<id> m_pauseTarget; -
trunk/Source/WebCore/platform/ios/RemoteCommandListenerIOS.mm
r165676 r166101 47 47 RemoteCommandListenerIOS::RemoteCommandListenerIOS(RemoteCommandListenerClient& client) 48 48 : RemoteCommandListener(client) 49 , m_weakPtrFactory(this) 49 50 { 50 51 MPRemoteCommandCenter *center = [getMPRemoteCommandCenterClass() sharedCommandCenter]; 52 auto weakThis = createWeakPtr(); 53 54 m_pauseTarget = [[center pauseCommand] addTargetWithHandler:^(MPRemoteCommandEvent *) { 55 callOnMainThread([weakThis] { 56 if (!weakThis) 57 return; 58 weakThis->m_client.didReceiveRemoteControlCommand(MediaSession::PauseCommand); 59 }); 51 60 52 m_pauseTarget = [[center pauseCommand] addTargetWithHandler:^(MPRemoteCommandEvent *) {53 m_client.didReceiveRemoteControlCommand(MediaSession::PauseCommand);54 61 return MPRemoteCommandHandlerStatusSuccess; 55 62 }]; 63 56 64 m_playTarget = [[center playCommand] addTargetWithHandler:^(MPRemoteCommandEvent *) { 57 m_client.didReceiveRemoteControlCommand(MediaSession::PlayCommand); 65 callOnMainThread([weakThis] { 66 if (!weakThis) 67 return; 68 weakThis->m_client.didReceiveRemoteControlCommand(MediaSession::PlayCommand); 69 }); 70 58 71 return MPRemoteCommandHandlerStatusSuccess; 59 72 }]; 73 60 74 m_togglePlayPauseTarget = [[center togglePlayPauseCommand] addTargetWithHandler:^(MPRemoteCommandEvent *) { 61 m_client.didReceiveRemoteControlCommand(MediaSession::TogglePlayPauseCommand); 75 callOnMainThread([weakThis] { 76 if (!weakThis) 77 return; 78 weakThis->m_client.didReceiveRemoteControlCommand(MediaSession::TogglePlayPauseCommand); 79 }); 80 62 81 return MPRemoteCommandHandlerStatusSuccess; 63 82 }]; 83 64 84 m_seekBackwardTarget = [[center seekBackwardCommand] addTargetWithHandler:^(MPRemoteCommandEvent *event) { 65 85 ASSERT([event isKindOfClass:getMPSeekCommandEventClass()]); 86 66 87 MPSeekCommandEvent* seekEvent = static_cast<MPSeekCommandEvent *>(event); 67 m_client.didReceiveRemoteControlCommand([seekEvent type] == MPSeekCommandEventTypeBeginSeeking ? MediaSession::BeginSeekingBackwardCommand : MediaSession::EndSeekingBackwardCommand); 88 MediaSession::RemoteControlCommandType command = [seekEvent type] == MPSeekCommandEventTypeBeginSeeking ? MediaSession::BeginSeekingBackwardCommand : MediaSession::EndSeekingBackwardCommand; 89 90 callOnMainThread([weakThis, command] { 91 if (!weakThis) 92 return; 93 weakThis->m_client.didReceiveRemoteControlCommand(command); 94 }); 95 68 96 return MPRemoteCommandHandlerStatusSuccess; 69 97 }]; 98 70 99 m_seekForwardTarget = [[center seekForwardCommand] addTargetWithHandler:^(MPRemoteCommandEvent *event) { 71 100 ASSERT([event isKindOfClass:getMPSeekCommandEventClass()]); 72 101 MPSeekCommandEvent* seekEvent = static_cast<MPSeekCommandEvent *>(event); 73 m_client.didReceiveRemoteControlCommand([seekEvent type] == MPSeekCommandEventTypeBeginSeeking ? MediaSession::BeginSeekingForwardCommand : MediaSession::EndSeekingForwardCommand); 102 103 MediaSession::RemoteControlCommandType command = [seekEvent type] == MPSeekCommandEventTypeBeginSeeking ? MediaSession::BeginSeekingForwardCommand : MediaSession::EndSeekingForwardCommand; 104 105 callOnMainThread([weakThis, command] { 106 if (!weakThis) 107 return; 108 weakThis->m_client.didReceiveRemoteControlCommand(command); 109 }); 110 74 111 return MPRemoteCommandHandlerStatusSuccess; 75 112 }];
Note: See TracChangeset
for help on using the changeset viewer.