Changeset 258795 in webkit
- Timestamp:
- Mar 20, 2020 3:36:45 PM (4 years ago)
- Location:
- trunk/Source
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r258789 r258795 1 2020-03-20 Jer Noble <jer.noble@apple.com> 2 3 Ensure media cache directory is created before passing to AVURLAsset. 4 https://bugs.webkit.org/show_bug.cgi?id=209341 5 6 Reviewed by Eric Carlson. 7 8 Sandbox changes require the media cache directory to be created before passing to 9 AVFoundation, to ensure that a sandbox extension is allowed to be created for that 10 directory. 11 12 When the mediaCacheDirectory is empty or null, no longer specify a temporary directory. This 13 allows clients to disable caching by specifying an empty string for the cache directory. 14 Since now assetCacheForPath() can return nil, update all the call sites to handle that 15 possibility. Add a new method, ensureAssetCacheExistsAtPath() which tries to create a 16 directory at the specified path, and returns nil if that is not possible. This ensures the 17 cache path exists before adding the AVAssetCache to the AVURLAsset options dictionary. 18 19 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 20 (WebCore::assetCacheForPath): 21 (WebCore::ensureAssetCacheExistsForPath): 22 (WebCore::MediaPlayerPrivateAVFoundationObjC::originsInMediaCache): 23 (WebCore::MediaPlayerPrivateAVFoundationObjC::clearMediaCache): 24 (WebCore::MediaPlayerPrivateAVFoundationObjC::clearMediaCacheForOrigins): 25 (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL): 26 1 27 2020-03-20 David Kilzer <ddkilzer@apple.com> 2 28 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r258082 r258795 80 80 #import <pal/spi/cocoa/QuartzCoreSPI.h> 81 81 #import <wtf/BlockObjCExceptions.h> 82 #import <wtf/FileSystem.h> 82 83 #import <wtf/ListHashSet.h> 83 84 #import <wtf/NeverDestroyed.h> … … 324 325 static AVAssetCache *assetCacheForPath(const String& path) 325 326 { 326 NSURL *assetCacheURL;327 328 327 if (path.isEmpty()) 329 assetCacheURL = [[NSURL fileURLWithPath:NSTemporaryDirectory()] URLByAppendingPathComponent:@"MediaCache" isDirectory:YES]; 330 else 331 assetCacheURL = [NSURL fileURLWithPath:path isDirectory:YES]; 332 333 return [PAL::getAVAssetCacheClass() assetCacheWithURL:assetCacheURL]; 328 return nil; 329 330 return [PAL::getAVAssetCacheClass() assetCacheWithURL:[NSURL fileURLWithPath:path isDirectory:YES]]; 331 } 332 333 static AVAssetCache *ensureAssetCacheExistsForPath(const String& path) 334 { 335 if (path.isEmpty()) 336 return nil; 337 338 auto fileExistsAtPath = FileSystem::fileExists(path); 339 340 if (fileExistsAtPath && !FileSystem::fileIsDirectory(path, FileSystem::ShouldFollowSymbolicLinks::Yes)) { 341 // Non-directory file already exists at the path location; bail. 342 ASSERT_NOT_REACHED(); 343 return nil; 344 } 345 346 if (!fileExistsAtPath && !FileSystem::makeAllDirectories(path)) { 347 // Could not create a directory at the specified location; bail. 348 ASSERT_NOT_REACHED(); 349 return nil; 350 } 351 352 return assetCacheForPath(path); 334 353 } 335 354 … … 337 356 { 338 357 HashSet<RefPtr<SecurityOrigin>> origins; 339 for (NSString *key in [assetCacheForPath(path) allKeys]) { 358 AVAssetCache* assetCache = assetCacheForPath(path); 359 if (!assetCache) 360 return origins; 361 362 for (NSString *key in [assetCache allKeys]) { 340 363 URL keyAsURL = URL(URL(), key); 341 364 if (keyAsURL.isValid()) … … 354 377 { 355 378 AVAssetCache* assetCache = assetCacheForPath(path); 379 if (!assetCache) 380 return; 356 381 357 382 for (NSString *key in [assetCache allKeys]) { … … 396 421 { 397 422 AVAssetCache* assetCache = assetCacheForPath(path); 423 if (!assetCache) 424 return; 425 398 426 for (NSString *key in [assetCache allKeys]) { 399 427 URL keyAsURL = URL(URL(), key); … … 841 869 [options setObject:@(!usePersistentCache) forKey:AVURLAssetUsesNoPersistentCacheKey]; 842 870 843 if (usePersistentCache) 844 [options setObject:assetCacheForPath(player()->mediaCacheDirectory()) forKey:AVURLAssetCacheKey]; 871 if (usePersistentCache) { 872 if (auto* assetCache = ensureAssetCacheExistsForPath(player()->mediaCacheDirectory())) 873 [options setObject:assetCache forKey:AVURLAssetCacheKey]; 874 else 875 [options setObject:@NO forKey:AVURLAssetUsesNoPersistentCacheKey]; 876 } 845 877 846 878 NSURL *cocoaURL = canonicalURL(url); -
trunk/Source/WebKitLegacy/mac/ChangeLog
r258782 r258795 1 2020-03-20 Jer Noble <jer.noble@apple.com> 2 3 Ensure media cache directory is created before passing to AVURLAsset. 4 https://bugs.webkit.org/show_bug.cgi?id=209341 5 6 Reviewed by Eric Carlson. 7 8 MediaPlayerPrivateAVFoundaionObjC will no longer create an asset cache in a temporary 9 directory by default; ensure that it's media cache directory is set during initialization. 10 11 * WebView/WebView.mm: 12 (-[WebView _commonInitializationWithFrameName:groupName:]): 13 1 14 2020-03-20 Timothy Horton <timothy_horton@apple.com> 2 15 -
trunk/Source/WebKitLegacy/mac/WebView/WebView.mm
r258628 r258795 1428 1428 WebCore::DeprecatedGlobalSettings::setShouldManageAudioSessionCategory(true); 1429 1429 #endif 1430 1431 #if ENABLE(VIDEO) 1432 WebCore::HTMLMediaElement::setMediaCacheDirectory(FileSystem::pathByAppendingComponent(NSTemporaryDirectory(), "MediaCache/"_s)); 1433 #endif 1430 1434 didOneTimeInitialization = true; 1431 1435 }
Note: See TracChangeset
for help on using the changeset viewer.