Title: [231824] trunk/Source/WebKit
Revision
231824
Author
[email protected]
Date
2018-05-15 17:30:25 -0700 (Tue, 15 May 2018)

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

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (231823 => 231824)


--- trunk/Source/WebKit/ChangeLog	2018-05-16 00:01:17 UTC (rev 231823)
+++ trunk/Source/WebKit/ChangeLog	2018-05-16 00:30:25 UTC (rev 231824)
@@ -1,3 +1,28 @@
+2018-05-15  Dean Jackson  <[email protected]>
+
+        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:]):
+
 2018-05-15  Tadeu Zagallo  <[email protected]>
 
         Update touch event tracking type on every touch

Modified: trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.h (231823 => 231824)


--- trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.h	2018-05-16 00:01:17 UTC (rev 231823)
+++ trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.h	2018-05-16 00:30:25 UTC (rev 231824)
@@ -60,12 +60,17 @@
     void didCreateDestination(WebProcessPool&, DownloadProxy&, const String&) final;
     void processDidCrash(WebProcessPool&, DownloadProxy&) final;
 
-#if PLATFORM(IOS) && USE(SYSTEM_PREVIEW)
-    void releaseActivityToken(DownloadProxy&);
+#if USE(SYSTEM_PREVIEW)
+    void takeActivityToken(DownloadProxy&);
+    void releaseActivityTokenIfNecessary(DownloadProxy&);
 #endif
 
     WeakObjCPtr<id <_WKDownloadDelegate>> m_delegate;
 
+#if PLATFORM(IOS) && USE(SYSTEM_PREVIEW)
+    ProcessThrottler::BackgroundActivityToken m_activityToken { nullptr };
+#endif
+
     struct {
         bool downloadDidStart : 1;            
         bool downloadDidReceiveResponse : 1;
@@ -81,10 +86,6 @@
         bool downloadDidCreateDestination : 1;
         bool downloadProcessDidCrash : 1;
     } m_delegateMethods;
-
-#if PLATFORM(IOS) && USE(SYSTEM_PREVIEW)
-    ProcessThrottler::BackgroundActivityToken m_activityToken;
-#endif
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm (231823 => 231824)


--- trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm	2018-05-16 00:01:17 UTC (rev 231823)
+++ trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm	2018-05-16 00:30:25 UTC (rev 231824)
@@ -76,11 +76,7 @@
 {
 #if USE(SYSTEM_PREVIEW)
     if (downloadProxy.isSystemPreviewDownload()) {
-        if (auto* webPage = downloadProxy.originatingPage()) {
-            RELEASE_LOG_IF(webPage->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - UIProcess is taking a background assertion because it is downloading a system preview", this);
-            ASSERT(!m_activityToken);
-            m_activityToken = webPage->process().throttler().backgroundActivityToken();
-        }
+        takeActivityToken(downloadProxy);
         return;
     }
 #endif
@@ -179,8 +175,7 @@
 {
 #if USE(SYSTEM_PREVIEW)
     if (downloadProxy.isSystemPreviewDownload()) {
-        if (m_activityToken)
-            releaseActivityToken(downloadProxy);
+        releaseActivityTokenIfNecessary(downloadProxy);
         return;
     }
 #endif
@@ -228,8 +223,7 @@
             NSURL *destinationURL = [NSURL fileURLWithPath:(NSString *)downloadProxy.destinationFilename()];
             webPage->systemPreviewController()->finish(WebCore::URL(destinationURL));
         }
-        if (m_activityToken)
-            releaseActivityToken(downloadProxy);
+        releaseActivityTokenIfNecessary(downloadProxy);
         return;
     }
 #endif
@@ -244,8 +238,7 @@
     if (downloadProxy.isSystemPreviewDownload()) {
         if (auto* webPage = downloadProxy.originatingPage())
             webPage->systemPreviewController()->cancel();
-        if (m_activityToken)
-            releaseActivityToken(downloadProxy);
+        releaseActivityTokenIfNecessary(downloadProxy);
         return;
     }
 #endif
@@ -260,8 +253,7 @@
     if (downloadProxy.isSystemPreviewDownload()) {
         if (auto* webPage = downloadProxy.originatingPage())
             webPage->systemPreviewController()->cancel();
-        if (m_activityToken)
-            releaseActivityToken(downloadProxy);
+        releaseActivityTokenIfNecessary(downloadProxy);
         return;
     }
 #endif
@@ -278,14 +270,32 @@
     completionHandler(WTFMove(request));
 }
 
-#if PLATFORM(IOS) && USE(SYSTEM_PREVIEW)
-void DownloadClient::releaseActivityToken(DownloadProxy& downloadProxy)
+#if USE(SYSTEM_PREVIEW)
+void DownloadClient::takeActivityToken(DownloadProxy& downloadProxy)
 {
-    RELEASE_LOG_IF(downloadProxy.originatingPage()->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p UIProcess is releasing a background assertion because a system preview download completed", this);
-    ASSERT(m_activityToken);
-    m_activityToken = nullptr;
+#if PLATFORM(IOS)
+    if (auto* webPage = downloadProxy.originatingPage()) {
+        RELEASE_LOG_IF(webPage->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - UIProcess is taking a background assertion because it is downloading a system preview", this);
+        ASSERT(!m_activityToken);
+        m_activityToken = webPage->process().throttler().backgroundActivityToken();
+    }
+#else
+    UNUSED_PARAM(downloadProxy);
+#endif
 }
+
+void DownloadClient::releaseActivityTokenIfNecessary(DownloadProxy& downloadProxy)
+{
+#if PLATFORM(IOS)
+    if (m_activityToken) {
+        RELEASE_LOG_IF(downloadProxy.originatingPage()->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p UIProcess is releasing a background assertion because a system preview download completed", this);
+        m_activityToken = nullptr;
+    }
+#else
+    UNUSED_PARAM(downloadProxy);
 #endif
+}
+#endif
 
 } // namespace WebKit
 

Modified: trunk/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm (231823 => 231824)


--- trunk/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm	2018-05-16 00:01:17 UTC (rev 231823)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm	2018-05-16 00:30:25 UTC (rev 231824)
@@ -74,20 +74,21 @@
 
 - (id<QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
 {
-    if (!_item) {
-        _itemProvider = adoptNS([[NSItemProvider alloc] init]);
-        NSString *contentType = @"public.content";
+    if (_item)
+        return _item.get();
+
+    _itemProvider = adoptNS([[NSItemProvider alloc] init]);
+    NSString *contentType = @"public.content";
 #if USE(APPLE_INTERNAL_SDK)
-        contentType = WebKit::getUTIForMIMEType(self.mimeType);
+    contentType = WebKit::getUTIForMIMEType(self.mimeType);
 #endif
-        _item = adoptNS([allocQLItemInstance() initWithPreviewItemProvider:_itemProvider.get() contentType:contentType previewTitle:@"Preview" fileSize:@(0)]);
-        [_item setUseLoadingTimeout:NO];
+    _item = adoptNS([allocQLItemInstance() initWithPreviewItemProvider:_itemProvider.get() contentType:contentType previewTitle:@"Preview" fileSize:@(0)]);
+    [_item setUseLoadingTimeout:NO];
 
-        [_itemProvider registerItemForTypeIdentifier:contentType loadHandler:^(NSItemProviderCompletionHandler completionHandler, Class expectedValueClass, NSDictionary * options) {
-            // This will get called once the download completes.
-            self.completionHandler = completionHandler;
-        }];
-    }
+    [_itemProvider registerItemForTypeIdentifier:contentType loadHandler:^(NSItemProviderCompletionHandler completionHandler, Class expectedValueClass, NSDictionary * options) {
+        // This will get called once the download completes.
+        self.completionHandler = completionHandler;
+    }];
     return _item.get();
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to