Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
NetworkDataTaskCocoa and NetworkSessionCocoa should use public method…
…s instead of being friends

https://bugs.webkit.org/show_bug.cgi?id=204242

Patch by Alex Christensen <achristensen@webkit.org> on 2019-12-12
Reviewed by Chris Dumez.

This makes them stay good abstractions, and probably could make a good meme about not having any friends.

* NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTaskCocoa::applySniffingPoliciesAndBindRequestToInferfaceIfNeeded):
* NetworkProcess/cocoa/NetworkSessionCocoa.h:

Canonical link: https://commits.webkit.org/218373@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253449 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Alex Christensen authored and webkit-commit-queue committed Dec 12, 2019
1 parent 7a7b0de commit 77390a2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
14 changes: 14 additions & 0 deletions Source/WebKit/ChangeLog
@@ -1,3 +1,17 @@
2019-12-12 Alex Christensen <achristensen@webkit.org>

NetworkDataTaskCocoa and NetworkSessionCocoa should use public methods instead of being friends
https://bugs.webkit.org/show_bug.cgi?id=204242

Reviewed by Chris Dumez.

This makes them stay good abstractions, and probably could make a good meme about not having any friends.

* NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTaskCocoa::applySniffingPoliciesAndBindRequestToInferfaceIfNeeded):
* NetworkProcess/cocoa/NetworkSessionCocoa.h:

2019-12-12 Per Arne Vollan <pvollan@apple.com>

[iOS] Deny mach lookup access to content filter service in the WebContent sandbox
Expand Down
1 change: 0 additions & 1 deletion Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h
Expand Up @@ -41,7 +41,6 @@ class NetworkSessionCocoa;
struct SessionWrapper;

class NetworkDataTaskCocoa final : public NetworkDataTask {
friend class NetworkSessionCocoa;
public:
static Ref<NetworkDataTask> create(NetworkSession& session, NetworkDataTaskClient& client, const WebCore::ResourceRequest& request, WebCore::FrameIdentifier frameID, WebCore::PageIdentifier pageID, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, WebCore::ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy shouldContentEncodingSniff, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly shouldPreconnectOnly, bool dataTaskIsForMainFrameNavigation, bool dataTaskIsForMainResourceNavigationForAnyFrame, Optional<NetworkActivityTracker> networkActivityTracker)
{
Expand Down
14 changes: 8 additions & 6 deletions Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm
Expand Up @@ -94,12 +94,14 @@ static float toNSURLSessionTaskPriority(WebCore::ResourceLoadPriority priority)
#endif

auto& cocoaSession = static_cast<NetworkSessionCocoa&>(*m_session);
auto& boundInterfaceIdentifier = cocoaSession.boundInterfaceIdentifier();
auto* proxyConfiguration = cocoaSession.proxyConfiguration();
if (shouldContentSniff
#if USE(CFNETWORK_CONTENT_ENCODING_SNIFFING_OVERRIDE)
&& shouldContentEncodingSniff
#endif
&& cocoaSession.m_boundInterfaceIdentifier.isNull()
&& !cocoaSession.m_proxyConfiguration)
&& boundInterfaceIdentifier.isNull()
&& !proxyConfiguration)
return;

auto mutableRequest = adoptNS([nsRequest mutableCopy]);
Expand All @@ -112,11 +114,11 @@ static float toNSURLSessionTaskPriority(WebCore::ResourceLoadPriority priority)
if (!shouldContentSniff)
[mutableRequest _setProperty:@NO forKey:(NSString *)_kCFURLConnectionPropertyShouldSniff];

if (!cocoaSession.m_boundInterfaceIdentifier.isNull())
[mutableRequest setBoundInterfaceIdentifier:cocoaSession.m_boundInterfaceIdentifier];
if (!boundInterfaceIdentifier.isNull())
[mutableRequest setBoundInterfaceIdentifier:boundInterfaceIdentifier];

if (cocoaSession.m_proxyConfiguration)
CFURLRequestSetProxySettings([mutableRequest _CFURLRequest], cocoaSession.m_proxyConfiguration.get());
if (proxyConfiguration)
CFURLRequestSetProxySettings([mutableRequest _CFURLRequest], proxyConfiguration);

nsRequest = mutableRequest.autorelease();
}
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h
Expand Up @@ -61,7 +61,6 @@ struct SessionWrapper : public CanMakeWeakPtr<SessionWrapper> {
};

class NetworkSessionCocoa final : public NetworkSession {
friend class NetworkDataTaskCocoa;
public:
static std::unique_ptr<NetworkSession> create(NetworkProcess&, NetworkSessionCreationParameters&&);

Expand Down Expand Up @@ -94,12 +93,13 @@ class NetworkSessionCocoa final : public NetworkSession {
bool hasIsolatedSession(const WebCore::RegistrableDomain) const override;
void clearIsolatedSessions() override;

SessionWrapper& sessionWrapperForTask(const WebCore::ResourceRequest&, WebCore::StoredCredentialsPolicy);

private:
void invalidateAndCancel() override;
void clearCredentials() override;
bool shouldLogCookieInformation() const override { return m_shouldLogCookieInformation; }
Seconds loadThrottleLatency() const override { return m_loadThrottleLatency; }
SessionWrapper& sessionWrapperForTask(const WebCore::ResourceRequest&, WebCore::StoredCredentialsPolicy);
SessionWrapper& isolatedSession(WebCore::StoredCredentialsPolicy, const WebCore::RegistrableDomain);

#if HAVE(NSURLSESSION_WEBSOCKET)
Expand Down

0 comments on commit 77390a2

Please sign in to comment.