Title: [263212] branches/safari-610.1.17-branch/Source/WebCore
Revision
263212
Author
alanc...@apple.com
Date
2020-06-18 09:52:05 -0700 (Thu, 18 Jun 2020)

Log Message

Cherry-pick r263119. rdar://problem/64492834

    Web Inspector: replace completion handler with a function in interception.
    https://bugs.webkit.org/show_bug.cgi?id=213252

    Patch by Pavel Feldman <pavel.feld...@gmail.com> on 2020-06-16
    Reviewed by Devin Rousso.

    Don't use a `CompletionHandler` as it asserts that it's been called when it's destroyed.
    Both `Network.interceptRequestWithResponse` and `Network.interceptRequestWithError` essentially
    "skip" the network pipeline, so the `CompletionHandler` is not invoked for those commands.

    * inspector/InspectorInstrumentation.cpp:
    (WebCore::InspectorInstrumentation::interceptRequestImpl):
    * inspector/InspectorInstrumentation.h:
    (WebCore::InspectorInstrumentation::interceptRequest):
    * inspector/InspectorInstrumentationWebKit.cpp:
    (WebCore::InspectorInstrumentationWebKit::interceptRequestInternal):
    * inspector/InspectorInstrumentationWebKit.h:
    (WebCore::InspectorInstrumentationWebKit::interceptRequest):
    * inspector/agents/InspectorNetworkAgent.cpp:
    (WebCore::InspectorNetworkAgent::interceptRequest):
    (WebCore::InspectorNetworkAgent::interceptRequestWithResponse):
    (WebCore::InspectorNetworkAgent::interceptRequestWithError):
    * inspector/agents/InspectorNetworkAgent.h:
    (WebCore::InspectorNetworkAgent::PendingInterceptRequest::PendingInterceptRequest):
    (WebCore::InspectorNetworkAgent::PendingInterceptRequest::continueAsHandled):

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

Modified Paths

Diff

Modified: branches/safari-610.1.17-branch/Source/WebCore/ChangeLog (263211 => 263212)


--- branches/safari-610.1.17-branch/Source/WebCore/ChangeLog	2020-06-18 16:32:09 UTC (rev 263211)
+++ branches/safari-610.1.17-branch/Source/WebCore/ChangeLog	2020-06-18 16:52:05 UTC (rev 263212)
@@ -1,3 +1,62 @@
+2020-06-18  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r263119. rdar://problem/64492834
+
+    Web Inspector: replace completion handler with a function in interception.
+    https://bugs.webkit.org/show_bug.cgi?id=213252
+    
+    Patch by Pavel Feldman <pavel.feld...@gmail.com> on 2020-06-16
+    Reviewed by Devin Rousso.
+    
+    Don't use a `CompletionHandler` as it asserts that it's been called when it's destroyed.
+    Both `Network.interceptRequestWithResponse` and `Network.interceptRequestWithError` essentially
+    "skip" the network pipeline, so the `CompletionHandler` is not invoked for those commands.
+    
+    * inspector/InspectorInstrumentation.cpp:
+    (WebCore::InspectorInstrumentation::interceptRequestImpl):
+    * inspector/InspectorInstrumentation.h:
+    (WebCore::InspectorInstrumentation::interceptRequest):
+    * inspector/InspectorInstrumentationWebKit.cpp:
+    (WebCore::InspectorInstrumentationWebKit::interceptRequestInternal):
+    * inspector/InspectorInstrumentationWebKit.h:
+    (WebCore::InspectorInstrumentationWebKit::interceptRequest):
+    * inspector/agents/InspectorNetworkAgent.cpp:
+    (WebCore::InspectorNetworkAgent::interceptRequest):
+    (WebCore::InspectorNetworkAgent::interceptRequestWithResponse):
+    (WebCore::InspectorNetworkAgent::interceptRequestWithError):
+    * inspector/agents/InspectorNetworkAgent.h:
+    (WebCore::InspectorNetworkAgent::PendingInterceptRequest::PendingInterceptRequest):
+    (WebCore::InspectorNetworkAgent::PendingInterceptRequest::continueAsHandled):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263119 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-06-16  Pavel Feldman  <pavel.feld...@gmail.com>
+
+            Web Inspector: replace completion handler with a function in interception.
+            https://bugs.webkit.org/show_bug.cgi?id=213252
+
+            Reviewed by Devin Rousso.
+
+            Don't use a `CompletionHandler` as it asserts that it's been called when it's destroyed.
+            Both `Network.interceptRequestWithResponse` and `Network.interceptRequestWithError` essentially
+            "skip" the network pipeline, so the `CompletionHandler` is not invoked for those commands.
+
+            * inspector/InspectorInstrumentation.cpp:
+            (WebCore::InspectorInstrumentation::interceptRequestImpl):
+            * inspector/InspectorInstrumentation.h:
+            (WebCore::InspectorInstrumentation::interceptRequest):
+            * inspector/InspectorInstrumentationWebKit.cpp:
+            (WebCore::InspectorInstrumentationWebKit::interceptRequestInternal):
+            * inspector/InspectorInstrumentationWebKit.h:
+            (WebCore::InspectorInstrumentationWebKit::interceptRequest):
+            * inspector/agents/InspectorNetworkAgent.cpp:
+            (WebCore::InspectorNetworkAgent::interceptRequest):
+            (WebCore::InspectorNetworkAgent::interceptRequestWithResponse):
+            (WebCore::InspectorNetworkAgent::interceptRequestWithError):
+            * inspector/agents/InspectorNetworkAgent.h:
+            (WebCore::InspectorNetworkAgent::PendingInterceptRequest::PendingInterceptRequest):
+            (WebCore::InspectorNetworkAgent::PendingInterceptRequest::continueAsHandled):
+
 2020-06-15  Megan Gardner  <megan_gard...@apple.com>
 
         Text form controls can scroll by 1px when value is the same length as size. No scrolling should happen.

Modified: branches/safari-610.1.17-branch/Source/WebCore/inspector/InspectorInstrumentation.cpp (263211 => 263212)


--- branches/safari-610.1.17-branch/Source/WebCore/inspector/InspectorInstrumentation.cpp	2020-06-18 16:32:09 UTC (rev 263211)
+++ branches/safari-610.1.17-branch/Source/WebCore/inspector/InspectorInstrumentation.cpp	2020-06-18 16:52:05 UTC (rev 263212)
@@ -832,7 +832,7 @@
     return false;
 }
 
-void InspectorInstrumentation::interceptRequestImpl(InstrumentingAgents& instrumentingAgents, ResourceLoader& loader, CompletionHandler<void(const ResourceRequest&)>&& handler)
+void InspectorInstrumentation::interceptRequestImpl(InstrumentingAgents& instrumentingAgents, ResourceLoader& loader, Function<void(const ResourceRequest&)>&& handler)
 {
     if (auto* networkAgent = instrumentingAgents.enabledNetworkAgent())
         networkAgent->interceptRequest(loader, WTFMove(handler));

Modified: branches/safari-610.1.17-branch/Source/WebCore/inspector/InspectorInstrumentation.h (263211 => 263212)


--- branches/safari-610.1.17-branch/Source/WebCore/inspector/InspectorInstrumentation.h	2020-06-18 16:32:09 UTC (rev 263211)
+++ branches/safari-610.1.17-branch/Source/WebCore/inspector/InspectorInstrumentation.h	2020-06-18 16:52:05 UTC (rev 263212)
@@ -52,6 +52,7 @@
 #include <_javascript_Core/ConsoleMessage.h>
 #include <initializer_list>
 #include <wtf/CompletionHandler.h>
+#include <wtf/Function.h>
 #include <wtf/MemoryPressureHandler.h>
 #include <wtf/RefPtr.h>
 
@@ -238,7 +239,7 @@
     static bool willIntercept(const Frame*, const ResourceRequest&);
     static bool shouldInterceptRequest(const Frame&, const ResourceRequest&);
     static bool shouldInterceptResponse(const Frame&, const ResourceResponse&);
-    static void interceptRequest(ResourceLoader&, CompletionHandler<void(const ResourceRequest&)>&&);
+    static void interceptRequest(ResourceLoader&, Function<void(const ResourceRequest&)>&&);
     static void interceptResponse(const Frame&, const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
 
     static void addMessageToConsole(Page&, std::unique_ptr<Inspector::ConsoleMessage>);
@@ -448,7 +449,7 @@
     static bool willInterceptImpl(InstrumentingAgents&, const ResourceRequest&);
     static bool shouldInterceptRequestImpl(InstrumentingAgents&, const ResourceRequest&);
     static bool shouldInterceptResponseImpl(InstrumentingAgents&, const ResourceResponse&);
-    static void interceptRequestImpl(InstrumentingAgents&, ResourceLoader&, CompletionHandler<void(const ResourceRequest&)>&&);
+    static void interceptRequestImpl(InstrumentingAgents&, ResourceLoader&, Function<void(const ResourceRequest&)>&&);
     static void interceptResponseImpl(InstrumentingAgents&, const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
 
     static void addMessageToConsoleImpl(InstrumentingAgents&, std::unique_ptr<Inspector::ConsoleMessage>);
@@ -1286,7 +1287,7 @@
     return false;
 }
 
-inline void InspectorInstrumentation::interceptRequest(ResourceLoader& loader, CompletionHandler<void(const ResourceRequest&)>&& handler)
+inline void InspectorInstrumentation::interceptRequest(ResourceLoader& loader, Function<void(const ResourceRequest&)>&& handler)
 {
     ASSERT(InspectorInstrumentation::shouldInterceptRequest(*loader.frame(), loader.request()));
     if (auto* instrumentingAgents = instrumentingAgentsForFrame(loader.frame()))

Modified: branches/safari-610.1.17-branch/Source/WebCore/inspector/InspectorInstrumentationWebKit.cpp (263211 => 263212)


--- branches/safari-610.1.17-branch/Source/WebCore/inspector/InspectorInstrumentationWebKit.cpp	2020-06-18 16:32:09 UTC (rev 263211)
+++ branches/safari-610.1.17-branch/Source/WebCore/inspector/InspectorInstrumentationWebKit.cpp	2020-06-18 16:52:05 UTC (rev 263212)
@@ -40,7 +40,7 @@
     return InspectorInstrumentation::shouldInterceptResponse(frame, response);
 }
 
-void InspectorInstrumentationWebKit::interceptRequestInternal(ResourceLoader& loader, CompletionHandler<void(const ResourceRequest&)>&& handler)
+void InspectorInstrumentationWebKit::interceptRequestInternal(ResourceLoader& loader, Function<void(const ResourceRequest&)>&& handler)
 {
     InspectorInstrumentation::interceptRequest(loader, WTFMove(handler));
 }

Modified: branches/safari-610.1.17-branch/Source/WebCore/inspector/InspectorInstrumentationWebKit.h (263211 => 263212)


--- branches/safari-610.1.17-branch/Source/WebCore/inspector/InspectorInstrumentationWebKit.h	2020-06-18 16:32:09 UTC (rev 263211)
+++ branches/safari-610.1.17-branch/Source/WebCore/inspector/InspectorInstrumentationWebKit.h	2020-06-18 16:52:05 UTC (rev 263212)
@@ -27,6 +27,7 @@
 
 #include "InspectorInstrumentationPublic.h"
 #include <wtf/CompletionHandler.h>
+#include <wtf/Function.h>
 
 namespace WebCore {
 
@@ -38,13 +39,13 @@
 public:
     static bool shouldInterceptRequest(const Frame*, const ResourceRequest&);
     static bool shouldInterceptResponse(const Frame*, const ResourceResponse&);
-    static void interceptRequest(ResourceLoader&, CompletionHandler<void(const ResourceRequest&)>&&);
+    static void interceptRequest(ResourceLoader&, Function<void(const ResourceRequest&)>&&);
     static void interceptResponse(const Frame*, const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
 
 private:
     static bool shouldInterceptRequestInternal(const Frame&, const ResourceRequest&);
     static bool shouldInterceptResponseInternal(const Frame&, const ResourceResponse&);
-    static void interceptRequestInternal(ResourceLoader&, CompletionHandler<void(const ResourceRequest&)>&&);
+    static void interceptRequestInternal(ResourceLoader&, Function<void(const ResourceRequest&)>&&);
     static void interceptResponseInternal(const Frame&, const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
 };
 
@@ -66,7 +67,7 @@
     return shouldInterceptResponseInternal(*frame, response);
 }
 
-inline void InspectorInstrumentationWebKit::interceptRequest(ResourceLoader& loader, CompletionHandler<void(const ResourceRequest&)>&& handler)
+inline void InspectorInstrumentationWebKit::interceptRequest(ResourceLoader& loader, Function<void(const ResourceRequest&)>&& handler)
 {
     ASSERT(InspectorInstrumentationWebKit::shouldInterceptRequest(loader.frame(), loader.request()));
     interceptRequestInternal(loader, WTFMove(handler));

Modified: branches/safari-610.1.17-branch/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp (263211 => 263212)


--- branches/safari-610.1.17-branch/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp	2020-06-18 16:32:09 UTC (rev 263211)
+++ branches/safari-610.1.17-branch/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp	2020-06-18 16:52:05 UTC (rev 263212)
@@ -1114,7 +1114,7 @@
     return shouldIntercept(response.url(), NetworkStage::Response);
 }
 
-void InspectorNetworkAgent::interceptRequest(ResourceLoader& loader, CompletionHandler<void(const ResourceRequest&)>&& handler)
+void InspectorNetworkAgent::interceptRequest(ResourceLoader& loader, Function<void(const ResourceRequest&)>&& handler)
 {
     ASSERT(m_enabled);
     ASSERT(m_interceptionEnabled);

Modified: branches/safari-610.1.17-branch/Source/WebCore/inspector/agents/InspectorNetworkAgent.h (263211 => 263212)


--- branches/safari-610.1.17-branch/Source/WebCore/inspector/agents/InspectorNetworkAgent.h	2020-06-18 16:32:09 UTC (rev 263211)
+++ branches/safari-610.1.17-branch/Source/WebCore/inspector/agents/InspectorNetworkAgent.h	2020-06-18 16:52:05 UTC (rev 263212)
@@ -125,7 +125,7 @@
     bool shouldInterceptRequest(const ResourceRequest&);
     bool shouldInterceptResponse(const ResourceResponse&);
     void interceptResponse(const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
-    void interceptRequest(ResourceLoader&, CompletionHandler<void(const ResourceRequest&)>&&);
+    void interceptRequest(ResourceLoader&, Function<void(const ResourceRequest&)>&&);
 
     void searchOtherRequests(const JSC::Yarr::RegularExpression&, RefPtr<JSON::ArrayOf<Inspector::Protocol::Page::SearchResult>>&);
     void searchInRequest(ErrorString&, const String& requestId, const String& query, bool caseSensitive, bool isRegex, RefPtr<JSON::ArrayOf<Inspector::Protocol::GenericTypes::SearchMatch>>&);
@@ -164,25 +164,25 @@
         WTF_MAKE_NONCOPYABLE(PendingInterceptRequest);
         WTF_MAKE_FAST_ALLOCATED;
     public:
-        PendingInterceptRequest(RefPtr<ResourceLoader> loader, CompletionHandler<void(const ResourceRequest&)>&& completionHandler)
+        PendingInterceptRequest(RefPtr<ResourceLoader> loader, Function<void(const ResourceRequest&)>&& callback)
             : m_loader(loader)
-            , m_completionHandler(WTFMove(completionHandler))
+            , m_completionCallback(WTFMove(callback))
         { }
 
         void continueWithOriginalRequest()
         {
             if (!m_loader->reachedTerminalState())
-                m_completionHandler(m_loader->request());
+                m_completionCallback(m_loader->request());
         }
 
         void continueWithRequest(const ResourceRequest& request)
         {
-            m_completionHandler(request);
+            m_completionCallback(request);
         }
 
         PendingInterceptRequest() = default;
         RefPtr<ResourceLoader> m_loader;
-        CompletionHandler<void(const ResourceRequest&)> m_completionHandler;
+        Function<void(const ResourceRequest&)> m_completionCallback;
     };
 
     class PendingInterceptResponse {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to