Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: Source/core/inspector/InspectorResourceAgent.cpp

Issue 1315043008: [DevTools] Show blocked requests in Network panel. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/inspector/InspectorResourceAgent.h ('k') | Source/core/loader/FrameFetchContext.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 case ResourceLoadPriorityLow: return TypeBuilder::Network::ResourcePriority: :Low; 201 case ResourceLoadPriorityLow: return TypeBuilder::Network::ResourcePriority: :Low;
202 case ResourceLoadPriorityMedium: return TypeBuilder::Network::ResourcePriori ty::Medium; 202 case ResourceLoadPriorityMedium: return TypeBuilder::Network::ResourcePriori ty::Medium;
203 case ResourceLoadPriorityHigh: return TypeBuilder::Network::ResourcePriority ::High; 203 case ResourceLoadPriorityHigh: return TypeBuilder::Network::ResourcePriority ::High;
204 case ResourceLoadPriorityVeryHigh: return TypeBuilder::Network::ResourcePrio rity::VeryHigh; 204 case ResourceLoadPriorityVeryHigh: return TypeBuilder::Network::ResourcePrio rity::VeryHigh;
205 case ResourceLoadPriorityUnresolved: break; 205 case ResourceLoadPriorityUnresolved: break;
206 } 206 }
207 ASSERT_NOT_REACHED(); 207 ASSERT_NOT_REACHED();
208 return TypeBuilder::Network::ResourcePriority::Medium; 208 return TypeBuilder::Network::ResourcePriority::Medium;
209 } 209 }
210 210
211 TypeBuilder::Network::BlockedReason::Enum buildBlockedReason(ResourceRequestBloc kedReason reason)
212 {
213 switch (reason) {
214 case ResourceRequestBlockedReasonCSP:
215 return TypeBuilder::Network::BlockedReason::Enum::Csp;
216 case ResourceRequestBlockedReasonMixedContent:
217 return TypeBuilder::Network::BlockedReason::Enum::Mixed_content;
218 case ResourceRequestBlockedReasonOrigin:
219 return TypeBuilder::Network::BlockedReason::Enum::Origin;
220 case ResourceRequestBlockedReasonInspector:
221 return TypeBuilder::Network::BlockedReason::Enum::Inspector;
222 case ResourceRequestBlockedReasonOther:
223 return TypeBuilder::Network::BlockedReason::Enum::Other;
224 case ResourceRequestBlockedReasonNone:
225 default:
226 ASSERT_NOT_REACHED();
227 return TypeBuilder::Network::BlockedReason::Enum::Other;
228 }
229 }
211 230
212 } // namespace 231 } // namespace
213 232
214 void InspectorResourceAgent::restore() 233 void InspectorResourceAgent::restore()
215 { 234 {
216 if (m_state->getBoolean(ResourceAgentState::resourceAgentEnabled)) 235 if (m_state->getBoolean(ResourceAgentState::resourceAgentEnabled))
217 enable(); 236 enable();
218 } 237 }
219 238
220 static PassRefPtr<TypeBuilder::Network::ResourceTiming> buildObjectForTiming(con st ResourceLoadTiming& timing) 239 static PassRefPtr<TypeBuilder::Network::ResourceTiming> buildObjectForTiming(con st ResourceLoadTiming& timing)
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 395
377 DEFINE_TRACE(InspectorResourceAgent) 396 DEFINE_TRACE(InspectorResourceAgent)
378 { 397 {
379 visitor->trace(m_pageAgent); 398 visitor->trace(m_pageAgent);
380 visitor->trace(m_replayXHRs); 399 visitor->trace(m_replayXHRs);
381 visitor->trace(m_replayXHRsToBeDeleted); 400 visitor->trace(m_replayXHRsToBeDeleted);
382 visitor->trace(m_pendingXHRReplayData); 401 visitor->trace(m_pendingXHRReplayData);
383 InspectorBaseAgent::trace(visitor); 402 InspectorBaseAgent::trace(visitor);
384 } 403 }
385 404
386 bool InspectorResourceAgent::shouldBlockRequest(LocalFrame* frame, const Resourc eRequest& request, DocumentLoader* loader, const FetchInitiatorInfo& initiatorIn fo) 405 bool InspectorResourceAgent::shouldBlockRequest(const ResourceRequest& request)
387 { 406 {
388 String url = request.url().string(); 407 String url = request.url().string();
389 RefPtr<JSONObject> blockedURLs = m_state->getObject(ResourceAgentState::bloc kedURLs); 408 RefPtr<JSONObject> blockedURLs = m_state->getObject(ResourceAgentState::bloc kedURLs);
390 for (const auto& entry : *blockedURLs) { 409 for (const auto& entry : *blockedURLs) {
391 if (url.contains(entry.key)) { 410 if (url.contains(entry.key))
392 unsigned long identifier = createUniqueIdentifier();
393 willSendRequestInternal(frame, identifier, loader, request, Resource Response(), initiatorInfo);
394
395 String requestId = IdentifiersFactory::requestId(identifier);
396 bool blocked = true;
397 frontend()->loadingFailed(requestId, monotonicallyIncreasingTime(), InspectorPageAgent::resourceTypeJson(m_resourcesData->resourceType(requestId)), String(), nullptr, &blocked);
398 return true; 411 return true;
399 }
400 } 412 }
401 return false; 413 return false;
402 } 414 }
403 415
416 void InspectorResourceAgent::didBlockRequest(LocalFrame* frame, const ResourceRe quest& request, DocumentLoader* loader, const FetchInitiatorInfo& initiatorInfo, ResourceRequestBlockedReason reason)
417 {
418 unsigned long identifier = createUniqueIdentifier();
419 willSendRequestInternal(frame, identifier, loader, request, ResourceResponse (), initiatorInfo);
420
421 String requestId = IdentifiersFactory::requestId(identifier);
422 TypeBuilder::Network::BlockedReason::Enum protocolReason = buildBlockedReaso n(reason);
423 frontend()->loadingFailed(requestId, monotonicallyIncreasingTime(), Inspecto rPageAgent::resourceTypeJson(m_resourcesData->resourceType(requestId)), String() , nullptr, &protocolReason);
424 }
425
404 void InspectorResourceAgent::willSendRequestInternal(LocalFrame* frame, unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiatorInfo& initiatorInfo) 426 void InspectorResourceAgent::willSendRequestInternal(LocalFrame* frame, unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiatorInfo& initiatorInfo)
405 { 427 {
406 String requestId = IdentifiersFactory::requestId(identifier); 428 String requestId = IdentifiersFactory::requestId(identifier);
407 String loaderId = IdentifiersFactory::loaderId(loader); 429 String loaderId = IdentifiersFactory::loaderId(loader);
408 m_resourcesData->resourceCreated(requestId, loaderId); 430 m_resourcesData->resourceCreated(requestId, loaderId);
409 431
410 InspectorPageAgent::ResourceType type = InspectorPageAgent::OtherResource; 432 InspectorPageAgent::ResourceType type = InspectorPageAgent::OtherResource;
411 if (initiatorInfo.name == FetchInitiatorTypeNames::xmlhttprequest) { 433 if (initiatorInfo.name == FetchInitiatorTypeNames::xmlhttprequest) {
412 type = InspectorPageAgent::XHRResource; 434 type = InspectorPageAgent::XHRResource;
413 m_resourcesData->setResourceType(requestId, type); 435 m_resourcesData->setResourceType(requestId, type);
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish edReplayXHRFired) 1083 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish edReplayXHRFired)
1062 { 1084 {
1063 } 1085 }
1064 1086
1065 bool InspectorResourceAgent::shouldForceCORSPreflight() 1087 bool InspectorResourceAgent::shouldForceCORSPreflight()
1066 { 1088 {
1067 return m_state->getBoolean(ResourceAgentState::cacheDisabled); 1089 return m_state->getBoolean(ResourceAgentState::cacheDisabled);
1068 } 1090 }
1069 1091
1070 } // namespace blink 1092 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorResourceAgent.h ('k') | Source/core/loader/FrameFetchContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698