Changeset 231824 in webkit
- Timestamp:
- May 15, 2018 5:30:25 PM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r231821 r231824 1 2018-05-15 Dean Jackson <dino@apple.com> 2 3 Post-review cleanup for 185459 4 https://bugs.webkit.org/show_bug.cgi?id=185665 5 <rdar://problem/40276689> 6 7 Reviewed by Tim Horton. 8 9 Jon made some comments in 185459 that I'm addressing here. 10 11 * UIProcess/Cocoa/DownloadClient.h: 12 * UIProcess/Cocoa/DownloadClient.mm: Guard the activity token for iOS 13 in a way that means it will still work ok on macOS. 14 (WebKit::DownloadClient::didStart): 15 (WebKit::DownloadClient::processDidCrash): 16 (WebKit::DownloadClient::didFinish): 17 (WebKit::DownloadClient::didFail): 18 (WebKit::DownloadClient::didCancel): 19 (WebKit::DownloadClient::takeActivityToken): 20 (WebKit::DownloadClient::releaseActivityTokenIfNecessary): 21 (WebKit::DownloadClient::releaseActivityToken): Deleted. 22 23 * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm: Add an early return. 24 (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]): 25 1 26 2018-05-15 Tadeu Zagallo <tzagallo@apple.com> 2 27 -
trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.h
r231795 r231824 61 61 void processDidCrash(WebProcessPool&, DownloadProxy&) final; 62 62 63 #if PLATFORM(IOS) && USE(SYSTEM_PREVIEW) 64 void releaseActivityToken(DownloadProxy&); 63 #if USE(SYSTEM_PREVIEW) 64 void takeActivityToken(DownloadProxy&); 65 void releaseActivityTokenIfNecessary(DownloadProxy&); 65 66 #endif 66 67 67 68 WeakObjCPtr<id <_WKDownloadDelegate>> m_delegate; 69 70 #if PLATFORM(IOS) && USE(SYSTEM_PREVIEW) 71 ProcessThrottler::BackgroundActivityToken m_activityToken { nullptr }; 72 #endif 68 73 69 74 struct { … … 82 87 bool downloadProcessDidCrash : 1; 83 88 } m_delegateMethods; 84 85 #if PLATFORM(IOS) && USE(SYSTEM_PREVIEW)86 ProcessThrottler::BackgroundActivityToken m_activityToken;87 #endif88 89 }; 89 90 -
trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm
r231795 r231824 77 77 #if USE(SYSTEM_PREVIEW) 78 78 if (downloadProxy.isSystemPreviewDownload()) { 79 if (auto* webPage = downloadProxy.originatingPage()) { 80 RELEASE_LOG_IF(webPage->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - UIProcess is taking a background assertion because it is downloading a system preview", this); 81 ASSERT(!m_activityToken); 82 m_activityToken = webPage->process().throttler().backgroundActivityToken(); 83 } 79 takeActivityToken(downloadProxy); 84 80 return; 85 81 } … … 180 176 #if USE(SYSTEM_PREVIEW) 181 177 if (downloadProxy.isSystemPreviewDownload()) { 182 if (m_activityToken) 183 releaseActivityToken(downloadProxy); 178 releaseActivityTokenIfNecessary(downloadProxy); 184 179 return; 185 180 } … … 229 224 webPage->systemPreviewController()->finish(WebCore::URL(destinationURL)); 230 225 } 231 if (m_activityToken) 232 releaseActivityToken(downloadProxy); 226 releaseActivityTokenIfNecessary(downloadProxy); 233 227 return; 234 228 } … … 245 239 if (auto* webPage = downloadProxy.originatingPage()) 246 240 webPage->systemPreviewController()->cancel(); 247 if (m_activityToken) 248 releaseActivityToken(downloadProxy); 241 releaseActivityTokenIfNecessary(downloadProxy); 249 242 return; 250 243 } … … 261 254 if (auto* webPage = downloadProxy.originatingPage()) 262 255 webPage->systemPreviewController()->cancel(); 263 if (m_activityToken) 264 releaseActivityToken(downloadProxy); 256 releaseActivityTokenIfNecessary(downloadProxy); 265 257 return; 266 258 } … … 279 271 } 280 272 281 #if PLATFORM(IOS) && USE(SYSTEM_PREVIEW) 282 void DownloadClient::releaseActivityToken(DownloadProxy& downloadProxy) 283 { 284 RELEASE_LOG_IF(downloadProxy.originatingPage()->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p UIProcess is releasing a background assertion because a system preview download completed", this); 285 ASSERT(m_activityToken); 286 m_activityToken = nullptr; 273 #if USE(SYSTEM_PREVIEW) 274 void DownloadClient::takeActivityToken(DownloadProxy& downloadProxy) 275 { 276 #if PLATFORM(IOS) 277 if (auto* webPage = downloadProxy.originatingPage()) { 278 RELEASE_LOG_IF(webPage->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - UIProcess is taking a background assertion because it is downloading a system preview", this); 279 ASSERT(!m_activityToken); 280 m_activityToken = webPage->process().throttler().backgroundActivityToken(); 281 } 282 #else 283 UNUSED_PARAM(downloadProxy); 284 #endif 285 } 286 287 void DownloadClient::releaseActivityTokenIfNecessary(DownloadProxy& downloadProxy) 288 { 289 #if PLATFORM(IOS) 290 if (m_activityToken) { 291 RELEASE_LOG_IF(downloadProxy.originatingPage()->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p UIProcess is releasing a background assertion because a system preview download completed", this); 292 m_activityToken = nullptr; 293 } 294 #else 295 UNUSED_PARAM(downloadProxy); 296 #endif 287 297 } 288 298 #endif -
trunk/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm
r231814 r231824 75 75 - (id<QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index 76 76 { 77 if (!_item) { 78 _itemProvider = adoptNS([[NSItemProvider alloc] init]); 79 NSString *contentType = @"public.content"; 77 if (_item) 78 return _item.get(); 79 80 _itemProvider = adoptNS([[NSItemProvider alloc] init]); 81 NSString *contentType = @"public.content"; 80 82 #if USE(APPLE_INTERNAL_SDK) 81 83 contentType = WebKit::getUTIForMIMEType(self.mimeType); 82 84 #endif 83 _item = adoptNS([allocQLItemInstance() initWithPreviewItemProvider:_itemProvider.get() contentType:contentType previewTitle:@"Preview" fileSize:@(0)]); 84 [_item setUseLoadingTimeout:NO]; 85 86 [_itemProvider registerItemForTypeIdentifier:contentType loadHandler:^(NSItemProviderCompletionHandler completionHandler, Class expectedValueClass, NSDictionary * options) { 87 // This will get called once the download completes. 88 self.completionHandler = completionHandler; 89 }]; 90 } 85 _item = adoptNS([allocQLItemInstance() initWithPreviewItemProvider:_itemProvider.get() contentType:contentType previewTitle:@"Preview" fileSize:@(0)]); 86 [_item setUseLoadingTimeout:NO]; 87 88 [_itemProvider registerItemForTypeIdentifier:contentType loadHandler:^(NSItemProviderCompletionHandler completionHandler, Class expectedValueClass, NSDictionary * options) { 89 // This will get called once the download completes. 90 self.completionHandler = completionHandler; 91 }]; 91 92 return _item.get(); 92 93 }
Note: See TracChangeset
for help on using the changeset viewer.