Changeset 222739 in webkit


Ignore:
Timestamp:
Oct 2, 2017 1:24:10 PM (7 years ago)
Author:
Joseph Pecoraro
Message:

Web Inspector: Include Beacon and Ping requests in Network tab
https://bugs.webkit.org/show_bug.cgi?id=177641
<rdar://problem/33086839>

Reviewed by Chris Dumez.

Source/JavaScriptCore:

  • inspector/protocol/Page.json:

Include new "Beacon" and "Ping" resource types.

Source/WebCore:

Tests: http/tests/inspector/network/beacon-type.html

http/tests/inspector/network/ping-type.html

  • Modules/beacon/NavigatorBeacon.cpp:

(WebCore::NavigatorBeacon::sendBeacon):
Fix a typo.

  • loader/PingLoader.cpp:

(WebCore::PingLoader::startPingLoad):

  • loader/cache/CachedResource.cpp:

(WebCore::CachedResource::load):
Include InspectorInstrumentation hooks for ping network loads.

  • loader/LoaderStrategy.h:
  • platform/network/PingHandle.h:

Include an optional ResourceResponse in the ping load completion callback.
If available this will be enough for Web Inspector to include details such
as the response statusCode.

  • inspector/InspectorInstrumentation.cpp:

(WebCore::InspectorInstrumentation::willSendRequestOfTypeImpl):
(WebCore::InspectorInstrumentation::continueAfterPingLoaderImpl): Deleted.

  • inspector/InspectorInstrumentation.h:

(WebCore::InspectorInstrumentation::willSendRequestOfType):
(WebCore::InspectorInstrumentation::continueAfterPingLoader): Deleted.

  • inspector/InspectorNetworkAgent.cpp:

(WebCore::resourceTypeForCachedResource):
(WebCore::resourceTypeForLoadType):
(WebCore::InspectorNetworkAgent::willSendRequest):
(WebCore::InspectorNetworkAgent::willSendRequestOfType):

  • inspector/InspectorNetworkAgent.h:

Make a general willSendRequestOfType hook when sending a request that does
not go through normal CachedResource loading. The Ping and Beacon requests
go through this process, we may also use this path for Preflight requests.

  • inspector/InspectorPageAgent.cpp:

(WebCore::InspectorPageAgent::resourceTypeJson):
(WebCore::InspectorPageAgent::cachedResourceType):

  • inspector/InspectorPageAgent.h:

Small refactoring.

Source/WebInspectorUI:

  • Localizations/en.lproj/localizedStrings.js:

New strings for Beacon/Ping.

  • UserInterface/Images/Beacon.svg: Added.
  • UserInterface/Views/ResourceIcons.css:

(.resource-icon.resource-type-ping .icon,):
(body:not(.mac-platform, .windows-platform) .resource-icon.resource-type-ping .icon,):
(body:not(.mac-platform, .windows-platform) .large .resource-icon.resource-type-ping .icon,):
New icon for Beacon/Ping. They share an icon since they are similiar in concept:
a request that is sent and the page doesn't expect a response.

  • UserInterface/Controllers/FrameResourceManager.js:

(WI.FrameResourceManager.prototype._addNewResourceToFrameOrTarget):
When a sub-resource and a main-resource have the same URL we were not
distinguishing them. Use the resource type to distinguish them better.

  • UserInterface/Models/SourceCode.js:

(WI.SourceCode.prototype._processContent):
Safer handling if the body was base64 encoded but an empty string.

  • UserInterface/Models/Resource.js:

(WI.Resource.displayNameForType):

  • UserInterface/Models/ResourceCollection.js:

(WI.ResourceCollection.verifierForType):

  • UserInterface/Views/NetworkTableContentView.js:

(WI.NetworkTableContentView.shortDisplayNameForResourceType):

  • UserInterface/Views/ResourceClusterContentView.js:

(WI.ResourceClusterContentView.prototype.get responseContentView):
New resource types.

  • UserInterface/Views/ResourceContentView.js:

(WI.ResourceContentView.prototype.showMessage):

  • UserInterface/Views/TextResourceContentView.js:

(WI.TextResourceContentView.prototype._contentDidPopulate):
Nicer display for empty content, which may be common for these requests.

Source/WebKit:

  • NetworkProcess/NetworkConnectionToWebProcess.cpp:

(WebKit::NetworkConnectionToWebProcess::loadPing):
(WebKit::NetworkConnectionToWebProcess::didFinishPingLoad):

  • NetworkProcess/NetworkConnectionToWebProcess.h:
  • NetworkProcess/PingLoad.cpp:

(WebKit::PingLoad::PingLoad):
(WebKit::PingLoad::didFinish):
(WebKit::PingLoad::didReceiveResponseNetworkSession):

  • NetworkProcess/PingLoad.h:
  • WebProcess/Network/NetworkProcessConnection.cpp:

(WebKit::NetworkProcessConnection::didFinishPingLoad):

  • WebProcess/Network/NetworkProcessConnection.h:
  • WebProcess/Network/NetworkProcessConnection.messages.in:
  • WebProcess/Network/WebLoaderStrategy.cpp:

(WebKit::WebLoaderStrategy::networkProcessCrashed):
(WebKit::WebLoaderStrategy::startPingLoad):
(WebKit::WebLoaderStrategy::didFinishPingLoad):

  • WebProcess/Network/WebLoaderStrategy.h:

Pass an optional ResourceResponse back to the ping completion handler.

LayoutTests:

  • http/tests/inspector/network/beacon-type-expected.txt: Added.
  • http/tests/inspector/network/beacon-type.html: Added.
  • http/tests/inspector/network/ping-type-expected.txt: Added.
  • http/tests/inspector/network/ping-type.html: Added.
  • http/tests/inspector/network/resources/beacon.php: Added.
  • http/tests/inspector/network/resources/ping.php: Added.

Test for Beacon and Ping resource loads.

  • platform/mac-wk1/TestExpectations:
  • platform/mac-wk2/TestExpectations:
  • platform/win/TestExpectations:

Skip beacon tests where beacon is not supported.

Location:
trunk
Files:
7 added
40 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r222734 r222739  
     12017-10-02  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Include Beacon and Ping requests in Network tab
     4        https://bugs.webkit.org/show_bug.cgi?id=177641
     5        <rdar://problem/33086839>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * http/tests/inspector/network/beacon-type-expected.txt: Added.
     10        * http/tests/inspector/network/beacon-type.html: Added.
     11        * http/tests/inspector/network/ping-type-expected.txt: Added.
     12        * http/tests/inspector/network/ping-type.html: Added.
     13        * http/tests/inspector/network/resources/beacon.php: Added.
     14        * http/tests/inspector/network/resources/ping.php: Added.
     15        Test for Beacon and Ping resource loads.
     16
     17        * platform/mac-wk1/TestExpectations:
     18        * platform/mac-wk2/TestExpectations:
     19        * platform/win/TestExpectations:
     20        Skip beacon tests where beacon is not supported.
     21
    1222017-10-02  Jiewen Tan  <jiewen_tan@apple.com>
    223
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r222626 r222739  
    373373# Beacon is not supported on WK1.
    374374http/tests/blink/sendbeacon/ [ Skip ]
     375http/tests/inspector/network/beacon-type.html [ Skip ]
    375376http/wpt/beacon/ [ Skip ]
    376377imported/blink/fast/beacon/ [ Skip ]
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r222734 r222739  
    725725# Beacon is not supported on WK2 for the non NETWORK_SESSION code path.
    726726[ ElCapitan ] http/tests/blink/sendbeacon/ [ Skip ]
     727[ ElCapitan ] http/tests/inspector/network/beacon-type.html [ Skip ]
    727728[ ElCapitan ] http/wpt/beacon/ [ Skip ]
    728729[ ElCapitan ] imported/blink/fast/beacon/ [ Skip ]
  • trunk/LayoutTests/platform/mac/TestExpectations

    r222605 r222739  
    14311431[ ElCapitan ] http/tests/inspector/network/resource-request-headers.html [ Failure ]
    14321432
     1433[ ElCapitan ] http/tests/inspector/network/ping-type.html [ Skip ]
     1434
    14331435# <rdar://problem/30610988>
    14341436[ Sierra+ ] imported/w3c/web-platform-tests/fetch/api/redirect/redirect-count-cross-origin.html [ Failure ]
  • trunk/LayoutTests/platform/win/TestExpectations

    r222635 r222739  
    36813681# Beacon is not supported on WK1.
    36823682http/tests/blink/sendbeacon/ [ Skip ]
     3683http/tests/inspector/network/beacon-type.html [ Skip ]
    36833684http/wpt/beacon/ [ Skip ]
    36843685imported/blink/fast/beacon/ [ Skip ]
  • trunk/Source/JavaScriptCore/ChangeLog

    r222724 r222739  
     12017-10-02  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Include Beacon and Ping requests in Network tab
     4        https://bugs.webkit.org/show_bug.cgi?id=177641
     5        <rdar://problem/33086839>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * inspector/protocol/Page.json:
     10        Include new "Beacon" and "Ping" resource types.
     11
    1122017-10-02  Caio Lima  <ticaiolima@gmail.com>
    213
  • trunk/Source/JavaScriptCore/inspector/protocol/Page.json

    r222560 r222739  
    77            "id": "ResourceType",
    88            "type": "string",
    9             "enum": ["Document", "Stylesheet", "Image", "Font", "Script", "XHR", "Fetch", "WebSocket", "Other"],
     9            "enum": ["Document", "Stylesheet", "Image", "Font", "Script", "XHR", "Fetch", "Ping", "Beacon", "WebSocket", "Other"],
    1010            "description": "Resource type as it was perceived by the rendering engine."
    1111        },
  • trunk/Source/WebCore/ChangeLog

    r222738 r222739  
     12017-10-02  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Include Beacon and Ping requests in Network tab
     4        https://bugs.webkit.org/show_bug.cgi?id=177641
     5        <rdar://problem/33086839>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Tests: http/tests/inspector/network/beacon-type.html
     10               http/tests/inspector/network/ping-type.html
     11
     12        * Modules/beacon/NavigatorBeacon.cpp:
     13        (WebCore::NavigatorBeacon::sendBeacon):
     14        Fix a typo.
     15
     16        * loader/PingLoader.cpp:
     17        (WebCore::PingLoader::startPingLoad):
     18        * loader/cache/CachedResource.cpp:
     19        (WebCore::CachedResource::load):
     20        Include InspectorInstrumentation hooks for ping network loads.
     21
     22        * loader/LoaderStrategy.h:
     23        * platform/network/PingHandle.h:
     24        Include an optional ResourceResponse in the ping load completion callback.
     25        If available this will be enough for Web Inspector to include details such
     26        as the response statusCode.
     27
     28        * inspector/InspectorInstrumentation.cpp:
     29        (WebCore::InspectorInstrumentation::willSendRequestOfTypeImpl):
     30        (WebCore::InspectorInstrumentation::continueAfterPingLoaderImpl): Deleted.
     31        * inspector/InspectorInstrumentation.h:
     32        (WebCore::InspectorInstrumentation::willSendRequestOfType):
     33        (WebCore::InspectorInstrumentation::continueAfterPingLoader): Deleted.
     34        * inspector/InspectorNetworkAgent.cpp:
     35        (WebCore::resourceTypeForCachedResource):
     36        (WebCore::resourceTypeForLoadType):
     37        (WebCore::InspectorNetworkAgent::willSendRequest):
     38        (WebCore::InspectorNetworkAgent::willSendRequestOfType):
     39        * inspector/InspectorNetworkAgent.h:
     40        Make a general willSendRequestOfType hook when sending a request that does
     41        not go through normal CachedResource loading. The Ping and Beacon requests
     42        go through this process, we may also use this path for Preflight requests.
     43
     44        * inspector/InspectorPageAgent.cpp:
     45        (WebCore::InspectorPageAgent::resourceTypeJson):
     46        (WebCore::InspectorPageAgent::cachedResourceType):
     47        * inspector/InspectorPageAgent.h:
     48        Small refactoring.
     49
    1502017-10-02  Zalan Bujtas  <zalan@apple.com>
    251
  • trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp

    r221329 r222739  
    104104
    105105    // Set parsedUrl to the result of the URL parser steps with url and base. If the algorithm returns an error, or if
    106     // parsedUrl's scheme is not "http" or "https", throw a " TypeError" exception and terminate these steps.
     106    // parsedUrl's scheme is not "http" or "https", throw a "TypeError" exception and terminate these steps.
    107107    if (!parsedUrl.isValid())
    108108        return Exception { TypeError, ASCIILiteral("This URL is invalid") };
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r222560 r222739  
    3333#include "InspectorInstrumentation.h"
    3434
     35#include "CachedResource.h"
    3536#include "DOMWindow.h"
    3637#include "DOMWrapperWorld.h"
     
    561562}
    562563
    563 void InspectorInstrumentation::continueAfterPingLoaderImpl(InstrumentingAgents& instrumentingAgents, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& response)
    564 {
    565     willSendRequestImpl(instrumentingAgents, identifier, loader, request, response);
     564void InspectorInstrumentation::willSendRequestOfTypeImpl(InstrumentingAgents& instrumentingAgents, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, LoadType loadType)
     565{
     566    if (!loader)
     567        return;
     568
     569    if (InspectorNetworkAgent* networkAgent = instrumentingAgents.inspectorNetworkAgent())
     570        networkAgent->willSendRequestOfType(identifier, *loader, request, loadType);
    566571}
    567572
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r222064 r222739  
    171171    static void applyEmulatedMedia(Frame&, String&);
    172172    static void willSendRequest(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
    173     static void continueAfterPingLoader(Frame&, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse&);
    174173    static void didLoadResourceFromMemoryCache(Page&, DocumentLoader*, CachedResource*);
    175174    static void didReceiveResourceResponse(Frame&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
     
    181180    static void continueWithPolicyDownload(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);
    182181    static void continueWithPolicyIgnore(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);
     182
     183    // Some network requests do not go through the normal network loading path.
     184    // These network requests have to issue their own willSendRequest / didReceiveResponse / didFinishLoading / didFailLoading
     185    // instrumentation calls. Some of these loads are for resources that lack a CachedResource::Type.
     186    enum class LoadType { Ping, Beacon };
     187    static void willSendRequestOfType(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, LoadType);
    183188
    184189    static void didFinishXHRLoading(ScriptExecutionContext*, unsigned long identifier, std::optional<String> decodedText, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber);
     
    343348    static void applyEmulatedMediaImpl(InstrumentingAgents&, String&);
    344349    static void willSendRequestImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
    345     static void continueAfterPingLoaderImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse&);
     350    static void willSendRequestOfTypeImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, LoadType);
    346351    static void markResourceAsCachedImpl(InstrumentingAgents&, unsigned long identifier);
    347352    static void didLoadResourceFromMemoryCacheImpl(InstrumentingAgents&, DocumentLoader*, CachedResource*);
     
    891896}
    892897
    893 inline void InspectorInstrumentation::continueAfterPingLoader(Frame& frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& response)
    894 {
    895     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
    896         InspectorInstrumentation::continueAfterPingLoaderImpl(*instrumentingAgents, identifier, loader, request, response);
     898inline void InspectorInstrumentation::willSendRequestOfType(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, LoadType loadType)
     899{
     900    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
     901        willSendRequestOfTypeImpl(*instrumentingAgents, identifier, loader, request, loadType);
    897902}
    898903
  • trunk/Source/WebCore/inspector/InspectorNetworkAgent.cpp

    r221839 r222739  
    4444#include "HTTPHeaderMap.h"
    4545#include "HTTPHeaderNames.h"
    46 #include "InspectorPageAgent.h"
    4746#include "InspectorTimelineAgent.h"
    4847#include "InstrumentingAgents.h"
     
    182181{
    183182    Ref<InspectorObject> headersObject = InspectorObject::create();
    184    
     183
    185184    for (const auto& header : headers)
    186185        headersObject->setString(header.key, header.value);
     
    337336}
    338337
    339 void InspectorNetworkAgent::willSendRequest(unsigned long identifier, DocumentLoader& loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
     338void InspectorNetworkAgent::willSendRequest(unsigned long identifier, DocumentLoader& loader, ResourceRequest& request, const ResourceResponse& redirectResponse, InspectorPageAgent::ResourceType type)
    340339{
    341340    if (request.hiddenFromInspector()) {
     
    347346    m_resourcesData->resourceCreated(requestId, m_pageAgent->loaderId(&loader));
    348347
    349     CachedResource* cachedResource = InspectorPageAgent::cachedResource(loader.frame(), request.url());
    350     InspectorPageAgent::ResourceType type = cachedResource ? InspectorPageAgent::cachedResourceType(*cachedResource) : m_resourcesData->resourceType(requestId);
    351348    if (type == InspectorPageAgent::OtherResource) {
    352349        if (m_loadingXHRSynchronously)
     
    369366        request.setHTTPHeaderField(entry.key, entry.value);
    370367
    371     Inspector::Protocol::Page::ResourceType resourceType = InspectorPageAgent::resourceTypeJson(type);
     368    Inspector::Protocol::Page::ResourceType protocolResourceType = InspectorPageAgent::resourceTypeJson(type);
    372369
    373370    RefPtr<Inspector::Protocol::Network::Initiator> initiatorObject = buildInitiatorObject(loader.frame() ? loader.frame()->document() : nullptr);
    374371    String targetId = request.initiatorIdentifier();
    375372
    376     m_frontendDispatcher->requestWillBeSent(requestId, m_pageAgent->frameId(loader.frame()), m_pageAgent->loaderId(&loader), loader.url().string(), buildObjectForResourceRequest(request), timestamp(), initiatorObject, buildObjectForResourceResponse(redirectResponse, nullptr), type != InspectorPageAgent::OtherResource ? &resourceType : nullptr, targetId.isEmpty() ? nullptr : &targetId);
     373    m_frontendDispatcher->requestWillBeSent(requestId, m_pageAgent->frameId(loader.frame()), m_pageAgent->loaderId(&loader), loader.url().string(), buildObjectForResourceRequest(request), timestamp(), initiatorObject, buildObjectForResourceResponse(redirectResponse, nullptr), type != InspectorPageAgent::OtherResource ? &protocolResourceType : nullptr, targetId.isEmpty() ? nullptr : &targetId);
     374}
     375
     376static InspectorPageAgent::ResourceType resourceTypeForCachedResource(CachedResource* resource)
     377{
     378    if (resource)
     379        return InspectorPageAgent::inspectorResourceType(*resource);
     380    return InspectorPageAgent::OtherResource;
     381}
     382
     383static InspectorPageAgent::ResourceType resourceTypeForLoadType(InspectorInstrumentation::LoadType loadType)
     384{
     385    switch (loadType) {
     386    case InspectorInstrumentation::LoadType::Ping:
     387        return InspectorPageAgent::PingResource;
     388    case InspectorInstrumentation::LoadType::Beacon:
     389        return InspectorPageAgent::BeaconResource;
     390    }
     391
     392    ASSERT_NOT_REACHED();
     393    return InspectorPageAgent::OtherResource;
     394}
     395
     396void InspectorNetworkAgent::willSendRequest(unsigned long identifier, DocumentLoader& loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
     397{
     398    auto* cachedResource = InspectorPageAgent::cachedResource(loader.frame(), request.url());
     399    willSendRequest(identifier, loader, request, redirectResponse, resourceTypeForCachedResource(cachedResource));
     400}
     401
     402void InspectorNetworkAgent::willSendRequestOfType(unsigned long identifier, DocumentLoader& loader, ResourceRequest& request, InspectorInstrumentation::LoadType loadType)
     403{
     404    willSendRequest(identifier, loader, request, ResourceResponse(), resourceTypeForLoadType(loadType));
    377405}
    378406
     
    401429
    402430    InspectorPageAgent::ResourceType type = m_resourcesData->resourceType(requestId);
    403     InspectorPageAgent::ResourceType newType = cachedResource ? InspectorPageAgent::cachedResourceType(*cachedResource) : type;
     431    InspectorPageAgent::ResourceType newType = cachedResource ? InspectorPageAgent::inspectorResourceType(*cachedResource) : type;
    404432
    405433    // FIXME: XHRResource is returned for CachedResource::RawResource, it should be OtherResource unless it truly is an XHR.
  • trunk/Source/WebCore/inspector/InspectorNetworkAgent.h

    r220250 r222739  
    3232#pragma once
    3333
     34#include "InspectorInstrumentation.h"
     35#include "InspectorPageAgent.h"
    3436#include "InspectorWebAgentBase.h"
    3537#include <inspector/InspectorBackendDispatchers.h>
     
    5052class DocumentLoader;
    5153class DocumentThreadableLoader;
    52 class InspectorPageAgent;
    5354class NetworkLoadMetrics;
    5455class NetworkResourcesData;
     
    7778    void didRecalculateStyle();
    7879    void willSendRequest(unsigned long identifier, DocumentLoader&, ResourceRequest&, const ResourceResponse& redirectResponse);
     80    void willSendRequestOfType(unsigned long identifier, DocumentLoader&, ResourceRequest&, InspectorInstrumentation::LoadType);
    7981    void didReceiveResponse(unsigned long identifier, DocumentLoader&, const ResourceResponse&, ResourceLoader*);
    8082    void didReceiveData(unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
     
    116118    void enable();
    117119
     120    void willSendRequest(unsigned long identifier, DocumentLoader&, ResourceRequest&, const ResourceResponse& redirectResponse, InspectorPageAgent::ResourceType);
     121
    118122    WebSocket* webSocketForRequestId(const String& requestId);
    119123
  • trunk/Source/WebCore/inspector/InspectorPageAgent.cpp

    r222560 r222739  
    102102    // We should not assume XHR / Fetch have text content.
    103103
    104     InspectorPageAgent::ResourceType type = InspectorPageAgent::cachedResourceType(*cachedResource);
     104    InspectorPageAgent::ResourceType type = InspectorPageAgent::inspectorResourceType(*cachedResource);
    105105    return type == InspectorPageAgent::DocumentResource
    106106        || type == InspectorPageAgent::StylesheetResource
     
    264264    case FetchResource:
    265265        return Inspector::Protocol::Page::ResourceType::Fetch;
     266    case PingResource:
     267        return Inspector::Protocol::Page::ResourceType::Ping;
     268    case BeaconResource:
     269        return Inspector::Protocol::Page::ResourceType::Beacon;
    266270    case WebSocketResource:
    267271        return Inspector::Protocol::Page::ResourceType::WebSocket;
     
    272276}
    273277
    274 InspectorPageAgent::ResourceType InspectorPageAgent::cachedResourceType(const CachedResource& cachedResource)
    275 {
    276     switch (cachedResource.type()) {
     278InspectorPageAgent::ResourceType InspectorPageAgent::inspectorResourceType(CachedResource::Type type)
     279{
     280    switch (type) {
    277281    case CachedResource::ImageResource:
    278282        return InspectorPageAgent::ImageResource;
     
    291295    case CachedResource::MainResource:
    292296        return InspectorPageAgent::DocumentResource;
     297    case CachedResource::Beacon:
     298        return InspectorPageAgent::BeaconResource;
    293299    case CachedResource::MediaResource:
    294300    case CachedResource::Icon:
    295     case CachedResource::RawResource: {
     301    case CachedResource::RawResource:
     302    default:
     303        return InspectorPageAgent::OtherResource;
     304    }
     305}
     306
     307InspectorPageAgent::ResourceType InspectorPageAgent::inspectorResourceType(const CachedResource& cachedResource)
     308{
     309    if (cachedResource.type() == CachedResource::RawResource) {
    296310        switch (cachedResource.resourceRequest().requester()) {
    297311        case ResourceRequest::Requester::Fetch:
     
    303317        }
    304318    }
    305     default:
    306         break;
    307     }
    308     return InspectorPageAgent::OtherResource;
     319
     320    return inspectorResourceType(cachedResource.type());
    309321}
    310322
    311323Inspector::Protocol::Page::ResourceType InspectorPageAgent::cachedResourceTypeJson(const CachedResource& cachedResource)
    312324{
    313     return resourceTypeJson(cachedResourceType(cachedResource));
     325    return resourceTypeJson(inspectorResourceType(cachedResource));
    314326}
    315327
  • trunk/Source/WebCore/inspector/InspectorPageAgent.h

    r222560 r222739  
    3232#pragma once
    3333
     34#include "CachedResource.h"
    3435#include "InspectorWebAgentBase.h"
    3536#include "LayoutRect.h"
     
    4647namespace WebCore {
    4748
    48 class CachedResource;
    4949class DocumentLoader;
    5050class Frame;
     
    7474        XHRResource,
    7575        FetchResource,
     76        PingResource,
     77        BeaconResource,
    7678        WebSocketResource,
    7779        OtherResource,
     
    8587    static CachedResource* cachedResource(Frame*, const URL&);
    8688    static Inspector::Protocol::Page::ResourceType resourceTypeJson(ResourceType);
    87     static ResourceType cachedResourceType(const CachedResource&);
     89    static ResourceType inspectorResourceType(CachedResource::Type);
     90    static ResourceType inspectorResourceType(const CachedResource&);
    8891    static Inspector::Protocol::Page::ResourceType cachedResourceTypeJson(const CachedResource&);
    8992    static RefPtr<TextResourceDecoder> createTextDecoder(const String& mimeType, const String& textEncodingName);
  • trunk/Source/WebCore/loader/LoaderStrategy.h

    r222673 r222739  
    6666    virtual void resumePendingRequests() = 0;
    6767
    68     using PingLoadCompletionHandler = WTF::Function<void(const ResourceError&)>;
     68    using PingLoadCompletionHandler = WTF::Function<void(const ResourceError&, const ResourceResponse&)>;
    6969    virtual void startPingLoad(Frame&, ResourceRequest&, const HTTPHeaderMap& originalRequestHeaders, const FetchOptions&, PingLoadCompletionHandler&& = { }) = 0;
    7070
  • trunk/Source/WebCore/loader/PingLoader.cpp

    r222602 r222739  
    4242#include "InspectorInstrumentation.h"
    4343#include "LoaderStrategy.h"
     44#include "NetworkLoadMetrics.h"
    4445#include "Page.h"
    4546#include "PlatformStrategies.h"
     
    192193    unsigned long identifier = frame.page()->progress().createUniqueIdentifier();
    193194    // FIXME: Why activeDocumentLoader? I would have expected documentLoader().
    194     // Itseems like the PingLoader should be associated with the current
     195    // It seems like the PingLoader should be associated with the current
    195196    // Document in the Frame, but the activeDocumentLoader will be associated
    196197    // with the provisional DocumentLoader if there is a provisional
     
    201202    options.redirect = shouldFollowRedirects == ShouldFollowRedirects::Yes ? FetchOptions::Redirect::Follow : FetchOptions::Redirect::Error;
    202203
    203     InspectorInstrumentation::continueAfterPingLoader(frame, identifier, frame.loader().activeDocumentLoader(), request, ResourceResponse());
    204 
    205     platformStrategies()->loaderStrategy()->startPingLoad(frame, request, WTFMove(originalRequestHeaders), options);
    206 }
    207 
    208 }
     204    // FIXME: Move ping loads to normal subresource loading to get normal inspector request instrumentation hooks.
     205    InspectorInstrumentation::willSendRequestOfType(&frame, identifier, frame.loader().activeDocumentLoader(), request, InspectorInstrumentation::LoadType::Ping);
     206
     207    platformStrategies()->loaderStrategy()->startPingLoad(frame, request, WTFMove(originalRequestHeaders), options, [protectedFrame = makeRef(frame), identifier] (const ResourceError& error, const ResourceResponse& response) {
     208        if (!response.isNull())
     209            InspectorInstrumentation::didReceiveResourceResponse(protectedFrame, identifier, protectedFrame->loader().activeDocumentLoader(), response, nullptr);
     210        if (error.isNull()) {
     211            NetworkLoadMetrics emptyMetrics;
     212            InspectorInstrumentation::didFinishLoading(protectedFrame.ptr(), protectedFrame->loader().activeDocumentLoader(), identifier, emptyMetrics, nullptr);
     213        } else
     214            InspectorInstrumentation::didFailLoading(protectedFrame.ptr(), protectedFrame->loader().activeDocumentLoader(), identifier, error);
     215    });
     216}
     217
     218}
  • trunk/Source/WebCore/loader/cache/CachedResource.cpp

    r222467 r222739  
    3838#include "HTTPHeaderNames.h"
    3939#include "InspectorInstrumentation.h"
    40 #include "URL.h"
    4140#include "LoaderStrategy.h"
    4241#include "Logging.h"
     
    4443#include "MemoryCache.h"
    4544#include "PlatformStrategies.h"
     45#include "ProgressTracker.h"
    4646#include "ResourceHandle.h"
    4747#include "SchemeRegistry.h"
    4848#include "SecurityOrigin.h"
    4949#include "SubresourceLoader.h"
     50#include "URL.h"
    5051#include <wtf/CurrentTime.h>
    5152#include <wtf/MathExtras.h>
    5253#include <wtf/RefCountedLeakCounter.h>
    5354#include <wtf/StdLibExtras.h>
     55#include <wtf/Vector.h>
    5456#include <wtf/text/CString.h>
    55 #include <wtf/Vector.h>
    5657
    5758#if USE(QUICK_LOOK)
     
    271272            ASSERT(m_originalRequestHeaders);
    272273            CachedResourceHandle<CachedResource> protectedThis(this);
    273             platformStrategies()->loaderStrategy()->startPingLoad(frame, request, *m_originalRequestHeaders, m_options, [this, protectedThis = WTFMove(protectedThis)] (const ResourceError& error) {
    274                 if (error.isNull())
     274
     275            // FIXME: Move beacon loads to normal subresource loading to get normal inspector request instrumentation hooks.
     276            unsigned long identifier = frame.page()->progress().createUniqueIdentifier();
     277            InspectorInstrumentation::willSendRequestOfType(&frame, identifier, frameLoader.activeDocumentLoader(), request, InspectorInstrumentation::LoadType::Beacon);
     278
     279            platformStrategies()->loaderStrategy()->startPingLoad(frame, request, *m_originalRequestHeaders, m_options, [this, protectedThis = WTFMove(protectedThis), protectedFrame = makeRef(frame), identifier] (const ResourceError& error, const ResourceResponse& response) {
     280                if (!response.isNull())
     281                    InspectorInstrumentation::didReceiveResourceResponse(protectedFrame, identifier, protectedFrame->loader().activeDocumentLoader(), response, nullptr);
     282                if (error.isNull()) {
    275283                    finishLoading(nullptr);
    276                 else {
     284                    NetworkLoadMetrics emptyMetrics;
     285                    InspectorInstrumentation::didFinishLoading(protectedFrame.ptr(), protectedFrame->loader().activeDocumentLoader(), identifier, emptyMetrics, nullptr);
     286                } else {
    277287                    setResourceError(error);
    278288                    this->error(LoadError);
     289                    InspectorInstrumentation::didFailLoading(protectedFrame.ptr(), protectedFrame->loader().activeDocumentLoader(), identifier, error);
    279290                }
    280291            });
  • trunk/Source/WebCore/platform/network/PingHandle.h

    r222570 r222739  
    4545    };
    4646   
    47     PingHandle(NetworkingContext* networkingContext, const ResourceRequest& request, bool shouldUseCredentialStorage, UsesAsyncCallbacks useAsyncCallbacks, bool shouldFollowRedirects, WTF::CompletionHandler<void(const ResourceError&)>&& completionHandler)
     47    PingHandle(NetworkingContext* networkingContext, const ResourceRequest& request, bool shouldUseCredentialStorage, UsesAsyncCallbacks useAsyncCallbacks, bool shouldFollowRedirects, WTF::CompletionHandler<void(const ResourceError&, const ResourceResponse&)>&& completionHandler)
    4848        : m_currentRequest(request)
    4949        , m_timeoutTimer(*this, &PingHandle::timeoutTimerFired)
     
    7474        pingLoadComplete(ResourceError { String(), 0, m_currentRequest.url(), ASCIILiteral("Not allowed to follow redirects"), ResourceError::Type::AccessControl });
    7575    }
    76     void didReceiveResponse(ResourceHandle*, ResourceResponse&&) final { pingLoadComplete(); }
     76    void didReceiveResponse(ResourceHandle*, ResourceResponse&& response) final { pingLoadComplete({ }, response); }
    7777    void didReceiveBuffer(ResourceHandle*, Ref<SharedBuffer>&&, int) final { pingLoadComplete(); }
    7878    void didFinishLoading(ResourceHandle*) final { pingLoadComplete(); }
     
    8282    void timeoutTimerFired() { pingLoadComplete(ResourceError { String(), 0, m_currentRequest.url(), ASCIILiteral("Load timed out"), ResourceError::Type::Timeout }); }
    8383
    84     void pingLoadComplete(const ResourceError& error = { })
     84    void pingLoadComplete(const ResourceError& error = { }, const ResourceResponse& response = { })
    8585    {
    8686        if (auto completionHandler = std::exchange(m_completionHandler, nullptr))
    87             completionHandler(error);
     87            completionHandler(error, response);
    8888        delete this;
    8989    }
     
    105105    bool m_shouldFollowRedirects;
    106106    UsesAsyncCallbacks m_usesAsyncCallbacks;
    107     WTF::CompletionHandler<void(const ResourceError&)> m_completionHandler;
     107    WTF::CompletionHandler<void(const ResourceError&, const ResourceResponse&)> m_completionHandler;
    108108};
    109109
  • trunk/Source/WebInspectorUI/ChangeLog

    r222678 r222739  
     12017-10-02  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Include Beacon and Ping requests in Network tab
     4        https://bugs.webkit.org/show_bug.cgi?id=177641
     5        <rdar://problem/33086839>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * Localizations/en.lproj/localizedStrings.js:
     10        New strings for Beacon/Ping.
     11
     12        * UserInterface/Images/Beacon.svg: Added.
     13        * UserInterface/Views/ResourceIcons.css:
     14        (.resource-icon.resource-type-ping .icon,):
     15        (body:not(.mac-platform, .windows-platform) .resource-icon.resource-type-ping .icon,):
     16        (body:not(.mac-platform, .windows-platform) .large .resource-icon.resource-type-ping .icon,):
     17        New icon for Beacon/Ping. They share an icon since they are similiar in concept:
     18        a request that is sent and the page doesn't expect a response.
     19
     20        * UserInterface/Controllers/FrameResourceManager.js:
     21        (WI.FrameResourceManager.prototype._addNewResourceToFrameOrTarget):
     22        When a sub-resource and a main-resource have the same URL we were not
     23        distinguishing them. Use the resource type to distinguish them better.
     24
     25        * UserInterface/Models/SourceCode.js:
     26        (WI.SourceCode.prototype._processContent):
     27        Safer handling if the body was base64 encoded but an empty string.
     28
     29        * UserInterface/Models/Resource.js:
     30        (WI.Resource.displayNameForType):
     31        * UserInterface/Models/ResourceCollection.js:
     32        (WI.ResourceCollection.verifierForType):
     33        * UserInterface/Views/NetworkTableContentView.js:
     34        (WI.NetworkTableContentView.shortDisplayNameForResourceType):
     35        * UserInterface/Views/ResourceClusterContentView.js:
     36        (WI.ResourceClusterContentView.prototype.get responseContentView):
     37        New resource types.
     38
     39        * UserInterface/Views/ResourceContentView.js:
     40        (WI.ResourceContentView.prototype.showMessage):
     41        * UserInterface/Views/TextResourceContentView.js:
     42        (WI.TextResourceContentView.prototype._contentDidPopulate):
     43        Nicer display for empty content, which may be common for these requests.
     44
    1452017-09-29  Nikita Vasilyev  <nvasilyev@apple.com>
    246
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r222573 r222739  
    125125localizedStrings["Background"] = "Background";
    126126localizedStrings["Basis"] = "Basis";
     127localizedStrings["Beacon"] = "Beacon";
     128localizedStrings["Beacons"] = "Beacons";
    127129localizedStrings["Bezier"] = "Bezier";
    128130localizedStrings["Binary Frame"] = "Binary Frame";
     
    652654localizedStrings["Pause Reason"] = "Pause Reason";
    653655localizedStrings["Pause script execution (%s or %s)"] = "Pause script execution (%s or %s)";
     656localizedStrings["Ping"] = "Ping";
    654657localizedStrings["Ping Frame"] = "Ping Frame";
     658localizedStrings["Pings"] = "Pings";
    655659localizedStrings["Play Sound"] = "Play Sound";
    656660localizedStrings["Polite"] = "Polite";
     
    719723localizedStrings["Resource Type"] = "Resource Type";
    720724localizedStrings["Resource failed to load."] = "Resource failed to load.";
     725localizedStrings["Resource has no content"] = "Resource has no content";
    721726localizedStrings["Resource was loaded with the “data“ scheme."] = "Resource was loaded with the “data“ scheme.";
    722727localizedStrings["Resource was served from the cache."] = "Resource was served from the cache.";
     
    982987localizedStrings["line "] = "line ";
    983988localizedStrings["originally %s"] = "originally %s";
     989localizedStrings["ping"] = "ping";
    984990localizedStrings["popup"] = "popup";
    985991localizedStrings["popup, toggle"] = "popup, toggle";
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js

    r220119 r222739  
    503503        if (frame) {
    504504            // This is a new request for an existing frame, which might be the main resource or a new resource.
    505             if (frame.mainResource.url === url && frame.loaderIdentifier === loaderIdentifier)
     505            if (type === PageAgent.ResourceType.Document && frame.mainResource.url === url && frame.loaderIdentifier === loaderIdentifier)
    506506                resource = frame.mainResource;
    507             else if (frame.provisionalMainResource && frame.provisionalMainResource.url === url && frame.provisionalLoaderIdentifier === loaderIdentifier)
     507            else if (type === PageAgent.ResourceType.Document && frame.provisionalMainResource && frame.provisionalMainResource.url === url && frame.provisionalLoaderIdentifier === loaderIdentifier)
    508508                resource = frame.provisionalMainResource;
    509509            else {
     
    675675            // a main resource when we created the Frame. The resource payload does not include anything
    676676            // didn't already get from the frame payload.
    677             if (resourcePayload.type === "Document" && resourcePayload.url === payload.frame.url)
     677            if (resourcePayload.type === PageAgent.ResourceType.Document && resourcePayload.url === payload.frame.url)
    678678                continue;
    679679
  • trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js

    r222485 r222739  
    141141                return WI.UIString("Fetches");
    142142            return WI.UIString("Fetch");
     143        case WI.Resource.Type.Ping:
     144            if (plural)
     145                return WI.UIString("Pings");
     146            return WI.UIString("Ping");
     147        case WI.Resource.Type.Beacon:
     148            if (plural)
     149                return WI.UIString("Beacons");
     150            return WI.UIString("Beacon");
    143151        case WI.Resource.Type.WebSocket:
    144152            if (plural)
     
    10091017    XHR: "resource-type-xhr",
    10101018    Fetch: "resource-type-fetch",
     1019    Ping: "resource-type-ping",
     1020    Beacon: "resource-type-beacon",
    10111021    WebSocket: "resource-type-websocket",
    1012     Other: "resource-type-other"
     1022    Other: "resource-type-other",
    10131023};
    10141024
  • trunk/Source/WebInspectorUI/UserInterface/Models/ResourceCollection.js

    r222573 r222739  
    5454        case WI.Resource.Type.Fetch:
    5555            return WI.ResourceCollection.TypeVerifier.Fetch;
     56        case WI.Resource.Type.Ping:
     57            return WI.ResourceCollection.TypeVerifier.Ping;
     58        case WI.Resource.Type.Beacon:
     59            return WI.ResourceCollection.TypeVerifier.Beacon;
    5660        case WI.Resource.Type.WebSocket:
    5761            return WI.ResourceCollection.TypeVerifier.WebSocket;
     
    201205    XHR: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.XHR,
    202206    Fetch: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Fetch,
     207    Beacon: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Beacon,
    203208    WebSocket: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.WebSocket,
    204209    Other: (object) => WI.Collection.TypeVerifier.Resource(object) && object.type === WI.Resource.Type.Other,
  • trunk/Source/WebInspectorUI/UserInterface/Models/SourceCode.js

    r220119 r222739  
    198198        var error = parameters.error;
    199199        if (parameters.base64Encoded)
    200             content = decodeBase64ToBlob(content, this.mimeType);
     200            content = content ? decodeBase64ToBlob(content, this.mimeType) : "";
    201201
    202202        var revision = this.revisionForRequestedContent;
  • trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js

    r222485 r222739  
    109109        case WI.Resource.Type.Fetch:
    110110            return "XHR";
     111        case WI.Resource.Type.Ping:
     112            return WI.UIString("ping");
     113        case WI.Resource.Type.Beacon:
     114            return WI.UIString("Beacon");
    111115        case WI.Resource.Type.WebSocket:
    112116        case WI.Resource.Type.Other:
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourceClusterContentView.js

    r220119 r222739  
    7272        case WI.Resource.Type.XHR:
    7373        case WI.Resource.Type.Fetch:
     74        case WI.Resource.Type.Ping:
     75        case WI.Resource.Type.Beacon:
    7476            // FIXME: <https://webkit.org/b/165495> Web Inspector: XHR / Fetch for non-text content should not show garbled text
    75             // XHR / Fetch content may not always be text.
     77            // The response content for these requests may not always be text.
    7678            this._responseContentView = new WI.TextResourceContentView(this._resource);
    7779            break;
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js

    r220119 r222739  
    8787    }
    8888
     89    showMessage(message)
     90    {
     91        this.element.removeChildren();
     92        this.element.appendChild(WI.createMessageTextView(message));
     93    }
     94
    8995    addIssue(issue)
    9096    {
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourceIcons.css

    r220294 r222739  
    7272}
    7373
     74.resource-icon.resource-type-ping .icon,
     75.resource-icon.resource-type-beacon .icon {
     76    content: url(../Images/Beacon.svg);
     77}
     78
    7479.canvas.canvas-2d .icon {
    7580    content: url(../Images/Canvas2D.svg);
     
    131136    content: image-set(url(../Images/WebSocketLarge.png) 1x, url(../Images/WebSocketLarge@2x.png) 2x);
    132137}
     138
     139/* FIXME: <https://webkit.org/b/177642> Web Inspector: Add GTK icons for Beacon / Ping requests */
     140body:not(.mac-platform, .windows-platform) .resource-icon.resource-type-ping .icon,
     141body:not(.mac-platform, .windows-platform) .resource-icon.resource-type-beacon .icon {
     142    content: image-set(url(../Images/DocumentGeneric.png) 1x, url(../Images/DocumentGeneric@2x.png) 2x);
     143}
     144body:not(.mac-platform, .windows-platform) .large .resource-icon.resource-type-ping .icon,
     145body:not(.mac-platform, .windows-platform) .large .resource-icon.resource-type-beacon .icon {
     146    content: image-set(url(../Images/DocumentGenericLarge.png) 1x, url(../Images/DocumentGenericLarge@2x.png) 2x);
     147}
  • trunk/Source/WebInspectorUI/UserInterface/Views/TextResourceContentView.js

    r221338 r222739  
    209209        this._codeCoverageButtonNavigationItem.enabled = this._textEditor.canShowCoverageHints();
    210210        this._codeCoverageButtonNavigationItem.activated = WI.enableControlFlowProfilerSetting.value;
     211
     212        if (!this._textEditor.string)
     213            this.showMessage(WI.UIString("Resource has no content"));
    211214    }
    212215
  • trunk/Source/WebKit/ChangeLog

    r222736 r222739  
     12017-10-02  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Include Beacon and Ping requests in Network tab
     4        https://bugs.webkit.org/show_bug.cgi?id=177641
     5        <rdar://problem/33086839>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
     10        (WebKit::NetworkConnectionToWebProcess::loadPing):
     11        (WebKit::NetworkConnectionToWebProcess::didFinishPingLoad):
     12        * NetworkProcess/NetworkConnectionToWebProcess.h:
     13        * NetworkProcess/PingLoad.cpp:
     14        (WebKit::PingLoad::PingLoad):
     15        (WebKit::PingLoad::didFinish):
     16        (WebKit::PingLoad::didReceiveResponseNetworkSession):
     17        * NetworkProcess/PingLoad.h:
     18        * WebProcess/Network/NetworkProcessConnection.cpp:
     19        (WebKit::NetworkProcessConnection::didFinishPingLoad):
     20        * WebProcess/Network/NetworkProcessConnection.h:
     21        * WebProcess/Network/NetworkProcessConnection.messages.in:
     22        * WebProcess/Network/WebLoaderStrategy.cpp:
     23        (WebKit::WebLoaderStrategy::networkProcessCrashed):
     24        (WebKit::WebLoaderStrategy::startPingLoad):
     25        (WebKit::WebLoaderStrategy::didFinishPingLoad):
     26        * WebProcess/Network/WebLoaderStrategy.h:
     27        Pass an optional ResourceResponse back to the ping completion handler.
     28
    1292017-10-02  Alex Christensen  <achristensen@webkit.org>
    230
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp

    r222684 r222739  
    241241void NetworkConnectionToWebProcess::loadPing(NetworkResourceLoadParameters&& loadParameters, HTTPHeaderMap&& originalRequestHeaders)
    242242{
    243     auto completionHandler = [this, protectedThis = makeRef(*this), identifier = loadParameters.identifier] (const ResourceError& error) {
    244         didFinishPingLoad(identifier, error);
     243    auto completionHandler = [this, protectedThis = makeRef(*this), identifier = loadParameters.identifier] (const ResourceError& error, const ResourceResponse& response) {
     244        didFinishPingLoad(identifier, error, response);
    245245    };
    246246
     
    257257}
    258258
    259 void NetworkConnectionToWebProcess::didFinishPingLoad(uint64_t pingLoadIdentifier, const ResourceError& error)
     259void NetworkConnectionToWebProcess::didFinishPingLoad(uint64_t pingLoadIdentifier, const ResourceError& error, const ResourceResponse& response)
    260260{
    261261    if (!m_connection->isValid())
    262262        return;
    263263
    264     m_connection->send(Messages::NetworkProcessConnection::DidFinishPingLoad(pingLoadIdentifier, error), 0);
     264    m_connection->send(Messages::NetworkProcessConnection::DidFinishPingLoad(pingLoadIdentifier, error, response), 0);
    265265}
    266266
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h

    r222673 r222739  
    6666
    6767    void didCleanupResourceLoader(NetworkResourceLoader&);
    68     void didFinishPingLoad(uint64_t pingLoadIdentifier, const WebCore::ResourceError&);
     68    void didFinishPingLoad(uint64_t pingLoadIdentifier, const WebCore::ResourceError&, const WebCore::ResourceResponse&);
    6969
    7070    bool captureExtraNetworkLoadMetricsEnabled() const { return m_captureExtraNetworkLoadMetricsEnabled; }
  • trunk/Source/WebKit/NetworkProcess/PingLoad.cpp

    r222602 r222739  
    4545using namespace WebCore;
    4646
    47 PingLoad::PingLoad(NetworkResourceLoadParameters&& parameters, HTTPHeaderMap&& originalRequestHeaders, WTF::CompletionHandler<void(const ResourceError&)>&& completionHandler)
     47PingLoad::PingLoad(NetworkResourceLoadParameters&& parameters, HTTPHeaderMap&& originalRequestHeaders, WTF::CompletionHandler<void(const ResourceError&, const ResourceResponse&)>&& completionHandler)
    4848    : m_parameters(WTFMove(parameters))
    4949    , m_originalRequestHeaders(WTFMove(originalRequestHeaders))
     
    7878}
    7979
    80 void PingLoad::didFinish(const ResourceError& error)
    81 {
    82     m_completionHandler(error);
     80void PingLoad::didFinish(const ResourceError& error, const ResourceResponse& response)
     81{
     82    m_completionHandler(error, response);
    8383    delete this;
    8484}
     
    176176    RELEASE_LOG_IF_ALLOWED("didReceiveResponseNetworkSession - httpStatusCode: %d", response.httpStatusCode());
    177177    completionHandler(PolicyAction::Ignore);
    178     didFinish();
     178    didFinish({ }, response);
    179179}
    180180
  • trunk/Source/WebKit/NetworkProcess/PingLoad.h

    r222570 r222739  
    3232#include <WebCore/ContentExtensionsBackend.h>
    3333#include <WebCore/ResourceError.h>
     34#include <WebCore/ResourceResponse.h>
    3435#include <wtf/CompletionHandler.h>
    3536
     
    4647class PingLoad final : private NetworkDataTaskClient {
    4748public:
    48     PingLoad(NetworkResourceLoadParameters&&, WebCore::HTTPHeaderMap&& originalRequestHeaders, WTF::CompletionHandler<void(const WebCore::ResourceError&)>&&);
     49    PingLoad(NetworkResourceLoadParameters&&, WebCore::HTTPHeaderMap&& originalRequestHeaders, WTF::CompletionHandler<void(const WebCore::ResourceError&, const WebCore::ResourceResponse&)>&&);
    4950   
    5051private:
     
    7879
    7980    const WebCore::ResourceRequest& currentRequest() const;
    80     void didFinish(const WebCore::ResourceError& = { });
     81    void didFinish(const WebCore::ResourceError& = { }, const WebCore::ResourceResponse& response = { });
    8182   
    8283    NetworkResourceLoadParameters m_parameters;
    8384    WebCore::HTTPHeaderMap m_originalRequestHeaders; // Needed for CORS checks.
    84     WTF::CompletionHandler<void(const WebCore::ResourceError&)> m_completionHandler;
     85    WTF::CompletionHandler<void(const WebCore::ResourceError&, const WebCore::ResourceResponse&)> m_completionHandler;
    8586    RefPtr<NetworkDataTask> m_task;
    8687    WebCore::Timer m_timeoutTimer;
  • trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp

    r222684 r222739  
    137137}
    138138
    139 void NetworkProcessConnection::didFinishPingLoad(uint64_t pingLoadIdentifier, ResourceError&& error)
     139void NetworkProcessConnection::didFinishPingLoad(uint64_t pingLoadIdentifier, ResourceError&& error, ResourceResponse&& response)
    140140{
    141     WebProcess::singleton().webLoaderStrategy().didFinishPingLoad(pingLoadIdentifier, WTFMove(error));
     141    WebProcess::singleton().webLoaderStrategy().didFinishPingLoad(pingLoadIdentifier, WTFMove(error), WTFMove(response));
    142142}
    143143
  • trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h

    r222613 r222739  
    7474
    7575    void didWriteBlobsToTemporaryFiles(uint64_t requestIdentifier, const Vector<String>& filenames);
    76     void didFinishPingLoad(uint64_t pingLoadIdentifier, WebCore::ResourceError&&);
     76    void didFinishPingLoad(uint64_t pingLoadIdentifier, WebCore::ResourceError&&, WebCore::ResourceResponse&&);
    7777    void didFinishPreconnection(uint64_t preconnectionIdentifier, WebCore::ResourceError&&);
    7878
  • trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.messages.in

    r222613 r222739  
    2828
    2929    DidWriteBlobsToTemporaryFiles(uint64_t requestIdentifier, Vector<String> filenames)
    30     DidFinishPingLoad(uint64_t pingLoadIdentifier, WebCore::ResourceError error)
     30    DidFinishPingLoad(uint64_t pingLoadIdentifier, WebCore::ResourceError error, WebCore::ResourceResponse response)
    3131    DidFinishPreconnection(uint64_t preconnectionIdentifier, WebCore::ResourceError error)
    3232}
  • trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp

    r222673 r222739  
    356356    auto pingLoadCompletionHandlers = WTFMove(m_pingLoadCompletionHandlers);
    357357    for (auto& pingLoadCompletionHandler : pingLoadCompletionHandlers.values())
    358         pingLoadCompletionHandler(internalError(URL()));
     358        pingLoadCompletionHandler(internalError(URL()), { });
    359359
    360360    auto preconnectCompletionHandlers = WTFMove(m_preconnectCompletionHandlers);
     
    410410    if (!networkingContext) {
    411411        if (completionHandler)
    412             completionHandler(internalError(request.url()));
     412            completionHandler(internalError(request.url()), { });
    413413        return;
    414414    }
     
    422422    if (!document) {
    423423        if (completionHandler)
    424             completionHandler(internalError(request.url()));
     424            completionHandler(internalError(request.url()), { });
    425425        return;
    426426    }
     
    458458}
    459459
    460 void WebLoaderStrategy::didFinishPingLoad(uint64_t pingLoadIdentifier, ResourceError&& error)
     460void WebLoaderStrategy::didFinishPingLoad(uint64_t pingLoadIdentifier, ResourceError&& error, ResourceResponse&& response)
    461461{
    462462    if (auto completionHandler = m_pingLoadCompletionHandlers.take(pingLoadIdentifier))
    463         completionHandler(WTFMove(error));
     463        completionHandler(WTFMove(error), WTFMove(response));
    464464}
    465465
  • trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h

    r222673 r222739  
    6161
    6262    void startPingLoad(WebCore::Frame&, WebCore::ResourceRequest&, const WebCore::HTTPHeaderMap& originalRequestHeaders, const WebCore::FetchOptions&, PingLoadCompletionHandler&&) final;
    63     void didFinishPingLoad(uint64_t pingLoadIdentifier, WebCore::ResourceError&&);
     63    void didFinishPingLoad(uint64_t pingLoadIdentifier, WebCore::ResourceError&&, WebCore::ResourceResponse&&);
    6464
    6565    void preconnectTo(WebCore::NetworkingContext&, const WebCore::URL&, WebCore::StoredCredentialsPolicy, PreconnectCompletionHandler&&) final;
Note: See TracChangeset for help on using the changeset viewer.