Bug 188314 - Add LogArgument template for PlatformMediaSession::RemoteControlCommandType
Summary: Add LogArgument template for PlatformMediaSession::RemoteControlCommandType
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Eric Carlson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-08-03 10:55 PDT by Eric Carlson
Modified: 2018-08-08 11:11 PDT (History)
4 users (show)

See Also:


Attachments
Patch (6.14 KB, patch)
2018-08-03 10:58 PDT, Eric Carlson
achristensen: review-
achristensen: commit-queue-
Details | Formatted Diff | Diff
Patch for landing (9.60 KB, patch)
2018-08-08 10:30 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Carlson 2018-08-03 10:55:38 PDT
Log PlatformMediaSession::RemoteControlCommandType as a readable string.
Comment 1 Radar WebKit Bug Importer 2018-08-03 10:58:12 PDT
<rdar://problem/42906364>
Comment 2 Eric Carlson 2018-08-03 10:58:27 PDT
Created attachment 346505 [details]
Patch
Comment 3 Alex Christensen 2018-08-07 11:50:59 PDT
Comment on attachment 346505 [details]
Patch

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

> Source/WebCore/platform/audio/PlatformMediaSession.cpp:102
> +    static_assert(static_cast<size_t>(PlatformMediaSession::PlayCommand == 1), "PlatformMediaSession::PlayCommand is not 1 as expected");

Why do you need to convert the booleans into size_t's?

> Source/WebCore/platform/audio/PlatformMediaSession.cpp:112
> +    ASSERT(static_cast<size_t>(command) < WTF_ARRAY_LENGTH(values));
> +    return values[static_cast<size_t>(command)];

I think a switch statement would be more appropriate here.  It would allow the compiler to give you an error if you're missing a case if you don't have a default.
Comment 4 Eric Carlson 2018-08-07 13:07:52 PDT
Comment on attachment 346505 [details]
Patch

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

>> Source/WebCore/platform/audio/PlatformMediaSession.cpp:102
>> +    static_assert(static_cast<size_t>(PlatformMediaSession::PlayCommand == 1), "PlatformMediaSession::PlayCommand is not 1 as expected");
> 
> Why do you need to convert the booleans into size_t's?

It doesn't convert boolean to size_t, it converts an enum to a size_t so it can be compared to an integer. 

I just copied the style of the convertEnumerationToString() generated for all enums in IDL.

>> Source/WebCore/platform/audio/PlatformMediaSession.cpp:112
>> +    return values[static_cast<size_t>(command)];
> 
> I think a switch statement would be more appropriate here.  It would allow the compiler to give you an error if you're missing a case if you don't have a default.

Is there a plan to do that for the 250 enums defined in IDL?
Comment 5 Alex Christensen 2018-08-07 13:10:42 PDT
Comment on attachment 346505 [details]
Patch

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

>>> Source/WebCore/platform/audio/PlatformMediaSession.cpp:102
>>> +    static_assert(static_cast<size_t>(PlatformMediaSession::PlayCommand == 1), "PlatformMediaSession::PlayCommand is not 1 as expected");
>> 
>> Why do you need to convert the booleans into size_t's?
> 
> It doesn't convert boolean to size_t, it converts an enum to a size_t so it can be compared to an integer. 
> 
> I just copied the style of the convertEnumerationToString() generated for all enums in IDL.

I see that now, but you put the parentheses in the wrong place.
Comment 6 Eric Carlson 2018-08-08 10:30:32 PDT
Created attachment 346774 [details]
Patch for landing
Comment 7 WebKit Commit Bot 2018-08-08 11:11:06 PDT
Comment on attachment 346774 [details]
Patch for landing

Clearing flags on attachment: 346774

Committed r234703: <https://trac.webkit.org/changeset/234703>
Comment 8 WebKit Commit Bot 2018-08-08 11:11:07 PDT
All reviewed patches have been landed.  Closing bug.