Bug 146660

Summary: Media Session: propagate metadata changes to UI clients
Product: WebKit Reporter: Matt Rajca <mrajca>
Component: MediaAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: conrad_shultz, eric.carlson, mrajca, thorton, 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
Patch thorton: review+

Description Matt Rajca 2015-07-06 16:24:13 PDT
We need to give UI clients a chance to handle media metadata changes.
Comment 1 Radar WebKit Bug Importer 2015-07-06 16:25:01 PDT
<rdar://problem/21694290>
Comment 2 Matt Rajca 2015-07-06 16:46:34 PDT
Created attachment 256255 [details]
Patch
Comment 3 Matt Rajca 2015-07-06 16:50:56 PDT
Created attachment 256258 [details]
Patch
Comment 4 Eric Carlson 2015-07-07 06:39:28 PDT
Comment on attachment 256258 [details]
Patch

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

> Source/WebKit2/Shared/WebMediaSessionMetadata.cpp:38
> +PassRefPtr<WebMediaSessionMetadata> WebMediaSessionMetadata::create(const MediaSessionMetadata& metadata)
> +{
> +    return adoptRef(new WebMediaSessionMetadata(metadata));
> +}

The return type should be Ref<WebMediaSessionMetadata>, not PassRefPtr<WebMediaSessionMetadata>. See http://www.webkit.org/coding/RefPtr.html.
Comment 5 Matt Rajca 2015-07-07 10:25:43 PDT
Created attachment 256308 [details]
Patch
Comment 6 Matt Rajca 2015-07-07 10:26:07 PDT
(In reply to comment #4)
> Comment on attachment 256258 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=256258&action=review
> 
> > Source/WebKit2/Shared/WebMediaSessionMetadata.cpp:38
> > +PassRefPtr<WebMediaSessionMetadata> WebMediaSessionMetadata::create(const MediaSessionMetadata& metadata)
> > +{
> > +    return adoptRef(new WebMediaSessionMetadata(metadata));
> > +}
> 
> The return type should be Ref<WebMediaSessionMetadata>, not
> PassRefPtr<WebMediaSessionMetadata>. See
> http://www.webkit.org/coding/RefPtr.html.

Fixed.
Comment 7 Tim Horton 2015-07-07 11:27:42 PDT
Comment on attachment 256308 [details]
Patch

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

> Source/WebKit2/UIProcess/API/APIUIClient.h:61
> +#if ENABLE(MEDIA_SESSION)

no need to guard this forward-declaration (but it's fine either way)

> Source/WebKit2/UIProcess/API/C/WKAPICast.h:112
> +#if ENABLE(MEDIA_SESSION)

ditto

> Source/WebKit2/UIProcess/API/C/WKAPICast.h:171
> +WK_ADD_API_MAPPING(WKMediaSessionMetadataRef, WebMediaSessionMetadata)

Why is this mapping #if'd out if WKMediaSessionMetadata has all the functions but the contents of said functions are if'd out? Which way are you disabling this?
Comment 8 Matt Rajca 2015-07-07 13:21:18 PDT
(In reply to comment #7)
> Comment on attachment 256308 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=256308&action=review
> 
> > Source/WebKit2/UIProcess/API/APIUIClient.h:61
> > +#if ENABLE(MEDIA_SESSION)
> 
> no need to guard this forward-declaration (but it's fine either way)

I think I'll leave it in.

> 
> > Source/WebKit2/UIProcess/API/C/WKAPICast.h:112
> > +#if ENABLE(MEDIA_SESSION)
> 
> ditto
> 
> > Source/WebKit2/UIProcess/API/C/WKAPICast.h:171
> > +WK_ADD_API_MAPPING(WKMediaSessionMetadataRef, WebMediaSessionMetadata)
> 
> Why is this mapping #if'd out if WKMediaSessionMetadata has all the
> functions but the contents of said functions are if'd out? Which way are you
> disabling this?

The contents of the functions have to be #if'd out since it doesn't seem like we can use #if ENABLE in those header files. I can remove the #if guards around the mapping.
Comment 9 Matt Rajca 2015-07-07 13:24:12 PDT
Created attachment 256318 [details]
Patch
Comment 10 Tim Horton 2015-07-07 13:45:57 PDT
(In reply to comment #8)
> (In reply to comment #7)
> > Comment on attachment 256308 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=256308&action=review
> > 
> > > Source/WebKit2/UIProcess/API/APIUIClient.h:61
> > > +#if ENABLE(MEDIA_SESSION)
> > 
> > no need to guard this forward-declaration (but it's fine either way)
> 
> I think I'll leave it in.

That's fine! I only noted this because Darin has previously called this practice "overkill" (see https://bugs.webkit.org/show_bug.cgi?id=134461#c6).

> > Why is this mapping #if'd out if WKMediaSessionMetadata has all the
> > functions but the contents of said functions are if'd out? Which way are you
> > disabling this?
> 
> The contents of the functions have to be #if'd out since it doesn't seem
> like we can use #if ENABLE in those header files. I can remove the #if
> guards around the mapping.

That's what I was hoping you'd do :)
Comment 11 Tim Horton 2015-07-07 13:49:56 PDT
Comment on attachment 256318 [details]
Patch

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

> Source/WebKit2/UIProcess/API/C/WKMediaSessionMetadata.cpp:49
> +    return 0;

These should be nullptr, not 0, I think?

> Source/WebKit2/UIProcess/API/C/WKPageUIClient.h:456
> +    WKPageMediaSessionMetadataDidChangeCallback                         mediaSessionMetadataDidChange;

Please make sure that it's OK to add this without bumping the version number and that you do everything necessary to not break internal builds because of it.
Comment 12 Matt Rajca 2015-07-07 14:13:30 PDT
(In reply to comment #11)
> Comment on attachment 256318 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=256318&action=review
> 
> > Source/WebKit2/UIProcess/API/C/WKMediaSessionMetadata.cpp:49
> > +    return 0;
> 
> These should be nullptr, not 0, I think?

Fixed. Not sure why we were using 0 in other WK* sources.

> 
> > Source/WebKit2/UIProcess/API/C/WKPageUIClient.h:456
> > +    WKPageMediaSessionMetadataDidChangeCallback                         mediaSessionMetadataDidChange;
> 
> Please make sure that it's OK to add this without bumping the version number
> and that you do everything necessary to not break internal builds because of
> it.

I'll watch the bots. Looks like Brady added a few callbacks last month and things were okay.
Comment 13 Matt Rajca 2015-07-07 16:55:05 PDT
Committed r186484: <http://trac.webkit.org/changeset/186484>