Bug 145806

Summary: Implement MediaSessionManager to keep track of all MediaSessions
Product: WebKit Reporter: Matt Rajca <mrajca>
Component: MediaAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, conrad_shultz, eric.carlson, jer.noble, mrajca, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 145411    
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Matt Rajca 2015-06-09 10:25:03 PDT
As described in the Media Session spec, MediaPlayPause events need to be handled by each Media Session, and we need a MediaSessionManager to keep track of them.
Comment 1 Radar WebKit Bug Importer 2015-06-09 10:26:27 PDT
<rdar://problem/21302849>
Comment 2 Matt Rajca 2015-06-09 10:40:09 PDT
Created attachment 254580 [details]
Patch
Comment 3 Darin Adler 2015-06-09 11:04:14 PDT
Comment on attachment 254580 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=254580&action=review

> Source/WebCore/Modules/mediasession/MediaSessionManager.cpp:49
> +    m_sessions.remove(m_sessions.find(&session));

Normally it’s not good to use remove/find. I’d suggest using a HashSet or ListHashSet for this collection instead of a vector.
Comment 4 Matt Rajca 2015-06-09 12:12:43 PDT
Created attachment 254585 [details]
Patch
Comment 5 Matt Rajca 2015-06-09 12:14:35 PDT
(In reply to comment #3)
> Comment on attachment 254580 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=254580&action=review
> 
> > Source/WebCore/Modules/mediasession/MediaSessionManager.cpp:49
> > +    m_sessions.remove(m_sessions.find(&session));
> 
> Normally it’s not good to use remove/find. I’d suggest using a HashSet or
> ListHashSet for this collection instead of a vector.

Settled on HashSet since we don't care about the ordering of MediaSessions. Thanks!
Comment 6 Eric Carlson 2015-06-09 13:53:24 PDT
Comment on attachment 254585 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=254585&action=review

> Source/WebCore/Modules/mediasession/MediaSessionManager.h:41
> +    const HashSet<MediaSession*>& sessions() const { return m_sessions; }

Is there any reason to not make this private?
Comment 7 Matt Rajca 2015-06-09 14:00:46 PDT
(In reply to comment #6)
> Comment on attachment 254585 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=254585&action=review
> 
> > Source/WebCore/Modules/mediasession/MediaSessionManager.h:41
> > +    const HashSet<MediaSession*>& sessions() const { return m_sessions; }
> 
> Is there any reason to not make this private?

I have other uncommitted code here locally that requires it to be public, but that is probably going to get refactored anyway. I'll remove the accessor for now.
Comment 8 Matt Rajca 2015-06-09 14:01:13 PDT
Created attachment 254599 [details]
Patch
Comment 9 WebKit Commit Bot 2015-06-09 15:57:36 PDT
Comment on attachment 254599 [details]
Patch

Clearing flags on attachment: 254599

Committed r185389: <http://trac.webkit.org/changeset/185389>
Comment 10 WebKit Commit Bot 2015-06-09 15:57:40 PDT
All reviewed patches have been landed.  Closing bug.