Changeset 231857 in webkit


Ignore:
Timestamp:
May 16, 2018 11:47:28 AM (6 years ago)
Author:
bshafiei@apple.com
Message:

Cherry-pick r231824. rdar://problem/40278181

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:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231824 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-606.1.17-branch/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-606.1.17-branch/Source/WebKit/ChangeLog

    r231856 r231857  
     12018-05-16  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Cherry-pick r231824. rdar://problem/40278181
     4
     5    Post-review cleanup for 185459
     6    https://bugs.webkit.org/show_bug.cgi?id=185665
     7    <rdar://problem/40276689>
     8   
     9    Reviewed by Tim Horton.
     10   
     11    Jon made some comments in 185459 that I'm addressing here.
     12   
     13    * UIProcess/Cocoa/DownloadClient.h:
     14    * UIProcess/Cocoa/DownloadClient.mm: Guard the activity token for iOS
     15    in a way that means it will still work ok on macOS.
     16    (WebKit::DownloadClient::didStart):
     17    (WebKit::DownloadClient::processDidCrash):
     18    (WebKit::DownloadClient::didFinish):
     19    (WebKit::DownloadClient::didFail):
     20    (WebKit::DownloadClient::didCancel):
     21    (WebKit::DownloadClient::takeActivityToken):
     22    (WebKit::DownloadClient::releaseActivityTokenIfNecessary):
     23    (WebKit::DownloadClient::releaseActivityToken): Deleted.
     24   
     25    * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm: Add an early return.
     26    (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]):
     27   
     28    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231824 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     29
     30    2018-05-15  Dean Jackson  <dino@apple.com>
     31
     32            Post-review cleanup for 185459
     33            https://bugs.webkit.org/show_bug.cgi?id=185665
     34            <rdar://problem/40276689>
     35
     36            Reviewed by Tim Horton.
     37
     38            Jon made some comments in 185459 that I'm addressing here.
     39
     40            * UIProcess/Cocoa/DownloadClient.h:
     41            * UIProcess/Cocoa/DownloadClient.mm: Guard the activity token for iOS
     42            in a way that means it will still work ok on macOS.
     43            (WebKit::DownloadClient::didStart):
     44            (WebKit::DownloadClient::processDidCrash):
     45            (WebKit::DownloadClient::didFinish):
     46            (WebKit::DownloadClient::didFail):
     47            (WebKit::DownloadClient::didCancel):
     48            (WebKit::DownloadClient::takeActivityToken):
     49            (WebKit::DownloadClient::releaseActivityTokenIfNecessary):
     50            (WebKit::DownloadClient::releaseActivityToken): Deleted.
     51
     52            * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm: Add an early return.
     53            (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]):
     54
    1552018-05-16  Babak Shafiei  <bshafiei@apple.com>
    256
  • branches/safari-606.1.17-branch/Source/WebKit/UIProcess/Cocoa/DownloadClient.h

    r231802 r231857  
    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
  • branches/safari-606.1.17-branch/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm

    r231802 r231857  
    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
  • branches/safari-606.1.17-branch/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm

    r231856 r231857  
    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.