ServiceWorker Inspector: Should be able to see image content from CacheStorage.add...
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Dec 2017 22:57:30 +0000 (22:57 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Dec 2017 22:57:30 +0000 (22:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180506

Reviewed by Brian Burg.

No test as this only happens inside a ServiceWorker inspector which
we don't yet have a way to test. In a Page Inspector, the
CacheStorage.add network request already behaves as expected.

* inspector/NetworkResourcesData.cpp:
(WebCore::NetworkResourcesData::responseReceived):
(WebCore::shouldBufferResourceData):
* inspector/NetworkResourcesData.h:
(WebCore::NetworkResourcesData::ResourceData::forceBufferData const):
(WebCore::NetworkResourcesData::ResourceData::setForceBufferData):
Provide a way to force buffering in NetworkResourceData.

* inspector/agents/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::didReceiveResponse):
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.h:
Enable force buffering in a Worker Network Agent.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225708 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/NetworkResourcesData.cpp
Source/WebCore/inspector/NetworkResourcesData.h
Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp
Source/WebCore/inspector/agents/InspectorNetworkAgent.h
Source/WebCore/inspector/agents/page/PageNetworkAgent.h
Source/WebCore/inspector/agents/worker/WorkerNetworkAgent.h

index 58b10c7..2682c40 100644 (file)
@@ -1,3 +1,29 @@
+2017-12-08  Joseph Pecoraro  <pecoraro@apple.com>
+
+        ServiceWorker Inspector: Should be able to see image content from CacheStorage.add(url) network request
+        https://bugs.webkit.org/show_bug.cgi?id=180506
+
+        Reviewed by Brian Burg.
+
+        No test as this only happens inside a ServiceWorker inspector which
+        we don't yet have a way to test. In a Page Inspector, the
+        CacheStorage.add network request already behaves as expected.
+
+        * inspector/NetworkResourcesData.cpp:
+        (WebCore::NetworkResourcesData::responseReceived):
+        (WebCore::shouldBufferResourceData):
+        * inspector/NetworkResourcesData.h:
+        (WebCore::NetworkResourcesData::ResourceData::forceBufferData const):
+        (WebCore::NetworkResourcesData::ResourceData::setForceBufferData):
+        Provide a way to force buffering in NetworkResourceData.
+
+        * inspector/agents/InspectorNetworkAgent.cpp:
+        (WebCore::InspectorNetworkAgent::didReceiveResponse):
+        * inspector/agents/InspectorNetworkAgent.h:
+        * inspector/agents/page/PageNetworkAgent.h:
+        * inspector/agents/worker/WorkerNetworkAgent.h:
+        Enable force buffering in a Worker Network Agent.
+
 2017-12-08  Daniel Bates  <dabates@apple.com>
 
         Remove unnecessary prefix from AutoFillButtonType enumerators
index 83eb663..2fa668a 100644 (file)
@@ -150,7 +150,7 @@ void NetworkResourcesData::resourceCreated(const String& requestId, const String
     m_requestIdToResourceDataMap.set(requestId, WTFMove(resourceData));
 }
 
-void NetworkResourcesData::responseReceived(const String& requestId, const String& frameId, const ResourceResponse& response, InspectorPageAgent::ResourceType type)
+void NetworkResourcesData::responseReceived(const String& requestId, const String& frameId, const ResourceResponse& response, InspectorPageAgent::ResourceType type, bool forceBufferData)
 {
     ResourceData* resourceData = resourceDataForRequestId(requestId);
     if (!resourceData)
@@ -160,6 +160,7 @@ void NetworkResourcesData::responseReceived(const String& requestId, const Strin
     resourceData->setURL(response.url());
     resourceData->setHTTPStatusCode(response.httpStatusCode());
     resourceData->setType(type);
+    resourceData->setForceBufferData(forceBufferData);
 
     if (InspectorNetworkAgent::shouldTreatAsText(response.mimeType()))
         resourceData->setDecoder(InspectorNetworkAgent::createTextDecoder(response.mimeType(), response.textEncodingName()));
@@ -205,6 +206,9 @@ void NetworkResourcesData::setResourceContent(const String& requestId, const Str
 
 static bool shouldBufferResourceData(const NetworkResourcesData::ResourceData& resourceData)
 {
+    if (resourceData.forceBufferData())
+        return true;
+
     if (resourceData.decoder())
         return true;
 
index df18fb4..37d8b7c 100644 (file)
@@ -87,6 +87,9 @@ public:
         CachedResource* cachedResource() const { return m_cachedResource; }
         void setCachedResource(CachedResource* cachedResource) { m_cachedResource = cachedResource; }
 
+        bool forceBufferData() const { return m_forceBufferData; }
+        void setForceBufferData(bool force) { m_forceBufferData = force; }
+
     private:
         bool hasData() const { return m_dataBuffer; }
         size_t dataLength() const;
@@ -107,6 +110,7 @@ public:
         int m_httpStatusCode { 0 };
         bool m_isContentEvicted { false };
         bool m_base64Encoded { false };
+        bool m_forceBufferData { false };
     };
 
     NetworkResourcesData();
@@ -114,7 +118,7 @@ public:
 
     void resourceCreated(const String& requestId, const String& loaderId, InspectorPageAgent::ResourceType);
     void resourceCreated(const String& requestId, const String& loaderId, CachedResource&);
-    void responseReceived(const String& requestId, const String& frameId, const ResourceResponse&, InspectorPageAgent::ResourceType);
+    void responseReceived(const String& requestId, const String& frameId, const ResourceResponse&, InspectorPageAgent::ResourceType, bool forceBufferData);
     void setResourceType(const String& requestId, InspectorPageAgent::ResourceType);
     InspectorPageAgent::ResourceType resourceType(const String& requestId);
     void setResourceContent(const String& requestId, const String& content, bool base64Encoded = false);
index 34aa5fc..b3091b3 100644 (file)
@@ -450,7 +450,7 @@ void InspectorNetworkAgent::didReceiveResponse(unsigned long identifier, Documen
     String frameId = frameIdentifier(loader);
     String loaderId = loaderIdentifier(loader);
 
-    m_resourcesData->responseReceived(requestId, frameId, response, type);
+    m_resourcesData->responseReceived(requestId, frameId, response, type, shouldForceBufferingNetworkResourceData());
 
     m_frontendDispatcher->responseReceived(requestId, frameId, loaderId, timestamp(), InspectorPageAgent::resourceTypeJSON(type), resourceResponse);
 
index e8139ef..9e94d79 100644 (file)
@@ -123,6 +123,7 @@ public:
     virtual Vector<WebSocket*> activeWebSockets(const LockHolder&) = 0;
     virtual void setResourceCachingDisabled(bool) = 0;
     virtual ScriptExecutionContext* scriptExecutionContext(ErrorString&, const String& frameId) = 0;
+    virtual bool shouldForceBufferingNetworkResourceData() const = 0;
 
 private:
     void enable();
index e135a89..fe0ebeb 100644 (file)
@@ -42,6 +42,7 @@ private:
     Vector<WebSocket*> activeWebSockets(const LockHolder&) final;
     void setResourceCachingDisabled(bool) final;
     ScriptExecutionContext* scriptExecutionContext(ErrorString&, const String& frameId) final;
+    bool shouldForceBufferingNetworkResourceData() const final { return false; }
 
     InspectorPageAgent* m_pageAgent { nullptr };
 };
index 3aa9dec..865e22b 100644 (file)
@@ -42,6 +42,7 @@ private:
     Vector<WebSocket*> activeWebSockets(const LockHolder&) final;
     void setResourceCachingDisabled(bool) final;
     ScriptExecutionContext* scriptExecutionContext(ErrorString&, const String& frameId) final;
+    bool shouldForceBufferingNetworkResourceData() const final { return true; }
 
     WorkerGlobalScope& m_workerGlobalScope;
 };