Changeset 257713 in webkit


Ignore:
Timestamp:
Mar 2, 2020 8:13:32 AM (4 years ago)
Author:
Jacob Uphoff
Message:

Unreviewed, rolling out r257687.

This commit caused debug tests to crash for macOS & iOS

Reverted changeset:

"[Cocoa] Mapping from MIME type to UTI type should be done in
the UI process"
https://bugs.webkit.org/show_bug.cgi?id=208415
https://trac.webkit.org/changeset/257687

Location:
trunk
Files:
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r257712 r257713  
     12020-03-02  Jacob Uphoff  <jacob_uphoff@apple.com>
     2
     3        Unreviewed, rolling out r257687.
     4
     5        This commit caused debug tests to crash for macOS & iOS
     6
     7        Reverted changeset:
     8
     9        "[Cocoa] Mapping from MIME type to UTI type should be done in
     10        the UI process"
     11        https://bugs.webkit.org/show_bug.cgi?id=208415
     12        https://trac.webkit.org/changeset/257687
     13
    1142020-03-02  Philippe Normand  <pnormand@igalia.com>
    215
  • trunk/Source/WebCore/platform/network/mac/UTIUtilities.h

    r257687 r257713  
    2424 */
    2525
    26 #pragma once
     26#ifndef UTIUtilities_h
     27#define UTIUtilities_h
    2728
    28 #include <wtf/text/WTFString.h>
     29#import <wtf/Forward.h>
     30#import <wtf/RetainPtr.h>
    2931
    3032namespace WebCore {
    31 
    3233WEBCORE_EXPORT String MIMETypeFromUTI(const String&);
    3334String MIMETypeFromUTITree(const String&);
    3435WEBCORE_EXPORT String UTIFromMIMEType(const String&);
    3536bool isDeclaredUTI(const String&);
     37}
    3638
    37 WEBCORE_EXPORT void setUTIFromMIMETypeMap(HashMap<String, String>&&);
    38 WEBCORE_EXPORT const HashMap<String, String>& createUTIFromMIMETypeMap();
    39 WEBCORE_EXPORT const Vector<String>& mimeTypes();
    40 }
     39#endif // UTIUtilities_h
  • trunk/Source/WebCore/platform/network/mac/UTIUtilities.mm

    r257687 r257713  
    4040#define ADDITIONAL_UTI_MAPPINGS
    4141#endif
    42 
    43 #define EMPTY_MIME_TYPE_STRING "emptyMimeType"_s
    4442
    4543namespace WebCore {
     
    116114}
    117115
    118 static Optional<HashMap<String, String>>& mapUTIFromMIMEType()
    119 {
    120     static NeverDestroyed<Optional<HashMap<String, String>>> map;
    121     return map;
    122 }
    123 
    124116struct UTIFromMIMETypeCachePolicy : TinyLRUCachePolicy<String, String> {
    125117public:
    126     static String createValueForKey(const String& mimeType)
     118    static String createValueForKey(const String& key)
    127119    {
    128         String key = mimeType;
    129         if (mapUTIFromMIMEType().hasValue()) {
    130             if (key.isEmpty())
    131                 key = EMPTY_MIME_TYPE_STRING;
    132             const auto& it = mapUTIFromMIMEType()->find(key);
    133             if (it != mapUTIFromMIMEType()->end())
    134                 return it->value;
    135             WTFLogAlways("UTI for MIME type %s not found.", key.utf8().data());
    136             ASSERT_NOT_REACHED();
    137         }
    138120        auto type = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, key.createCFString().get(), 0));
    139121        if (type)
     
    143125};
    144126
    145 static TinyLRUCache<String, String, 16, UTIFromMIMETypeCachePolicy>& cacheUTIFromMimeType()
    146 {
    147     static NeverDestroyed<TinyLRUCache<String, String, 16, UTIFromMIMETypeCachePolicy>> cache;
    148     return cache;
    149 }
    150 
    151127String UTIFromMIMEType(const String& mimeType)
    152128{
    153129    ASSERT(isMainThread());
    154     return cacheUTIFromMimeType().get(mimeType);
     130    static NeverDestroyed<TinyLRUCache<String, String, 16, UTIFromMIMETypeCachePolicy>> cache;
     131    return cache.get().get(mimeType);
    155132}
    156133
     
    160137}
    161138
    162 const Vector<String>& mimeTypes()
    163 {
    164     static NeverDestroyed<Vector<String>> mimeTypes = std::initializer_list<String> {
    165         "application/ogg"_s,
    166         "audio/ogg"_s,
    167         "video/ogg"_s,
    168         "application/annodex"_s,
    169         "audio/annodex"_s,
    170         "video/annodex"_s,
    171         "audio/speex"_s,
    172         "video/webm"_s,
    173         "audio/webm"_s,
    174         "audio/mpeg"_s,
    175         "video/mpeg"_s,
    176         "application/vnd.apple.mpegurl"_s,
    177         "application/mpegurl"_s,
    178         "application/x-mpegurl"_s,
    179         "audio/mpegurl"_s,
    180         "audio/x-mpegurl"_s,
    181         "audio/mpegurl"_s,
    182         "video/x-m4v"_s,
    183         "audio/x-m4a"_s,
    184         "audio/x-m4b"_s,
    185         "audio/x-m4p"_s,
    186         "audio/mp4"_s,
    187         "audio/mp3"_s,
    188         "audio/x-mp3"_s,
    189         "audio/x-mpeg"_s,
    190         "video/x-mpeg2"_s,
    191         "video/mpeg2"_s,
    192         "video/m2ts"_s,
    193         "video/x-m2ts"_s,
    194         "audio/3gpp"_s,
    195         "audio/3gpp2"_s,
    196         "application/x-mpeg"_s,
    197         "audio/aac"_s,
    198         "audio/x-aac"_s,
    199         "audio/x-caf"_s,
    200         "audio/x-gsm"_s,
    201         "audio/x-wav"_s,
    202         "audio/vnd.wave"_s,
    203     };
    204     return mimeTypes;
    205 };
    206 
    207 const HashMap<String, String>& createUTIFromMIMETypeMap()
    208 {
    209     static NeverDestroyed<HashMap<String, String>> map = [] {
    210         HashMap<String, String> cache;
    211         for (auto mimeType : mimeTypes())
    212             cache.add(mimeType, UTIFromMIMEType(mimeType));
    213         cache.add(EMPTY_MIME_TYPE_STRING, UTIFromMIMEType(emptyString()));
    214         return cache;
    215     }();
    216     return map;
    217139}
    218 
    219 void setUTIFromMIMETypeMap(HashMap<String, String>&& map)
    220 {
    221     mapUTIFromMIMEType() = WTFMove(map);
    222 }
    223 
    224 }
  • trunk/Source/WebCore/testing/Internals.cpp

    r257687 r257713  
    54755475    return emptyString();
    54765476}
    5477 
    5478 String Internals::getUTIFromMIMEType(const String& mimeType)
    5479 {
    5480     return emptyString();
    5481 }
    54825477#endif
    54835478
  • trunk/Source/WebCore/testing/Internals.h

    r257687 r257713  
    939939    String mediaMIMETypeForExtension(const String& extension);
    940940
    941     String getUTIFromMIMEType(const String& mimeType);
    942 
    943941    bool supportsPictureInPicture();
    944942
  • trunk/Source/WebCore/testing/Internals.idl

    r257687 r257713  
    847847
    848848    DOMString mediaMIMETypeForExtension(DOMString extension);
    849 
    850     DOMString getUTIFromMIMEType(DOMString mimeType);
    851 
     849   
    852850    boolean supportsPictureInPicture();
    853851};
  • trunk/Source/WebCore/testing/Internals.mm

    r257687 r257713  
    3535#import "MediaPlayerPrivate.h"
    3636#import "Range.h"
    37 #import "UTIUtilities.h"
    3837#import <AVFoundation/AVPlayer.h>
    3938#import <wtf/cocoa/NSURLExtras.h>
     
    102101}
    103102
    104 String Internals::getUTIFromMIMEType(const String& mimeType)
    105 {
    106     return UTIFromMIMEType(mimeType);
    107103}
    108 
    109 }
  • trunk/Source/WebKit/ChangeLog

    r257711 r257713  
     12020-03-02  Jacob Uphoff  <jacob_uphoff@apple.com>
     2
     3        Unreviewed, rolling out r257687.
     4
     5        This commit caused debug tests to crash for macOS & iOS
     6
     7        Reverted changeset:
     8
     9        "[Cocoa] Mapping from MIME type to UTI type should be done in
     10        the UI process"
     11        https://bugs.webkit.org/show_bug.cgi?id=208415
     12        https://trac.webkit.org/changeset/257687
     13
    1142020-03-02  Eric Carlson  <eric.carlson@apple.com>
    215
  • trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp

    r257687 r257713  
    172172    encoder << systemHasBattery;
    173173    encoder << mimeTypesMap;
    174     encoder << mapUTIFromMIMEType;
    175174#endif
    176175
     
    462461        return false;
    463462    parameters.mimeTypesMap = WTFMove(*mimeTypesMap);
    464 
    465     Optional<HashMap<String, String>> mapUTIFromMIMEType;
    466     decoder >> mapUTIFromMIMEType;
    467     if (!mapUTIFromMIMEType)
    468         return false;
    469     parameters.mapUTIFromMIMEType = WTFMove(*mapUTIFromMIMEType);
    470463#endif
    471464
  • trunk/Source/WebKit/Shared/WebProcessCreationParameters.h

    r257687 r257713  
    214214    bool systemHasBattery { false };
    215215    Optional<HashMap<String, Vector<String>, ASCIICaseInsensitiveHash>> mimeTypesMap;
    216     HashMap<String, String> mapUTIFromMIMEType;
    217216#endif
    218217
  • trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm

    r257687 r257713  
    5757#import <WebCore/RuntimeApplicationChecks.h>
    5858#import <WebCore/SharedBuffer.h>
    59 #import <WebCore/UTIUtilities.h>
    6059#import <objc/runtime.h>
    6160#import <pal/spi/cf/CFNetworkSPI.h>
     
    408407    }
    409408    parameters.systemHasBattery = systemHasBattery();
    410     parameters.mimeTypesMap = commonMimeTypesMap();
    411     parameters.mapUTIFromMIMEType = createUTIFromMIMETypeMap();
    412409#endif
    413410   
     
    418415        parameters.contentFilterExtensionHandle = WTFMove(handle);
    419416    }
     417    parameters.mimeTypesMap = commonMimeTypesMap();
    420418#endif
    421419   
  • trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

    r257687 r257713  
    6868#import <WebCore/RuntimeApplicationChecks.h>
    6969#import <WebCore/SWContextManager.h>
    70 #import <WebCore/UTIUtilities.h>
    7170#import <algorithm>
    7271#import <dispatch/dispatch.h>
     
    276275    if (parameters.mimeTypesMap)
    277276        overriddenMimeTypesMap() = WTFMove(parameters.mimeTypesMap);
    278 
    279     setUTIFromMIMETypeMap(WTFMove(parameters.mapUTIFromMIMEType));
    280277#endif
    281278
  • trunk/Tools/ChangeLog

    r257694 r257713  
     12020-03-02  Jacob Uphoff  <jacob_uphoff@apple.com>
     2
     3        Unreviewed, rolling out r257687.
     4
     5        This commit caused debug tests to crash for macOS & iOS
     6
     7        Reverted changeset:
     8
     9        "[Cocoa] Mapping from MIME type to UTI type should be done in
     10        the UI process"
     11        https://bugs.webkit.org/show_bug.cgi?id=208415
     12        https://trac.webkit.org/changeset/257687
     13
    1142020-03-01  Wenson Hsieh  <wenson_hsieh@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r257687 r257713  
    884884                C15CBB3F23FB177A00300CC7 /* PreferenceChanges.mm in Sources */ = {isa = PBXBuildFile; fileRef = C15CBB3E23FB177A00300CC7 /* PreferenceChanges.mm */; };
    885885                C1692DCA23D10DAE006E88F7 /* Battery.mm in Sources */ = {isa = PBXBuildFile; fileRef = C1692DC923D10DAE006E88F7 /* Battery.mm */; };
    886                 C194E31D2409DF43002939ED /* UTIFromMIMEType.mm in Sources */ = {isa = PBXBuildFile; fileRef = C194E31C2409DF43002939ED /* UTIFromMIMEType.mm */; };
    887886                C20F88A72295B96700D610FA /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C20F88A62295B96700D610FA /* CoreText.framework */; };
    888887                C22FA32B228F8708009D7988 /* TextWidth.mm in Sources */ = {isa = PBXBuildFile; fileRef = C22FA32A228F8708009D7988 /* TextWidth.mm */; };
     
    24502449                C15CBB3E23FB177A00300CC7 /* PreferenceChanges.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PreferenceChanges.mm; sourceTree = "<group>"; };
    24512450                C1692DC923D10DAE006E88F7 /* Battery.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = Battery.mm; sourceTree = "<group>"; };
    2452                 C194E31C2409DF43002939ED /* UTIFromMIMEType.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = UTIFromMIMEType.mm; sourceTree = "<group>"; };
    24532451                C1D8EE212028E8E3008EB141 /* WebProcessTerminate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessTerminate.mm; sourceTree = "<group>"; };
    24542452                C20F88A62295B96700D610FA /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; };
     
    29032901                                E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */,
    29042902                                C15CBB3E23FB177A00300CC7 /* PreferenceChanges.mm */,
    2905                                 C194E31C2409DF43002939ED /* UTIFromMIMEType.mm */,
    29062903                                0F139E751A423A5300F590F5 /* WeakObjCPtr.mm */,
    29072904                        );
     
    51005097                                7CCE7F181A411AE600447C4C /* UserMessage.cpp in Sources */,
    51015098                                2EB242B821D4140B0055C1C0 /* UseSelectionAsFindString.mm in Sources */,
    5102                                 C194E31D2409DF43002939ED /* UTIFromMIMEType.mm in Sources */,
    51035099                                7C83E03A1D0A602700FEBCF3 /* UtilitiesCocoa.mm in Sources */,
    51045100                                7C83E0C61D0A654E00FEBCF3 /* VideoControlsManager.mm in Sources */,
Note: See TracChangeset for help on using the changeset viewer.