Changeset 255119 in webkit
- Timestamp:
- Jan 25, 2020 8:51:34 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r255118 r255119 1 2020-01-25 Per Arne Vollan <pvollan@apple.com> 2 3 [Cocoa] Media mime types map should be created in the UI process 4 https://bugs.webkit.org/show_bug.cgi?id=206478 5 6 Reviewed by Darin Adler. 7 8 Creating this map in the WebContent process will access the launch services daemon, which will be blocked. 9 This patch creates the map in the UI process and sends it to the WebContent process as part of the WebProcess 10 creation parameters. 11 12 API test: WebKit.MimeTypes 13 14 * platform/MIMETypeRegistry.cpp: 15 (WebCore::overriddenMimeTypesMap): 16 (WebCore::commonMediaTypes): 17 (WebCore::commonMimeTypesMap): 18 (WebCore::typesForCommonExtension): 19 * platform/MIMETypeRegistry.h: 20 * testing/Internals.cpp: 21 (WebCore::Internals::mediaMIMETypeForExtension): 22 * testing/Internals.h: 23 * testing/Internals.idl: 24 1 25 2020-01-25 Zalan Bujtas <zalan@apple.com> 2 26 -
trunk/Source/WebCore/platform/MIMETypeRegistry.cpp
r255081 r255119 275 275 } 276 276 277 static const Vector<String>* typesForCommonExtension(const String& extension) 278 { 279 static const auto map = makeNeverDestroyed([] { 280 struct TypeExtensionPair { 281 ASCIILiteral type; 282 ASCIILiteral extension; 283 }; 284 285 // A table of common media MIME types and file extentions used when a platform's 286 // specific MIME type lookup doesn't have a match for a media file extension. 287 static const TypeExtensionPair commonMediaTypes[] = { 288 // Ogg 289 { "application/ogg"_s, "ogx"_s }, 290 { "audio/ogg"_s, "ogg"_s }, 291 { "audio/ogg"_s, "oga"_s }, 292 { "video/ogg"_s, "ogv"_s }, 293 294 // Annodex 295 { "application/annodex"_s, "anx"_s }, 296 { "audio/annodex"_s, "axa"_s }, 297 { "video/annodex"_s, "axv"_s }, 298 { "audio/speex"_s, "spx"_s }, 299 300 // WebM 301 { "video/webm"_s, "webm"_s }, 302 { "audio/webm"_s, "webm"_s }, 303 304 // MPEG 305 { "audio/mpeg"_s, "m1a"_s }, 306 { "audio/mpeg"_s, "m2a"_s }, 307 { "audio/mpeg"_s, "m1s"_s }, 308 { "audio/mpeg"_s, "mpa"_s }, 309 { "video/mpeg"_s, "mpg"_s }, 310 { "video/mpeg"_s, "m15"_s }, 311 { "video/mpeg"_s, "m1s"_s }, 312 { "video/mpeg"_s, "m1v"_s }, 313 { "video/mpeg"_s, "m75"_s }, 314 { "video/mpeg"_s, "mpa"_s }, 315 { "video/mpeg"_s, "mpeg"_s }, 316 { "video/mpeg"_s, "mpm"_s }, 317 { "video/mpeg"_s, "mpv"_s }, 318 319 // MPEG playlist 320 { "application/vnd.apple.mpegurl"_s, "m3u8"_s }, 321 { "application/mpegurl"_s, "m3u8"_s }, 322 { "application/x-mpegurl"_s, "m3u8"_s }, 323 { "audio/mpegurl"_s, "m3url"_s }, 324 { "audio/x-mpegurl"_s, "m3url"_s }, 325 { "audio/mpegurl"_s, "m3u"_s }, 326 { "audio/x-mpegurl"_s, "m3u"_s }, 327 328 // MPEG-4 329 { "video/x-m4v"_s, "m4v"_s }, 330 { "audio/x-m4a"_s, "m4a"_s }, 331 { "audio/x-m4b"_s, "m4b"_s }, 332 { "audio/x-m4p"_s, "m4p"_s }, 333 { "audio/mp4"_s, "m4a"_s }, 334 335 // MP3 336 { "audio/mp3"_s, "mp3"_s }, 337 { "audio/x-mp3"_s, "mp3"_s }, 338 { "audio/x-mpeg"_s, "mp3"_s }, 339 340 // MPEG-2 341 { "video/x-mpeg2"_s, "mp2"_s }, 342 { "video/mpeg2"_s, "vob"_s }, 343 { "video/mpeg2"_s, "mod"_s }, 344 { "video/m2ts"_s, "m2ts"_s }, 345 { "video/x-m2ts"_s, "m2t"_s }, 346 { "video/x-m2ts"_s, "ts"_s }, 347 348 // 3GP/3GP2 349 { "audio/3gpp"_s, "3gpp"_s }, 350 { "audio/3gpp2"_s, "3g2"_s }, 351 { "application/x-mpeg"_s, "amc"_s }, 352 353 // AAC 354 { "audio/aac"_s, "aac"_s }, 355 { "audio/aac"_s, "adts"_s }, 356 { "audio/x-aac"_s, "m4r"_s }, 357 358 // CoreAudio File 359 { "audio/x-caf"_s, "caf"_s }, 360 { "audio/x-gsm"_s, "gsm"_s }, 361 362 // ADPCM 363 { "audio/x-wav"_s, "wav"_s }, 364 { "audio/vnd.wave"_s, "wav"_s }, 365 }; 366 277 Optional<HashMap<String, Vector<String>, ASCIICaseInsensitiveHash>>& overriddenMimeTypesMap() 278 { 279 static NeverDestroyed<Optional<HashMap<String, Vector<String>, ASCIICaseInsensitiveHash>>> map; 280 return map; 281 } 282 283 const std::initializer_list<TypeExtensionPair>& commonMediaTypes() 284 { 285 // A table of common media MIME types and file extensions used when a platform's 286 // specific MIME type lookup doesn't have a match for a media file extension. 287 static std::initializer_list<TypeExtensionPair> commonMediaTypes = { 288 // Ogg 289 { "application/ogg"_s, "ogx"_s }, 290 { "audio/ogg"_s, "ogg"_s }, 291 { "audio/ogg"_s, "oga"_s }, 292 { "video/ogg"_s, "ogv"_s }, 293 294 // Annodex 295 { "application/annodex"_s, "anx"_s }, 296 { "audio/annodex"_s, "axa"_s }, 297 { "video/annodex"_s, "axv"_s }, 298 { "audio/speex"_s, "spx"_s }, 299 300 // WebM 301 { "video/webm"_s, "webm"_s }, 302 { "audio/webm"_s, "webm"_s }, 303 304 // MPEG 305 { "audio/mpeg"_s, "m1a"_s }, 306 { "audio/mpeg"_s, "m2a"_s }, 307 { "audio/mpeg"_s, "m1s"_s }, 308 { "audio/mpeg"_s, "mpa"_s }, 309 { "video/mpeg"_s, "mpg"_s }, 310 { "video/mpeg"_s, "m15"_s }, 311 { "video/mpeg"_s, "m1s"_s }, 312 { "video/mpeg"_s, "m1v"_s }, 313 { "video/mpeg"_s, "m75"_s }, 314 { "video/mpeg"_s, "mpa"_s }, 315 { "video/mpeg"_s, "mpeg"_s }, 316 { "video/mpeg"_s, "mpm"_s }, 317 { "video/mpeg"_s, "mpv"_s }, 318 319 // MPEG playlist 320 { "application/vnd.apple.mpegurl"_s, "m3u8"_s }, 321 { "application/mpegurl"_s, "m3u8"_s }, 322 { "application/x-mpegurl"_s, "m3u8"_s }, 323 { "audio/mpegurl"_s, "m3url"_s }, 324 { "audio/x-mpegurl"_s, "m3url"_s }, 325 { "audio/mpegurl"_s, "m3u"_s }, 326 { "audio/x-mpegurl"_s, "m3u"_s }, 327 328 // MPEG-4 329 { "video/x-m4v"_s, "m4v"_s }, 330 { "audio/x-m4a"_s, "m4a"_s }, 331 { "audio/x-m4b"_s, "m4b"_s }, 332 { "audio/x-m4p"_s, "m4p"_s }, 333 { "audio/mp4"_s, "m4a"_s }, 334 335 // MP3 336 { "audio/mp3"_s, "mp3"_s }, 337 { "audio/x-mp3"_s, "mp3"_s }, 338 { "audio/x-mpeg"_s, "mp3"_s }, 339 340 // MPEG-2 341 { "video/x-mpeg2"_s, "mp2"_s }, 342 { "video/mpeg2"_s, "vob"_s }, 343 { "video/mpeg2"_s, "mod"_s }, 344 { "video/m2ts"_s, "m2ts"_s }, 345 { "video/x-m2ts"_s, "m2t"_s }, 346 { "video/x-m2ts"_s, "ts"_s }, 347 348 // 3GP/3GP2 349 { "audio/3gpp"_s, "3gpp"_s }, 350 { "audio/3gpp2"_s, "3g2"_s }, 351 { "application/x-mpeg"_s, "amc"_s }, 352 353 // AAC 354 { "audio/aac"_s, "aac"_s }, 355 { "audio/aac"_s, "adts"_s }, 356 { "audio/x-aac"_s, "m4r"_s }, 357 358 // CoreAudio File 359 { "audio/x-caf"_s, "caf"_s }, 360 { "audio/x-gsm"_s, "gsm"_s }, 361 362 // ADPCM 363 { "audio/x-wav"_s, "wav"_s }, 364 { "audio/vnd.wave"_s, "wav"_s }, 365 }; 366 return commonMediaTypes; 367 } 368 369 const HashMap<String, Vector<String>, ASCIICaseInsensitiveHash>& commonMimeTypesMap() 370 { 371 ASSERT(isMainThread()); 372 static NeverDestroyed<HashMap<String, Vector<String>, ASCIICaseInsensitiveHash>> mimeTypesMap = [] { 367 373 HashMap<String, Vector<String>, ASCIICaseInsensitiveHash> map; 368 for (auto& pair : commonMediaTypes ) {374 for (auto& pair : commonMediaTypes()) { 369 375 ASCIILiteral type = pair.type; 370 376 ASCIILiteral extension = pair.extension; … … 380 386 } 381 387 return map; 382 }()); 383 auto mapEntry = map.get().find(extension); 384 if (mapEntry == map.get().end()) 388 }(); 389 return mimeTypesMap; 390 } 391 392 static const Vector<String>* typesForCommonExtension(const String& extension) 393 { 394 if (overriddenMimeTypesMap().hasValue()) { 395 auto mapEntry = overriddenMimeTypesMap()->find(extension); 396 if (mapEntry == overriddenMimeTypesMap()->end()) 397 return nullptr; 398 return &mapEntry->value; 399 } 400 auto mapEntry = commonMimeTypesMap().find(extension); 401 if (mapEntry == commonMimeTypesMap().end()) 385 402 return nullptr; 386 403 return &mapEntry->value; -
trunk/Source/WebCore/platform/MIMETypeRegistry.h
r255081 r255119 32 32 namespace WebCore { 33 33 34 WEBCORE_EXPORT Optional<HashMap<String, Vector<String>, ASCIICaseInsensitiveHash>>& overriddenMimeTypesMap(); 35 WEBCORE_EXPORT const HashMap<String, Vector<String>, ASCIICaseInsensitiveHash>& commonMimeTypesMap(); 36 37 struct TypeExtensionPair { 38 ASCIILiteral type; 39 ASCIILiteral extension; 40 }; 41 42 WEBCORE_EXPORT const std::initializer_list<TypeExtensionPair>& commonMediaTypes(); 43 34 44 struct MIMETypeRegistryThreadGlobalData { 35 45 WTF_MAKE_NONCOPYABLE(MIMETypeRegistryThreadGlobalData); … … 53 63 static Vector<String> getExtensionsForMIMEType(const String& type); 54 64 WEBCORE_EXPORT static String getPreferredExtensionForMIMEType(const String& type); 55 static String getMediaMIMETypeForExtension(const String& extension);65 WEBCORE_EXPORT static String getMediaMIMETypeForExtension(const String& extension); 56 66 static Vector<String> getMediaMIMETypesForExtension(const String& extension); 57 67 -
trunk/Source/WebCore/testing/Internals.cpp
r255081 r255119 119 119 #include "LoaderStrategy.h" 120 120 #include "Location.h" 121 #include "MIMETypeRegistry.h" 121 122 #include "MallocStatistics.h" 122 123 #include "MediaDevices.h" … … 5441 5442 } 5442 5443 5444 String Internals::mediaMIMETypeForExtension(const String& extension) 5445 { 5446 return MIMETypeRegistry::getMediaMIMETypeForExtension(extension); 5447 } 5448 5443 5449 } // namespace WebCore -
trunk/Source/WebCore/testing/Internals.h
r255081 r255119 931 931 bool systemHasBattery() const; 932 932 933 String mediaMIMETypeForExtension(const String& extension); 934 933 935 private: 934 936 explicit Internals(Document&); -
trunk/Source/WebCore/testing/Internals.idl
r255081 r255119 838 838 839 839 boolean systemHasBattery(); 840 }; 840 841 DOMString mediaMIMETypeForExtension(DOMString extension); 842 }; -
trunk/Source/WebKit/ChangeLog
r255117 r255119 1 2020-01-25 Per Arne Vollan <pvollan@apple.com> 2 3 [Cocoa] Media mime types map should be created in the UI process 4 https://bugs.webkit.org/show_bug.cgi?id=206478 5 6 Reviewed by Darin Adler. 7 8 Send the mime type map from the UI process to the WebContent process as part of the 9 WebProcess creation parameters. 10 11 * Shared/WebProcessCreationParameters.cpp: 12 (WebKit::WebProcessCreationParameters::encode const): 13 (WebKit::WebProcessCreationParameters::decode): 14 * Shared/WebProcessCreationParameters.h: 15 * UIProcess/Cocoa/WebProcessPoolCocoa.mm: 16 (WebKit::WebProcessPool::platformInitializeWebProcess): 17 * WebProcess/cocoa/WebProcessCocoa.mm: 18 (WebKit::WebProcess::platformInitializeWebProcess): 19 1 20 2020-01-25 Antti Koivisto <antti@apple.com> 2 21 -
trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp
r255081 r255119 168 168 encoder << neSessionManagerExtensionHandle; 169 169 encoder << systemHasBattery; 170 encoder << mimeTypesMap; 170 171 #endif 171 172 … … 441 442 return false; 442 443 parameters.systemHasBattery = WTFMove(*systemHasBattery); 444 445 Optional<Optional<HashMap<String, Vector<String>, ASCIICaseInsensitiveHash>>> mimeTypesMap; 446 decoder >> mimeTypesMap; 447 if (!mimeTypesMap) 448 return false; 449 parameters.mimeTypesMap = WTFMove(*mimeTypesMap); 443 450 #endif 444 451 -
trunk/Source/WebKit/Shared/WebProcessCreationParameters.h
r255081 r255119 210 210 Optional<SandboxExtension::Handle> neSessionManagerExtensionHandle; 211 211 bool systemHasBattery { false }; 212 Optional<HashMap<String, Vector<String>, ASCIICaseInsensitiveHash>> mimeTypesMap; 212 213 #endif 213 214 -
trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
r255081 r255119 48 48 #import "WindowServerConnection.h" 49 49 #import <WebCore/Color.h> 50 #import <WebCore/MIMETypeRegistry.h> 50 51 #import <WebCore/NetworkStorageSession.h> 51 52 #import <WebCore/NotImplemented.h> … … 354 355 parameters.contentFilterExtensionHandle = WTFMove(handle); 355 356 } 357 parameters.mimeTypesMap = commonMimeTypesMap(); 356 358 #endif 357 359 -
trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
r255081 r255119 60 60 #import <WebCore/LocalizedStrings.h> 61 61 #import <WebCore/LogInitialization.h> 62 #import <WebCore/MIMETypeRegistry.h> 62 63 #import <WebCore/MemoryRelease.h> 63 64 #import <WebCore/NSScrollerImpDetails.h> … … 261 262 NetworkExtensionContentFilter::setHasConsumedSandboxExtensions(parameters.neHelperExtensionHandle.hasValue() && parameters.neSessionManagerExtensionHandle.hasValue()); 262 263 setSystemHasBattery(parameters.systemHasBattery); 264 265 if (parameters.mimeTypesMap) 266 overriddenMimeTypesMap() = WTFMove(parameters.mimeTypesMap); 263 267 #endif 264 268 -
trunk/Tools/ChangeLog
r255117 r255119 1 2020-01-25 Per Arne Vollan <pvollan@apple.com> 2 3 [Cocoa] Media mime types map should be created in the UI process 4 https://bugs.webkit.org/show_bug.cgi?id=206478 5 6 Reviewed by Darin Adler. 7 8 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 9 * TestWebKitAPI/Tests/WebKit/MimeTypes.mm: Added. 10 (TEST): 11 1 12 2020-01-25 Antti Koivisto <antti@apple.com> 2 13 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r255081 r255119 863 863 C0BD669F131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */; }; 864 864 C0C5D3C61459912900A802A6 /* GetBackingScaleFactor_Bundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */; }; 865 C145CC0C23DA5A1F003A5EEB /* MimeTypes.mm in Sources */ = {isa = PBXBuildFile; fileRef = C145CC0B23DA5A0F003A5EEB /* MimeTypes.mm */; }; 865 866 C1692DCA23D10DAE006E88F7 /* Battery.mm in Sources */ = {isa = PBXBuildFile; fileRef = C1692DC923D10DAE006E88F7 /* Battery.mm */; }; 866 867 C20F88A72295B96700D610FA /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C20F88A62295B96700D610FA /* CoreText.framework */; }; … … 2386 2387 C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor.mm; sourceTree = "<group>"; }; 2387 2388 C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor_Bundle.mm; sourceTree = "<group>"; }; 2389 C145CC0B23DA5A0F003A5EEB /* MimeTypes.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MimeTypes.mm; sourceTree = "<group>"; }; 2388 2390 C1692DC923D10DAE006E88F7 /* Battery.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = Battery.mm; sourceTree = "<group>"; }; 2389 2391 C1D8EE212028E8E3008EB141 /* WebProcessTerminate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessTerminate.mm; sourceTree = "<group>"; }; … … 2827 2829 children = ( 2828 2830 C1692DC923D10DAE006E88F7 /* Battery.mm */, 2831 C145CC0B23DA5A0F003A5EEB /* MimeTypes.mm */, 2829 2832 0F139E751A423A5300F590F5 /* WeakObjCPtr.mm */, 2830 2833 ); … … 4810 4813 5165FE04201EE620009F7EC3 /* MessagePortProviders.mm in Sources */, 4811 4814 A5B149DE1F5A19EA00C6DAFF /* MIMETypeRegistry.cpp in Sources */, 4815 C145CC0C23DA5A1F003A5EEB /* MimeTypes.mm in Sources */, 4812 4816 51CD1C6C1B38CE4300142CA5 /* ModalAlerts.mm in Sources */, 4813 4817 7C83E0B61D0A64B300FEBCF3 /* ModalAlertsSPI.cpp in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.