Formalize WebKitAdditions mechanism of LoadOptimizer
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2019 20:01:07 +0000 (20:01 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2019 20:01:07 +0000 (20:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193886
<rdar://problem/47696809>

Reviewed by Brent Fulgham.

Source/WebCore:

Covered by existing tests.

* platform/network/ResourceRequestBase.h:
Export isolatedCopy().

Source/WebKit:

This patch does the following few things:
1) formalizes WebKitAdditions mechanism of LoadOptimizer;
2) modernizes AppLinks code in tryInterceptNavigation to use BlockPtr;
3) lets AppLinks have higher precedence than LoadOptimizer.

* SourcesCocoa.txt:
* UIProcess/Cocoa/LoadOptimizer.h: Removed.
* UIProcess/Cocoa/LoadOptimizer.mm: Removed.
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::tryOptimizingLoad):
(WebKit::tryInterceptNavigation):
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::WebsiteDataStore):
* UIProcess/WebsiteData/WebsiteDataStore.h:
(WebKit::WebsiteDataStore::loadOptimizer): Deleted.
* WebKit.xcodeproj/project.pbxproj:

Tools:

* MiniBrowser/MiniBrowser.entitlements:
Make com.apple.security.temporary-exception.mach-lookup.global-name an array.

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

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/network/ResourceRequestBase.h
Source/WebKit/ChangeLog
Source/WebKit/SourcesCocoa.txt
Source/WebKit/UIProcess/Cocoa/LoadOptimizer.h [deleted file]
Source/WebKit/UIProcess/Cocoa/LoadOptimizer.mm [deleted file]
Source/WebKit/UIProcess/Cocoa/NavigationState.mm
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Tools/ChangeLog
Tools/MiniBrowser/MiniBrowser.entitlements

index 0a52aa0..e22c7ee 100644 (file)
@@ -1,3 +1,16 @@
+2019-01-31  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Formalize WebKitAdditions mechanism of LoadOptimizer
+        https://bugs.webkit.org/show_bug.cgi?id=193886
+        <rdar://problem/47696809>
+
+        Reviewed by Brent Fulgham.
+
+        Covered by existing tests.
+
+        * platform/network/ResourceRequestBase.h:
+        Export isolatedCopy().
+
 2019-01-31  Jer Noble  <jer.noble@apple.com>
 
         [Cocoa][EME] Modern EME uses a different path for SecureStop data than Legacy EME
index b470274..927f43a 100644 (file)
@@ -57,7 +57,7 @@ class ResourceResponse;
 class ResourceRequestBase {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    ResourceRequest isolatedCopy() const;
+    WEBCORE_EXPORT ResourceRequest isolatedCopy() const;
     WEBCORE_EXPORT void setAsIsolatedCopy(const ResourceRequest&);
 
     WEBCORE_EXPORT bool isNull() const;
index f6e5782..fda715d 100644 (file)
@@ -1,3 +1,28 @@
+2019-01-31  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Formalize WebKitAdditions mechanism of LoadOptimizer
+        https://bugs.webkit.org/show_bug.cgi?id=193886
+        <rdar://problem/47696809>
+
+        Reviewed by Brent Fulgham.
+
+        This patch does the following few things:
+        1) formalizes WebKitAdditions mechanism of LoadOptimizer;
+        2) modernizes AppLinks code in tryInterceptNavigation to use BlockPtr;
+        3) lets AppLinks have higher precedence than LoadOptimizer.
+
+        * SourcesCocoa.txt:
+        * UIProcess/Cocoa/LoadOptimizer.h: Removed.
+        * UIProcess/Cocoa/LoadOptimizer.mm: Removed.
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::tryOptimizingLoad):
+        (WebKit::tryInterceptNavigation):
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::WebsiteDataStore):
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+        (WebKit::WebsiteDataStore::loadOptimizer): Deleted.
+        * WebKit.xcodeproj/project.pbxproj:
+
 2019-01-31  Chris Dumez  <cdumez@apple.com>
 
         Regression(PSON) Crash under WebProcessProxy::canTerminateChildProcess()
index cbf2e9d..1cf8249 100644 (file)
@@ -324,7 +324,6 @@ UIProcess/Cocoa/FullscreenClient.mm
 UIProcess/Cocoa/GlobalFindInPageState.mm
 UIProcess/Cocoa/IconLoadingDelegate.mm
 UIProcess/Cocoa/LegacyCustomProtocolManagerClient.mm
-UIProcess/Cocoa/LoadOptimizer.mm
 UIProcess/Cocoa/MediaCaptureUtilities.mm
 UIProcess/Cocoa/NavigationState.mm
 UIProcess/Cocoa/PageClientImplCocoa.mm
diff --git a/Source/WebKit/UIProcess/Cocoa/LoadOptimizer.h b/Source/WebKit/UIProcess/Cocoa/LoadOptimizer.h
deleted file mode 100644 (file)
index acecf04..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if HAVE(LOAD_OPTIMIZER)
-#include <WebKitAdditions/LoadOptimizerAdditions.h>
-#endif
diff --git a/Source/WebKit/UIProcess/Cocoa/LoadOptimizer.mm b/Source/WebKit/UIProcess/Cocoa/LoadOptimizer.mm
deleted file mode 100644 (file)
index 215cebf..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "LoadOptimizer.h"
-
-#if HAVE(LOAD_OPTIMIZER)
-#import <WebKitAdditions/LoadOptimizerAdditions.mm>
-#endif
index 6a47cea..f444796 100644 (file)
@@ -37,7 +37,6 @@
 #import "AuthenticationChallengeDisposition.h"
 #import "AuthenticationDecisionListener.h"
 #import "CompletionHandlerCallChecker.h"
-#import "LoadOptimizer.h"
 #import "Logging.h"
 #import "NavigationActionData.h"
 #import "PageLoadState.h"
 #import <pal/spi/cocoa/LaunchServicesSPI.h>
 #endif
 
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/NavigationStateAdditions.mm>
+#endif
+
 #if USE(QUICK_LOOK)
 #import "QuickLookDocumentData.h"
 #endif
@@ -465,29 +468,32 @@ bool NavigationState::NavigationClient::willGoToBackForwardListItem(WebPageProxy
 }
 #endif
 
+#if !USE(APPLE_INTERNAL_SDK)
+static void tryOptimizingLoad(const WebCore::ResourceRequest&, WebPageProxy&, Function<void(bool)>&& completionHandler)
+{
+    completionHandler(false);
+}
+#endif
+
 static void tryInterceptNavigation(Ref<API::NavigationAction>&& navigationAction, WebPageProxy& page, WTF::Function<void(bool)>&& completionHandler)
 {
 #if HAVE(APP_LINKS)
     if (navigationAction->shouldOpenAppLinks()) {
-        auto* localCompletionHandler = new WTF::Function<void (bool)>(WTFMove(completionHandler));
-        [LSAppLink openWithURL:navigationAction->request().url() completionHandler:[localCompletionHandler](BOOL success, NSError *) {
-            dispatch_async(dispatch_get_main_queue(), [localCompletionHandler, success] {
-                (*localCompletionHandler)(success);
-                delete localCompletionHandler;
+        auto callback = makeBlockPtr([request = navigationAction->request().isolatedCopy(), weakPage = makeWeakPtr(page), completionHandler = WTFMove(completionHandler)] (BOOL success, NSError *) mutable {
+            RunLoop::main().dispatch([request = request.isolatedCopy(), weakPage, completionHandler = WTFMove(completionHandler), success]() mutable {
+                if (!success && weakPage) {
+                    tryOptimizingLoad(request, *weakPage, WTFMove(completionHandler));
+                    return;
+                }
+                completionHandler(success);
             });
-        }];
+        });
+        [LSAppLink openWithURL:navigationAction->request().url() completionHandler:callback.get()];
         return;
     }
 #endif
 
-#if HAVE(LOAD_OPTIMIZER)
-    if (LoadOptimizer::canOptimizeLoad(navigationAction->request().url())) {
-        page.websiteDataStore().loadOptimizer().optimizeLoad(navigationAction->request(), page, WTFMove(completionHandler));
-        return;
-    }
-#endif
-
-    completionHandler(false);
+    tryOptimizingLoad(navigationAction->request(), page, WTFMove(completionHandler));
 }
 
 void NavigationState::NavigationClient::decidePolicyForNavigationAction(WebPageProxy& webPageProxy, Ref<API::NavigationAction>&& navigationAction, Ref<WebFramePolicyListenerProxy>&& listener, API::Object* userInfo)
index 8a9c178..429d132 100644 (file)
 #include <wtf/ProcessPrivilege.h>
 #include <wtf/RunLoop.h>
 
-#if HAVE(LOAD_OPTIMIZER)
-#include "LoadOptimizer.h"
-#endif
-
 #if ENABLE(NETSCAPE_PLUGIN_API)
 #include "PluginProcessManager.h"
 #endif
@@ -104,10 +100,10 @@ WebsiteDataStore::WebsiteDataStore(Ref<WebsiteDataStoreConfiguration>&& configur
     , m_authenticatorManager(makeUniqueRef<AuthenticatorManager>())
 #endif
     , m_client(makeUniqueRef<WebsiteDataStoreClient>())
+{
 #if HAVE(LOAD_OPTIMIZER)
-    , m_loadOptimizer(makeUniqueRef<LoadOptimizer>())
+WEBSITEDATASTORE_LOADOPTIMIZER_ADDITIONS_2
 #endif
-{
     WTF::setProcessPrivileges(allPrivileges());
     maybeRegisterWithSessionIDMap();
     platformInitialize();
@@ -125,10 +121,10 @@ WebsiteDataStore::WebsiteDataStore(PAL::SessionID sessionID)
     , m_authenticatorManager(makeUniqueRef<AuthenticatorManager>())
 #endif
     , m_client(makeUniqueRef<WebsiteDataStoreClient>())
+{
 #if HAVE(LOAD_OPTIMIZER)
-    , m_loadOptimizer(makeUniqueRef<LoadOptimizer>())
+WEBSITEDATASTORE_LOADOPTIMIZER_ADDITIONS_2
 #endif
-{
     maybeRegisterWithSessionIDMap();
     platformInitialize();
 
index 38250df..8f6e30f 100644 (file)
 #include <WebCore/CurlProxySettings.h>
 #endif
 
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/WebsiteDataStoreAdditions.h>
+#endif
+
 namespace WebCore {
 class SecurityOrigin;
 }
@@ -59,7 +63,6 @@ class SecurityOrigin;
 namespace WebKit {
 
 class AuthenticatorManager;
-class LoadOptimizer;
 class SecKeyProxyStore;
 class StorageManager;
 class DeviceIdHashSaltStorage;
@@ -227,7 +230,7 @@ public:
     void setClient(UniqueRef<WebsiteDataStoreClient>&& client) { m_client = WTFMove(client); }
 
 #if HAVE(LOAD_OPTIMIZER)
-    LoadOptimizer& loadOptimizer() { return m_loadOptimizer.get(); }
+WEBSITEDATASTORE_LOADOPTIMIZER_ADDITIONS_1
 #endif
 
 private:
@@ -306,10 +309,6 @@ private:
 #endif
 
     UniqueRef<WebsiteDataStoreClient> m_client;
-
-#if HAVE(LOAD_OPTIMIZER)
-    UniqueRef<LoadOptimizer> m_loadOptimizer;
-#endif
 };
 
 }
index 2a22d55..0ef8bb0 100644 (file)
                57597EBD218184900037F924 /* CtapHidAuthenticator.h in Headers */ = {isa = PBXBuildFile; fileRef = 57597EBB2181848F0037F924 /* CtapHidAuthenticator.h */; };
                5772F206217DBD6A0056BF2C /* HidService.h in Headers */ = {isa = PBXBuildFile; fileRef = 5772F204217DBD6A0056BF2C /* HidService.h */; };
                578DC2982155A0020074E815 /* LocalAuthenticationSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 578DC2972155A0010074E815 /* LocalAuthenticationSoftLink.h */; };
-               57900B4021F8F9B8008317DE /* LoadOptimizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 57900B3E21F8F9B8008317DE /* LoadOptimizer.h */; };
                57AC8F50217FEED90055438C /* HidConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 57AC8F4E217FEED90055438C /* HidConnection.h */; };
                57B4B46020B504AC00D4AD79 /* ClientCertificateAuthenticationXPCConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B4B45E20B504AB00D4AD79 /* ClientCertificateAuthenticationXPCConstants.h */; };
                57DCED6E2142EE5E0016B847 /* WebAuthenticatorCoordinatorMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57DCED6B2142EAE20016B847 /* WebAuthenticatorCoordinatorMessageReceiver.cpp */; };
                5772F204217DBD6A0056BF2C /* HidService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HidService.h; sourceTree = "<group>"; };
                5772F205217DBD6A0056BF2C /* HidService.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = HidService.mm; sourceTree = "<group>"; };
                578DC2972155A0010074E815 /* LocalAuthenticationSoftLink.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LocalAuthenticationSoftLink.h; sourceTree = "<group>"; };
-               57900B3E21F8F9B8008317DE /* LoadOptimizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoadOptimizer.h; sourceTree = "<group>"; };
-               57900B3F21F8F9B8008317DE /* LoadOptimizer.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LoadOptimizer.mm; sourceTree = "<group>"; };
                57AC8F4E217FEED90055438C /* HidConnection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HidConnection.h; sourceTree = "<group>"; };
                57AC8F4F217FEED90055438C /* HidConnection.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = HidConnection.mm; sourceTree = "<group>"; };
                57B4B45D20B504AB00D4AD79 /* AuthenticationManagerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AuthenticationManagerCocoa.mm; sourceTree = "<group>"; };
                                51C0C9731DDD74F00032CAD3 /* IconLoadingDelegate.mm */,
                                7A821F4B1E2F664800604577 /* LegacyCustomProtocolManagerClient.h */,
                                7A821F4D1E2F679E00604577 /* LegacyCustomProtocolManagerClient.mm */,
-                               57900B3E21F8F9B8008317DE /* LoadOptimizer.h */,
-                               57900B3F21F8F9B8008317DE /* LoadOptimizer.mm */,
                                411286EF21C8A90C003A8550 /* MediaCaptureUtilities.h */,
                                411286F021C8A90D003A8550 /* MediaCaptureUtilities.mm */,
                                1ABC3DF41899E437004F0626 /* NavigationState.h */,
                                413075AD1DE85F580039EC69 /* LibWebRTCSocket.h in Headers */,
                                41DC459C1E3DBB2800B11F51 /* LibWebRTCSocketClient.h in Headers */,
                                413075B21DE85F580039EC69 /* LibWebRTCSocketFactory.h in Headers */,
-                               57900B4021F8F9B8008317DE /* LoadOptimizer.h in Headers */,
                                2D1087611D2C573E00B85F82 /* LoadParameters.h in Headers */,
                                578DC2982155A0020074E815 /* LocalAuthenticationSoftLink.h in Headers */,
                                57DCEDAC214C60270016B847 /* LocalAuthenticator.h in Headers */,
index 16c9d46..c42d240 100644 (file)
@@ -1,3 +1,14 @@
+2019-01-31  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Formalize WebKitAdditions mechanism of LoadOptimizer
+        https://bugs.webkit.org/show_bug.cgi?id=193886
+        <rdar://problem/47696809>
+
+        Reviewed by Brent Fulgham.
+
+        * MiniBrowser/MiniBrowser.entitlements:
+        Make com.apple.security.temporary-exception.mach-lookup.global-name an array.
+
 2019-01-31  Zalan Bujtas  <zalan@apple.com>
 
         [LFC] Margin before/after/start/end initial value is 0 and not auto.
index e085f4e..e6e5a9d 100644 (file)
@@ -5,7 +5,9 @@
        <key>com.apple.security.device.usb</key>
        <true/>
        <key>com.apple.security.temporary-exception.mach-lookup.global-name</key>
-       <string>com.apple.Safari.SafeBrowsing.Service</string>
+       <array>
+               <string>com.apple.Safari.SafeBrowsing.Service</string>
+       </array>
        <key>com.apple.security.app-sandbox</key>
        <true/>
        <key>com.apple.security.network.client</key>