Changeset 231824 in webkit


Ignore:
Timestamp:
May 15, 2018 5:30:25 PM (6 years ago)
Author:
dino@apple.com
Message:

Post-review cleanup for 185459
https://bugs.webkit.org/show_bug.cgi?id=185665
<rdar://problem/40276689>

Reviewed by Tim Horton.

Jon made some comments in 185459 that I'm addressing here.

  • UIProcess/Cocoa/DownloadClient.h:
  • UIProcess/Cocoa/DownloadClient.mm: Guard the activity token for iOS

in a way that means it will still work ok on macOS.
(WebKit::DownloadClient::didStart):
(WebKit::DownloadClient::processDidCrash):
(WebKit::DownloadClient::didFinish):
(WebKit::DownloadClient::didFail):
(WebKit::DownloadClient::didCancel):
(WebKit::DownloadClient::takeActivityToken):
(WebKit::DownloadClient::releaseActivityTokenIfNecessary):
(WebKit::DownloadClient::releaseActivityToken): Deleted.

  • UIProcess/Cocoa/SystemPreviewControllerCocoa.mm: Add an early return.

(-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]):

Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r231821 r231824  
     12018-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
    1262018-05-15  Tadeu Zagallo  <tzagallo@apple.com>
    227
  • trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.h

    r231795 r231824  
    6161    void processDidCrash(WebProcessPool&, DownloadProxy&) final;
    6262
    63 #if PLATFORM(IOS) && USE(SYSTEM_PREVIEW)
    64     void releaseActivityToken(DownloadProxy&);
     63#if USE(SYSTEM_PREVIEW)
     64    void takeActivityToken(DownloadProxy&);
     65    void releaseActivityTokenIfNecessary(DownloadProxy&);
    6566#endif
    6667
    6768    WeakObjCPtr<id <_WKDownloadDelegate>> m_delegate;
     69
     70#if PLATFORM(IOS) && USE(SYSTEM_PREVIEW)
     71    ProcessThrottler::BackgroundActivityToken m_activityToken { nullptr };
     72#endif
    6873
    6974    struct {
     
    8287        bool downloadProcessDidCrash : 1;
    8388    } m_delegateMethods;
    84 
    85 #if PLATFORM(IOS) && USE(SYSTEM_PREVIEW)
    86     ProcessThrottler::BackgroundActivityToken m_activityToken;
    87 #endif
    8889};
    8990
  • trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm

    r231795 r231824  
    7777#if USE(SYSTEM_PREVIEW)
    7878    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);
    8480        return;
    8581    }
     
    180176#if USE(SYSTEM_PREVIEW)
    181177    if (downloadProxy.isSystemPreviewDownload()) {
    182         if (m_activityToken)
    183             releaseActivityToken(downloadProxy);
     178        releaseActivityTokenIfNecessary(downloadProxy);
    184179        return;
    185180    }
     
    229224            webPage->systemPreviewController()->finish(WebCore::URL(destinationURL));
    230225        }
    231         if (m_activityToken)
    232             releaseActivityToken(downloadProxy);
     226        releaseActivityTokenIfNecessary(downloadProxy);
    233227        return;
    234228    }
     
    245239        if (auto* webPage = downloadProxy.originatingPage())
    246240            webPage->systemPreviewController()->cancel();
    247         if (m_activityToken)
    248             releaseActivityToken(downloadProxy);
     241        releaseActivityTokenIfNecessary(downloadProxy);
    249242        return;
    250243    }
     
    261254        if (auto* webPage = downloadProxy.originatingPage())
    262255            webPage->systemPreviewController()->cancel();
    263         if (m_activityToken)
    264             releaseActivityToken(downloadProxy);
     256        releaseActivityTokenIfNecessary(downloadProxy);
    265257        return;
    266258    }
     
    279271}
    280272
    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)
     274void 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
     287void 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
    287297}
    288298#endif
  • trunk/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm

    r231814 r231824  
    7575- (id<QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
    7676{
    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";
    8082#if USE(APPLE_INTERNAL_SDK)
    81         contentType = WebKit::getUTIForMIMEType(self.mimeType);
     83    contentType = WebKit::getUTIForMIMEType(self.mimeType);
    8284#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    }];
    9192    return _item.get();
    9293}
Note: See TracChangeset for help on using the changeset viewer.