Bug 127003

Summary: MediaSessionManager shouldn't use std::map
Product: WebKit Reporter: Eric Carlson <eric.carlson>
Component: MediaAssignee: Eric Carlson <eric.carlson>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, glenn, jer.noble, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Proposed patch
sam: review-
Another patch. none

Description Eric Carlson 2014-01-14 13:26:27 PST
Just don't do it!
Comment 1 Eric Carlson 2014-01-14 13:30:01 PST
Created attachment 221195 [details]
Proposed patch
Comment 2 Sam Weinig 2014-01-14 18:01:08 PST
Comment on attachment 221195 [details]
Proposed patch

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

> Source/WebCore/platform/audio/MediaSessionManager.h:71
> +    typedef HashMap<MediaSession::MediaType, SessionRestrictions, WTF::IntHash<unsigned>, WTF::HashTraits<unsigned>> RestrictionsMap;

I think you can actually do much better than a HashMap.  How about something like an array of SessionRestrictions of size == LagestValueOfMediaType + 1:

SessionRestrictions[WebAudio + 1];

But, if you use the HashMap, you need to use traits that allow for a 0 value key (e.g. UnsignedWithZeroKeyHashTraits).
Comment 3 Eric Carlson 2014-01-15 17:21:00 PST
Created attachment 221320 [details]
Another patch.
Comment 4 Sam Weinig 2014-01-15 18:51:57 PST
Comment on attachment 221320 [details]
Another patch.

Nice.
Comment 5 Eric Carlson 2014-01-15 19:09:51 PST
(In reply to comment #4)
> (From update of attachment 221320 [details])
> Nice.

Thanks for the suggestion, my first and second versions were definitely over engineered :-)
Comment 6 WebKit Commit Bot 2014-01-15 19:36:19 PST
Comment on attachment 221320 [details]
Another patch.

Clearing flags on attachment: 221320

Committed r162108: <http://trac.webkit.org/changeset/162108>
Comment 7 WebKit Commit Bot 2014-01-15 19:36:22 PST
All reviewed patches have been landed.  Closing bug.