Skip to content
Permalink
Browse files
Web Inspector: Cleanup some InspectorInstrumentation network loading …
…notifications

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

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-12-11
Reviewed by Brian Burg.

Eliminate InspectorInstrumentation::willReceiveResourceResponse by folding
it into InspectorInstrumentation::didReceiveResourceResponse. Simplify other
related InspectorInstrumentation calls by using references and using more
consistent InspectorInstrumentation patterns.

* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didReceiveResourceResponseImpl):
(WebCore::InspectorInstrumentation::willReceiveResourceResponseImpl): Deleted.
(WebCore::InspectorInstrumentation::didReceiveResourceResponseButCanceledImpl): Deleted.
(WebCore::InspectorInstrumentation::continueAfterXFrameOptionsDeniedImpl): Deleted.
(WebCore::InspectorInstrumentation::continueWithPolicyDownloadImpl): Deleted.
(WebCore::InspectorInstrumentation::continueWithPolicyIgnoreImpl): Deleted.
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::didReceiveResourceResponse):
(WebCore::InspectorInstrumentation::continueAfterXFrameOptionsDenied):
(WebCore::InspectorInstrumentation::continueWithPolicyDownload):
(WebCore::InspectorInstrumentation::continueWithPolicyIgnore):
(WebCore::InspectorInstrumentation::willReceiveResourceResponse): Deleted.
* loader/CrossOriginPreflightChecker.cpp:
(WebCore::CrossOriginPreflightChecker::validatePreflightResponse):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::stopLoadingAfterXFrameOptionsOrContentSecurityPolicyDenied):
(WebCore::DocumentLoader::continueAfterContentPolicy):
* loader/ResourceLoadNotifier.cpp:
(WebCore::ResourceLoadNotifier::dispatchDidReceiveResponse):
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::didReceiveResponse):

Canonical link: https://commits.webkit.org/183343@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209687 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JosephPecoraro authored and webkit-commit-queue committed Dec 11, 2016
1 parent 9162865 commit 6639fc656b86ed1bdcb3c8a6d936218aa6dc590b
Showing 7 changed files with 71 additions and 82 deletions.
@@ -1,3 +1,38 @@
2016-12-11 Joseph Pecoraro <pecoraro@apple.com>

Web Inspector: Cleanup some InspectorInstrumentation network loading notifications
https://bugs.webkit.org/show_bug.cgi?id=165688

Reviewed by Brian Burg.

Eliminate InspectorInstrumentation::willReceiveResourceResponse by folding
it into InspectorInstrumentation::didReceiveResourceResponse. Simplify other
related InspectorInstrumentation calls by using references and using more
consistent InspectorInstrumentation patterns.

* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didReceiveResourceResponseImpl):
(WebCore::InspectorInstrumentation::willReceiveResourceResponseImpl): Deleted.
(WebCore::InspectorInstrumentation::didReceiveResourceResponseButCanceledImpl): Deleted.
(WebCore::InspectorInstrumentation::continueAfterXFrameOptionsDeniedImpl): Deleted.
(WebCore::InspectorInstrumentation::continueWithPolicyDownloadImpl): Deleted.
(WebCore::InspectorInstrumentation::continueWithPolicyIgnoreImpl): Deleted.
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::didReceiveResourceResponse):
(WebCore::InspectorInstrumentation::continueAfterXFrameOptionsDenied):
(WebCore::InspectorInstrumentation::continueWithPolicyDownload):
(WebCore::InspectorInstrumentation::continueWithPolicyIgnore):
(WebCore::InspectorInstrumentation::willReceiveResourceResponse): Deleted.
* loader/CrossOriginPreflightChecker.cpp:
(WebCore::CrossOriginPreflightChecker::validatePreflightResponse):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::stopLoadingAfterXFrameOptionsOrContentSecurityPolicyDenied):
(WebCore::DocumentLoader::continueAfterContentPolicy):
* loader/ResourceLoadNotifier.cpp:
(WebCore::ResourceLoadNotifier::dispatchDidReceiveResponse):
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::didReceiveResponse):

2016-12-11 Eric Carlson <eric.carlson@apple.com>

[MediaStream] Protect MediaDevicesRequest during callback
@@ -582,51 +582,17 @@ void InspectorInstrumentation::didLoadResourceFromMemoryCacheImpl(InstrumentingA
networkAgent->didLoadResourceFromMemoryCache(*loader, *cachedResource);
}

InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceResponseImpl(InstrumentingAgents& instrumentingAgents)
void InspectorInstrumentation::didReceiveResourceResponseImpl(InstrumentingAgents& instrumentingAgents, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response, ResourceLoader* resourceLoader)
{
return InspectorInstrumentationCookie(instrumentingAgents, 0);
}

void InspectorInstrumentation::didReceiveResourceResponseImpl(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response, ResourceLoader* resourceLoader)
{
if (!cookie.isValid())
return;

if (!loader)
return;

InstrumentingAgents& instrumentingAgents = *cookie.instrumentingAgents();

if (InspectorNetworkAgent* networkAgent = instrumentingAgents.inspectorNetworkAgent())
networkAgent->didReceiveResponse(identifier, *loader, response, resourceLoader);
if (WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())
consoleAgent->didReceiveResponse(identifier, response); // This should come AFTER resource notification, front-end relies on this.
}

void InspectorInstrumentation::didReceiveResourceResponseButCanceledImpl(Frame* frame, DocumentLoader& loader, unsigned long identifier, const ResourceResponse& r)
{
if (!frame)
return;

InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(frame);
InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, &loader, r, nullptr);
}

void InspectorInstrumentation::continueAfterXFrameOptionsDeniedImpl(Frame* frame, DocumentLoader& loader, unsigned long identifier, const ResourceResponse& r)
{
didReceiveResourceResponseButCanceledImpl(frame, loader, identifier, r);
}

void InspectorInstrumentation::continueWithPolicyDownloadImpl(Frame* frame, DocumentLoader& loader, unsigned long identifier, const ResourceResponse& r)
{
didReceiveResourceResponseButCanceledImpl(frame, loader, identifier, r);
}

void InspectorInstrumentation::continueWithPolicyIgnoreImpl(Frame* frame, DocumentLoader& loader, unsigned long identifier, const ResourceResponse& r)
{
didReceiveResourceResponseButCanceledImpl(frame, loader, identifier, r);
}

void InspectorInstrumentation::didReceiveThreadableLoaderResponseImpl(InstrumentingAgents& instrumentingAgents, DocumentThreadableLoader& documentThreadableLoader, unsigned long identifier)
{
if (InspectorNetworkAgent* networkAgent = instrumentingAgents.inspectorNetworkAgent())
@@ -154,15 +154,15 @@ class InspectorInstrumentation {
static void continueAfterPingLoader(Frame&, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse&);
static void markResourceAsCached(Page&, unsigned long identifier);
static void didLoadResourceFromMemoryCache(Page&, DocumentLoader*, CachedResource*);
static InspectorInstrumentationCookie willReceiveResourceResponse(Frame*);
static void didReceiveResourceResponse(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
static void continueAfterXFrameOptionsDenied(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
static void continueWithPolicyDownload(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
static void continueWithPolicyIgnore(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
static void didReceiveResourceResponse(Frame&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
static void didReceiveThreadableLoaderResponse(DocumentThreadableLoader&, unsigned long identifier);
static void didReceiveData(Frame*, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
static void didFinishLoading(Frame*, DocumentLoader*, unsigned long identifier, double finishTime);
static void didFailLoading(Frame*, DocumentLoader*, unsigned long identifier, const ResourceError&);
static void continueAfterXFrameOptionsDenied(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);
static void continueWithPolicyDownload(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);
static void continueWithPolicyIgnore(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);

static void didFinishXHRLoading(ScriptExecutionContext*, unsigned long identifier, std::optional<String> decodedText, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber);
static void willLoadXHRSynchronously(ScriptExecutionContext*);
static void didLoadXHRSynchronously(ScriptExecutionContext*);
@@ -324,12 +324,7 @@ class InspectorInstrumentation {
static void continueAfterPingLoaderImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse&);
static void markResourceAsCachedImpl(InstrumentingAgents&, unsigned long identifier);
static void didLoadResourceFromMemoryCacheImpl(InstrumentingAgents&, DocumentLoader*, CachedResource*);
static InspectorInstrumentationCookie willReceiveResourceResponseImpl(InstrumentingAgents&);
static void didReceiveResourceResponseImpl(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
static void didReceiveResourceResponseButCanceledImpl(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
static void continueAfterXFrameOptionsDeniedImpl(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
static void continueWithPolicyDownloadImpl(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
static void continueWithPolicyIgnoreImpl(Frame*, DocumentLoader&, unsigned long identifier, const ResourceResponse&);
static void didReceiveResourceResponseImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
static void didReceiveThreadableLoaderResponseImpl(InstrumentingAgents&, DocumentThreadableLoader&, unsigned long identifier);
static void didReceiveDataImpl(InstrumentingAgents&, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
static void didFinishLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, double finishTime);
@@ -850,35 +845,10 @@ inline void InspectorInstrumentation::didLoadResourceFromMemoryCache(Page& page,
didLoadResourceFromMemoryCacheImpl(instrumentingAgentsForPage(page), loader, resource);
}

inline InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceResponse(Frame* frame)
inline void InspectorInstrumentation::didReceiveResourceResponse(Frame& frame, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response, ResourceLoader* resourceLoader)
{
if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
return willReceiveResourceResponseImpl(*instrumentingAgents);
return InspectorInstrumentationCookie();
}

inline void InspectorInstrumentation::didReceiveResourceResponse(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response, ResourceLoader* resourceLoader)
{
// Call this unconditionally so that we're able to log to console with no front-end attached.
didReceiveResourceResponseImpl(cookie, identifier, loader, response, resourceLoader);
}

inline void InspectorInstrumentation::continueAfterXFrameOptionsDenied(Frame* frame, DocumentLoader& loader, unsigned long identifier, const ResourceResponse& r)
{
FAST_RETURN_IF_NO_FRONTENDS(void());
InspectorInstrumentation::continueAfterXFrameOptionsDeniedImpl(frame, loader, identifier, r);
}

inline void InspectorInstrumentation::continueWithPolicyDownload(Frame* frame, DocumentLoader& loader, unsigned long identifier, const ResourceResponse& r)
{
FAST_RETURN_IF_NO_FRONTENDS(void());
InspectorInstrumentation::continueWithPolicyDownloadImpl(frame, loader, identifier, r);
}

inline void InspectorInstrumentation::continueWithPolicyIgnore(Frame* frame, DocumentLoader& loader, unsigned long identifier, const ResourceResponse& r)
{
FAST_RETURN_IF_NO_FRONTENDS(void());
InspectorInstrumentation::continueWithPolicyIgnoreImpl(frame, loader, identifier, r);
didReceiveResourceResponseImpl(*instrumentingAgents, identifier, loader, response, resourceLoader);
}

inline void InspectorInstrumentation::didReceiveThreadableLoaderResponse(DocumentThreadableLoader& documentThreadableLoader, unsigned long identifier)
@@ -905,6 +875,27 @@ inline void InspectorInstrumentation::didFailLoading(Frame* frame, DocumentLoade
didFailLoadingImpl(*instrumentingAgents, identifier, loader, error);
}

inline void InspectorInstrumentation::continueAfterXFrameOptionsDenied(Frame& frame, unsigned long identifier, DocumentLoader& loader, const ResourceResponse& response)
{
// Treat the same as didReceiveResponse.
if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
didReceiveResourceResponseImpl(*instrumentingAgents, identifier, &loader, response, nullptr);
}

inline void InspectorInstrumentation::continueWithPolicyDownload(Frame& frame, unsigned long identifier, DocumentLoader& loader, const ResourceResponse& response)
{
// Treat the same as didReceiveResponse.
if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
didReceiveResourceResponseImpl(*instrumentingAgents, identifier, &loader, response, nullptr);
}

inline void InspectorInstrumentation::continueWithPolicyIgnore(Frame& frame, unsigned long identifier, DocumentLoader& loader, const ResourceResponse& response)
{
// Treat the same as didReceiveResponse.
if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
didReceiveResourceResponseImpl(*instrumentingAgents, identifier, &loader, response, nullptr);
}

inline void InspectorInstrumentation::didFinishXHRLoading(ScriptExecutionContext* context, unsigned long identifier, std::optional<String> decodedText, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber)
{
if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
@@ -83,8 +83,7 @@ void CrossOriginPreflightChecker::validatePreflightResponse(DocumentThreadableLo
// FIXME: <https://webkit.org/b/164889> Web Inspector: Show Preflight Request information in inspector
// This is only showing success preflight requests and responses but we should show network events
// for preflight failures and distinguish them better from non-preflight requests.
auto cookie = InspectorInstrumentation::willReceiveResourceResponse(frame);
InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, frame->loader().documentLoader(), response, nullptr);
InspectorInstrumentation::didReceiveResourceResponse(*frame, identifier, frame->loader().documentLoader(), response, nullptr);
InspectorInstrumentation::didFinishLoading(frame, frame->loader().documentLoader(), identifier, 0);

CrossOriginPreflightResultCache::singleton().appendEntry(loader.securityOrigin().toString(), request.url(), WTFMove(result));
@@ -639,7 +639,7 @@ void DocumentLoader::continueAfterNavigationPolicy(const ResourceRequest&, bool

void DocumentLoader::stopLoadingAfterXFrameOptionsOrContentSecurityPolicyDenied(unsigned long identifier, const ResourceResponse& response)
{
InspectorInstrumentation::continueAfterXFrameOptionsDenied(m_frame, *this, identifier, response);
InspectorInstrumentation::continueAfterXFrameOptionsDenied(*m_frame, identifier, *this, response);
m_frame->document()->enforceSandboxFlags(SandboxOrigin);
if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement())
ownerElement->dispatchEvent(Event::create(eventNames().loadEvent, false, false));
@@ -798,7 +798,7 @@ void DocumentLoader::continueAfterContentPolicy(PolicyAction policy)
}

if (ResourceLoader* mainResourceLoader = this->mainResourceLoader())
InspectorInstrumentation::continueWithPolicyDownload(m_frame, *this, mainResourceLoader->identifier(), m_response);
InspectorInstrumentation::continueWithPolicyDownload(*m_frame, mainResourceLoader->identifier(), *this, m_response);

// When starting the request, we didn't know that it would result in download and not navigation. Now we know that main document URL didn't change.
// Download may use this knowledge for purposes unrelated to cookies, notably for setting file quarantine data.
@@ -821,7 +821,7 @@ void DocumentLoader::continueAfterContentPolicy(PolicyAction policy)
}
case PolicyIgnore:
if (ResourceLoader* mainResourceLoader = this->mainResourceLoader())
InspectorInstrumentation::continueWithPolicyIgnore(m_frame, *this, mainResourceLoader->identifier(), m_response);
InspectorInstrumentation::continueWithPolicyIgnore(*m_frame, mainResourceLoader->identifier(), *this, m_response);
stopLoadingForPolicyChange();
return;
}
@@ -147,8 +147,7 @@ void ResourceLoadNotifier::dispatchDidReceiveResponse(DocumentLoader* loader, un
Ref<Frame> protect(m_frame);
m_frame.loader().client().dispatchDidReceiveResponse(loader, identifier, r);

InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(&m_frame);
InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, loader, r, resourceLoader);
InspectorInstrumentation::didReceiveResourceResponse(m_frame, identifier, loader, r, resourceLoader);
}

void ResourceLoadNotifier::dispatchDidReceiveData(DocumentLoader* loader, unsigned long identifier, const char* data, int dataLength, int encodedDataLength)
@@ -492,8 +492,7 @@ RefPtr<ResourceHandle> ApplicationCacheGroup::createResourceHandle(const URL& ur
void ApplicationCacheGroup::didReceiveResponse(ResourceHandle* handle, ResourceResponse&& response)
{
ASSERT(m_frame);
InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(m_frame);
InspectorInstrumentation::didReceiveResourceResponse(cookie, m_currentResourceIdentifier, m_frame->loader().documentLoader(), response, 0);
InspectorInstrumentation::didReceiveResourceResponse(*m_frame, m_currentResourceIdentifier, m_frame->loader().documentLoader(), response, nullptr);

if (handle == m_manifestHandle) {
didReceiveManifestResponse(response);

0 comments on commit 6639fc6

Please sign in to comment.