Skip to content

Commit

Permalink
Unreviewed, fix the build after rdar://115730279
Browse files Browse the repository at this point in the history
After the changes for rdar://115730279, libnetcore's `nw_proxy_config_create_with_agent_data` now
takes an additional nullable outparam. Add a compile-time guard for this version of the SPI, and
use it to soft link (and call the soft-linked function) with or without this extra argument.

* Source/WTF/wtf/PlatformHave.h:
* Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(WebKit::NetworkSessionCocoa::setProxyConfigData):

Canonical link: https://commits.webkit.org/269221@main
  • Loading branch information
whsieh committed Oct 11, 2023
1 parent 44000a3 commit 871bf5d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Source/WTF/wtf/PlatformHave.h
Original file line number Diff line number Diff line change
Expand Up @@ -1643,3 +1643,11 @@
|| (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 170000)
#define HAVE_NSURL_ENCODING_INVALID_CHARACTERS 1
#endif

#if ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 140200) \
|| ((PLATFORM(MACCATALYST) || PLATFORM(IOS)) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170200) \
|| (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MAX_ALLOWED >= 100200) \
|| (PLATFORM(APPLETV) && __TV_OS_VERSION_MAX_ALLOWED >= 170200) \
|| (PLATFORM(VISION) && __XR_OS_VERSION_MAX_ALLOWED >= 10200))
#define HAVE_PROXY_CONFIG_CREATE_WITH_AGENT_DATA_WITH_RETURN_IS_COMPLETE 1
#endif
10 changes: 9 additions & 1 deletion Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@
SOFT_LINK_LIBRARY_OPTIONAL(libnetwork)
SOFT_LINK_OPTIONAL(libnetwork, nw_context_add_proxy, void, __cdecl, (nw_context_t, nw_proxy_config_t))
SOFT_LINK_OPTIONAL(libnetwork, nw_context_clear_proxies, void, __cdecl, (nw_context_t))
#if HAVE(PROXY_CONFIG_CREATE_WITH_AGENT_DATA_WITH_RETURN_IS_COMPLETE)
SOFT_LINK_OPTIONAL(libnetwork, nw_proxy_config_create_with_agent_data, nw_proxy_config_t, __cdecl, (const uint8_t*, size_t, const uuid_t, bool*))
#else
SOFT_LINK_OPTIONAL(libnetwork, nw_proxy_config_create_with_agent_data, nw_proxy_config_t, __cdecl, (const uint8_t*, size_t, const uuid_t))
#endif
SOFT_LINK_OPTIONAL(libnetwork, nw_proxy_config_stack_requires_http_protocols, bool, __cdecl, (nw_proxy_config_t))
#endif

Expand Down Expand Up @@ -2216,7 +2220,11 @@ void didCompleteWithError(const WebCore::ResourceError& error, const WebCore::Ne
memcpy(identifier, config.second.toSpan().data(), sizeof(uuid_t));

#if __has_include(<Network/proxy_config_private.h>)
auto nwProxyConfig = adoptNS(createProxyConfig(config.first.data(), config.first.size(), identifier));
auto nwProxyConfig = adoptNS(createProxyConfig(config.first.data(), config.first.size(), identifier
#if HAVE(PROXY_CONFIG_CREATE_WITH_AGENT_DATA_WITH_RETURN_IS_COMPLETE)
, nullptr
#endif
));

if (requiresHTTPProtocols(nwProxyConfig.get()))
recreateSessions = true;
Expand Down

0 comments on commit 871bf5d

Please sign in to comment.