Bug 154984 - Use NetworkSession for pings when using NetworkSession
Summary: Use NetworkSession for pings when using NetworkSession
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-03 15:26 PST by Alex Christensen
Modified: 2016-03-05 18:48 PST (History)
3 users (show)

See Also:


Attachments
Patch (10.55 KB, patch)
2016-03-03 15:28 PST, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (10.46 KB, patch)
2016-03-03 15:58 PST, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (10.50 KB, patch)
2016-03-03 22:01 PST, Alex Christensen
koivisto: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2016-03-03 15:26:02 PST
Use NetworkSession for pings when using NetworkSession
Comment 1 Alex Christensen 2016-03-03 15:28:38 PST
Created attachment 272779 [details]
Patch
Comment 2 Alex Christensen 2016-03-03 15:58:17 PST
Created attachment 272786 [details]
Patch
Comment 3 Darin Adler 2016-03-03 21:23:29 PST
Comment on attachment 272786 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=272786&action=review

> Source/WebKit2/NetworkProcess/PingLoad.h:71
> +    virtual void willPerformHTTPRedirection(const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, RedirectCompletionHandler completionHandler)
> +    {
> +        completionHandler({ });
> +        delete this;
> +    }
> +    virtual void didReceiveChallenge(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler completionHandler)
> +    {
> +        completionHandler(AuthenticationChallengeDisposition::Cancel, { });
> +        delete this;
> +    }
> +    virtual void didReceiveResponseNetworkSession(const WebCore::ResourceResponse&, ResponseCompletionHandler completionHandler)
> +    {
> +        completionHandler(WebCore::PolicyAction::PolicyIgnore);
> +        delete this;
> +    }
> +    virtual void didReceiveData(RefPtr<WebCore::SharedBuffer>&&) { ASSERT_NOT_REACHED(); }
> +    virtual void didCompleteWithError(const WebCore::ResourceError&) { delete this; }
> +    virtual void didBecomeDownload() { ASSERT_NOT_REACHED(); }
> +    virtual void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) { ASSERT_NOT_REACHED(); }
> +    virtual void wasBlocked() { delete this; }
> +    virtual void cannotShowURL() { delete this; }

These should all be marked override, and not virtual.
Comment 4 Alex Christensen 2016-03-03 22:01:23 PST
Created attachment 272833 [details]
Patch
Comment 5 Alex Christensen 2016-03-03 22:47:09 PST
Comment on attachment 272833 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=272833&action=review

> Source/WebKit2/NetworkProcess/PingLoad.h:69
> +    void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) override { ASSERT_NOT_REACHED(); }

This assertion was being hit in many tests.  Will commit without it if reviewed.
Comment 6 Antti Koivisto 2016-03-04 09:56:54 PST
Comment on attachment 272833 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=272833&action=review

> Source/WebKit2/ChangeLog:3
> +        Use NetworkSession for pings when using NetworkSession

The title could be reformulated with just one 'NetworkSession'

> Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp:145
>      RefPtr<NetworkingContext> context = RemoteNetworkingContext::create(loadParameters.sessionID, loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect);
>  
> +#if USE(NETWORK_SESSION)
> +    // PingLoad manages its own lifetime, deleting itself when its purpose has been fulfilled.
> +    new PingLoad(loadParameters);
> +#else
>      // PingHandle manages its own lifetime, deleting itself when its purpose has been fulfilled.
>      new PingHandle(context.get(), loadParameters.request, loadParameters.allowStoredCredentials == AllowStoredCredentials, PingHandle::UsesAsyncCallbacks::Yes);
> +#endif

RemoteNetworkingContext doesn't seems to be used in USE(NETWORK_SESSION) path. It should be moved inside the #else branch.
Comment 7 Alex Christensen 2016-03-04 10:01:59 PST
http://trac.webkit.org/changeset/197568
Comment 8 Darin Adler 2016-03-05 18:48:42 PST
Comment on attachment 272833 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=272833&action=review

> Source/WebKit2/NetworkProcess/PingLoad.h:34
> +class PingLoad : public NetworkDataTaskClient {

Should mark the class final. Also, I think that it could be private inheritance rather than public.

> Source/WebKit2/NetworkProcess/PingLoad.h:36
> +    PingLoad(const NetworkResourceLoadParameters& parameters)

Typically we’d want to mark this explicit.

Also, in a class that deletes itself like this, I think it’s better to only expose a static member function to trigger this load and not return the pointer. That way the caller doesn’t have to write what looks like incorrect code.

> Source/WebKit2/NetworkProcess/PingLoad.h:37
> +        : m_timeoutTimer(*this, &PingLoad::timeoutTimerFired)

I new code, a bit more elegant to write this with a lambda:

    : m_timeoutTimer(*this, [this]() {
        delete this;
    })

> Source/WebKit2/NetworkProcess/PingLoad.h:43
> +        if (auto* networkSession = SessionTracker::networkSession(parameters.sessionID)) {
> +            m_task = NetworkDataTask::create(*networkSession, *this, parameters.request, parameters.allowStoredCredentials, parameters.contentSniffingPolicy, parameters.shouldClearReferrerOnHTTPSToHTTPRedirect);
> +            m_task->resume();
> +        } else
> +            ASSERT_NOT_REACHED();

The if does us no good. If you really want an assertion then I’d just write:

    auto* networkSession = SessionTracker::networkSession(parameters.sessionID);
    ASSERT(networkSession);
    ...

But I’d suggest not bothering with the assertion.