Skip to content

Commit

Permalink
[cocoa] Expand when new experimental network loader is enabled
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=273091
rdar://126718999

Reviewed by Brent Fulgham.

The existing feature flag still takes precedence, but now the loader is used
when the a LOOA check passes, and for all tests (not only layout tests).
Otherwise, if the loader is enabled, then we use it for Safari.

* Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h:
* Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
(WebKit::WebsiteDataStore::useNetworkLoader):

Canonical link: https://commits.webkit.org/278344@main
  • Loading branch information
Matthew Finkel committed May 3, 2024
1 parent 4e8f922 commit 9fdc371
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ enum class SDKAlignedBehavior {
ThrowOnKVCInstanceVariableAccess,
LaxCookieSameSiteAttribute,
BlockOptionallyBlockableMixedContent,
UseCFNetworkNetworkLoader,

NumberOfBehaviors
};
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/PAL/pal/spi/cocoa/NetworkSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ void nw_parameters_set_traffic_class(nw_parameters_t, uint32_t traffic_class);

nw_interface_t nw_path_copy_interface(nw_path_t);

bool nw_settings_get_unified_http_enabled(void);

WTF_EXTERN_C_END

#endif // USE(APPLE_INTERNAL_SDK)
28 changes: 25 additions & 3 deletions Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#import <WebCore/RuntimeApplicationChecks.h>
#import <WebCore/SearchPopupMenuCocoa.h>
#import <pal/spi/cf/CFNetworkSPI.h>
#import <pal/spi/cocoa/NetworkSPI.h>
#import <wtf/FileSystem.h>
#import <wtf/NeverDestroyed.h>
#import <wtf/ProcessPrivilege.h>
Expand Down Expand Up @@ -220,11 +221,32 @@ bool experimentalFeatureEnabled(const String& key, bool defaultValue)

std::optional<bool> WebsiteDataStore::useNetworkLoader()
{
#if HAVE(NETWORK_LOADER)
return optionalExperimentalFeatureEnabled(WebPreferencesKey::cFNetworkNetworkLoaderEnabledKey(), std::nullopt);
#else
#if !HAVE(NETWORK_LOADER)
return false;
#else

[[maybe_unused]] const auto isSafari =
#if PLATFORM(MAC)
MacApplication::isSafari();
#elif PLATFORM(IOS_FAMILY)
WebCore::IOSApplication::isMobileSafari() || WebCore::IOSApplication::isSafariViewService();
#else
false;
#endif

if (auto isEnabled = optionalExperimentalFeatureEnabled(WebPreferencesKey::cFNetworkNetworkLoaderEnabledKey(), std::nullopt))
return isEnabled;
if (!linkedOnOrAfterSDKWithBehavior(SDKAlignedBehavior::UseCFNetworkNetworkLoader))
return std::nullopt;
#if defined(NW_SETTINGS_HAS_UNIFIED_HTTP)
if (isRunningTest(WebCore::applicationBundleIdentifier()))
return true;
if (nw_settings_get_unified_http_enabled())
return isSafari;
#endif
return std::nullopt;

#endif // NETWORK_LOADER
}

void WebsiteDataStore::platformInitialize()
Expand Down

0 comments on commit 9fdc371

Please sign in to comment.