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

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

Issue 1738073002: DevTools: introduce protocol::Value, baseline for hierarchical data in remote debugging protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "core/inspector/IdentifiersFactory.h" 51 #include "core/inspector/IdentifiersFactory.h"
52 #include "core/inspector/InspectedFrames.h" 52 #include "core/inspector/InspectedFrames.h"
53 #include "core/inspector/InstrumentingAgents.h" 53 #include "core/inspector/InstrumentingAgents.h"
54 #include "core/inspector/NetworkResourcesData.h" 54 #include "core/inspector/NetworkResourcesData.h"
55 #include "core/loader/DocumentLoader.h" 55 #include "core/loader/DocumentLoader.h"
56 #include "core/loader/FrameLoader.h" 56 #include "core/loader/FrameLoader.h"
57 #include "core/loader/MixedContentChecker.h" 57 #include "core/loader/MixedContentChecker.h"
58 #include "core/loader/ThreadableLoaderClient.h" 58 #include "core/loader/ThreadableLoaderClient.h"
59 #include "core/page/Page.h" 59 #include "core/page/Page.h"
60 #include "core/xmlhttprequest/XMLHttpRequest.h" 60 #include "core/xmlhttprequest/XMLHttpRequest.h"
61 #include "platform/JSONValues.h"
62 #include "platform/blob/BlobData.h" 61 #include "platform/blob/BlobData.h"
63 #include "platform/inspector_protocol/Frontend.h" 62 #include "platform/inspector_protocol/Frontend.h"
63 #include "platform/inspector_protocol/Values.h"
64 #include "platform/network/HTTPHeaderMap.h" 64 #include "platform/network/HTTPHeaderMap.h"
65 #include "platform/network/ResourceError.h" 65 #include "platform/network/ResourceError.h"
66 #include "platform/network/ResourceLoadPriority.h" 66 #include "platform/network/ResourceLoadPriority.h"
67 #include "platform/network/ResourceLoadTiming.h" 67 #include "platform/network/ResourceLoadTiming.h"
68 #include "platform/network/ResourceRequest.h" 68 #include "platform/network/ResourceRequest.h"
69 #include "platform/network/ResourceResponse.h" 69 #include "platform/network/ResourceResponse.h"
70 #include "platform/network/WebSocketHandshakeRequest.h" 70 #include "platform/network/WebSocketHandshakeRequest.h"
71 #include "platform/network/WebSocketHandshakeResponse.h" 71 #include "platform/network/WebSocketHandshakeResponse.h"
72 #include "platform/weborigin/KURL.h" 72 #include "platform/weborigin/KURL.h"
73 #include "public/platform/WebURLRequest.h" 73 #include "public/platform/WebURLRequest.h"
(...skipping 30 matching lines...) Expand all
104 pos = url.find(part, pos); 104 pos = url.find(part, pos);
105 if (pos == kNotFound) 105 if (pos == kNotFound)
106 return false; 106 return false;
107 pos += part.length(); 107 pos += part.length();
108 } 108 }
109 return true; 109 return true;
110 } 110 }
111 111
112 static PassOwnPtr<protocol::Network::Headers> buildObjectForHeaders(const HTTPHe aderMap& headers) 112 static PassOwnPtr<protocol::Network::Headers> buildObjectForHeaders(const HTTPHe aderMap& headers)
113 { 113 {
114 RefPtr<JSONObject> headersObject = JSONObject::create(); 114 RefPtr<protocol::DictionaryValue> headersObject = protocol::DictionaryValue: :create();
115 for (const auto& header : headers) 115 for (const auto& header : headers)
116 headersObject->setString(header.key.string(), header.value); 116 headersObject->setString(header.key.string(), header.value);
117 protocol::ErrorSupport errors; 117 protocol::ErrorSupport errors;
118 return protocol::Network::Headers::parse(headersObject, &errors); 118 return protocol::Network::Headers::parse(headersObject, &errors);
119 } 119 }
120 120
121 class InspectorFileReaderLoaderClient final : public FileReaderLoaderClient { 121 class InspectorFileReaderLoaderClient final : public FileReaderLoaderClient {
122 WTF_MAKE_NONCOPYABLE(InspectorFileReaderLoaderClient); 122 WTF_MAKE_NONCOPYABLE(InspectorFileReaderLoaderClient);
123 public: 123 public:
124 InspectorFileReaderLoaderClient(PassRefPtr<BlobDataHandle> blob, PassOwnPtr< TextResourceDecoder> decoder, PassRefPtr<GetResponseBodyCallback> callback) 124 InspectorFileReaderLoaderClient(PassRefPtr<BlobDataHandle> blob, PassOwnPtr< TextResourceDecoder> decoder, PassRefPtr<GetResponseBodyCallback> callback)
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 293
294 double status; 294 double status;
295 String statusText; 295 String statusText;
296 if (response.resourceLoadInfo() && response.resourceLoadInfo()->httpStatusCo de) { 296 if (response.resourceLoadInfo() && response.resourceLoadInfo()->httpStatusCo de) {
297 status = response.resourceLoadInfo()->httpStatusCode; 297 status = response.resourceLoadInfo()->httpStatusCode;
298 statusText = response.resourceLoadInfo()->httpStatusText; 298 statusText = response.resourceLoadInfo()->httpStatusText;
299 } else { 299 } else {
300 status = response.httpStatusCode(); 300 status = response.httpStatusCode();
301 statusText = response.httpStatusText(); 301 statusText = response.httpStatusText();
302 } 302 }
303 RefPtr<JSONObject> headers; 303 RefPtr<protocol::DictionaryValue> headers;
304 HTTPHeaderMap headersMap; 304 HTTPHeaderMap headersMap;
305 if (response.resourceLoadInfo() && response.resourceLoadInfo()->responseHead ers.size()) 305 if (response.resourceLoadInfo() && response.resourceLoadInfo()->responseHead ers.size())
306 headersMap = response.resourceLoadInfo()->responseHeaders; 306 headersMap = response.resourceLoadInfo()->responseHeaders;
307 else 307 else
308 headersMap = response.httpHeaderFields(); 308 headersMap = response.httpHeaderFields();
309 309
310 int64_t encodedDataLength = response.resourceLoadInfo() ? response.resourceL oadInfo()->encodedDataLength : -1; 310 int64_t encodedDataLength = response.resourceLoadInfo() ? response.resourceL oadInfo()->encodedDataLength : -1;
311 311
312 String securityState = protocol::Security::SecurityStateEnum::Unknown; 312 String securityState = protocol::Security::SecurityStateEnum::Unknown;
313 switch (response.securityStyle()) { 313 switch (response.securityStyle()) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 visitor->trace(m_inspectedFrames); 432 visitor->trace(m_inspectedFrames);
433 visitor->trace(m_resourcesData); 433 visitor->trace(m_resourcesData);
434 visitor->trace(m_replayXHRs); 434 visitor->trace(m_replayXHRs);
435 visitor->trace(m_replayXHRsToBeDeleted); 435 visitor->trace(m_replayXHRsToBeDeleted);
436 visitor->trace(m_pendingXHRReplayData); 436 visitor->trace(m_pendingXHRReplayData);
437 InspectorBaseAgent::trace(visitor); 437 InspectorBaseAgent::trace(visitor);
438 } 438 }
439 439
440 bool InspectorResourceAgent::shouldBlockRequest(const ResourceRequest& request) 440 bool InspectorResourceAgent::shouldBlockRequest(const ResourceRequest& request)
441 { 441 {
442 RefPtr<JSONObject> blockedURLs = m_state->getObject(ResourceAgentState::bloc kedURLs); 442 RefPtr<protocol::DictionaryValue> blockedURLs = m_state->getObject(ResourceA gentState::blockedURLs);
443 if (!blockedURLs) 443 if (!blockedURLs)
444 return false; 444 return false;
445 String url = request.url().string(); 445 String url = request.url().string();
446 for (const auto& entry : *blockedURLs) { 446 for (const auto& entry : *blockedURLs) {
447 if (matches(url, entry.key)) 447 if (matches(url, entry.key))
448 return true; 448 return true;
449 } 449 }
450 return false; 450 return false;
451 } 451 }
452 452
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 495
496 void InspectorResourceAgent::willSendRequest(LocalFrame* frame, unsigned long id entifier, DocumentLoader* loader, ResourceRequest& request, const ResourceRespon se& redirectResponse, const FetchInitiatorInfo& initiatorInfo) 496 void InspectorResourceAgent::willSendRequest(LocalFrame* frame, unsigned long id entifier, DocumentLoader* loader, ResourceRequest& request, const ResourceRespon se& redirectResponse, const FetchInitiatorInfo& initiatorInfo)
497 { 497 {
498 // Ignore the request initiated internally. 498 // Ignore the request initiated internally.
499 if (initiatorInfo.name == FetchInitiatorTypeNames::internal) 499 if (initiatorInfo.name == FetchInitiatorTypeNames::internal)
500 return; 500 return;
501 501
502 if (initiatorInfo.name == FetchInitiatorTypeNames::document && loader->subst ituteData().isValid()) 502 if (initiatorInfo.name == FetchInitiatorTypeNames::document && loader->subst ituteData().isValid())
503 return; 503 return;
504 504
505 RefPtr<JSONObject> headers = m_state->getObject(ResourceAgentState::extraReq uestHeaders); 505 RefPtr<protocol::DictionaryValue> headers = m_state->getObject(ResourceAgent State::extraRequestHeaders);
506 if (headers) { 506 if (headers) {
507 for (const auto& header : *headers) { 507 for (const auto& header : *headers) {
508 String value; 508 String value;
509 if (header.value->asString(&value)) 509 if (header.value->asString(&value))
510 request.setHTTPHeaderField(AtomicString(header.key), AtomicStrin g(value)); 510 request.setHTTPHeaderField(AtomicString(header.key), AtomicStrin g(value));
511 } 511 }
512 } 512 }
513 513
514 request.setReportRawHeaders(true); 514 request.setReportRawHeaders(true);
515 515
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 } 960 }
961 961
962 if (getResponseBodyBlob(requestId, callback)) 962 if (getResponseBodyBlob(requestId, callback))
963 return; 963 return;
964 964
965 callback->sendFailure("No data found for resource with given identifier"); 965 callback->sendFailure("No data found for resource with given identifier");
966 } 966 }
967 967
968 void InspectorResourceAgent::addBlockedURL(ErrorString*, const String& url) 968 void InspectorResourceAgent::addBlockedURL(ErrorString*, const String& url)
969 { 969 {
970 RefPtr<JSONObject> blockedURLs = m_state->getObject(ResourceAgentState::bloc kedURLs); 970 RefPtr<protocol::DictionaryValue> blockedURLs = m_state->getObject(ResourceA gentState::blockedURLs);
971 if (!blockedURLs) { 971 if (!blockedURLs) {
972 blockedURLs = JSONObject::create(); 972 blockedURLs = protocol::DictionaryValue::create();
973 m_state->setObject(ResourceAgentState::blockedURLs, blockedURLs); 973 m_state->setObject(ResourceAgentState::blockedURLs, blockedURLs);
974 } 974 }
975 blockedURLs->setBoolean(url, true); 975 blockedURLs->setBoolean(url, true);
976 } 976 }
977 977
978 void InspectorResourceAgent::removeBlockedURL(ErrorString*, const String& url) 978 void InspectorResourceAgent::removeBlockedURL(ErrorString*, const String& url)
979 { 979 {
980 RefPtr<JSONObject> blockedURLs = m_state->getObject(ResourceAgentState::bloc kedURLs); 980 RefPtr<protocol::DictionaryValue> blockedURLs = m_state->getObject(ResourceA gentState::blockedURLs);
981 if (blockedURLs) 981 if (blockedURLs)
982 blockedURLs->remove(url); 982 blockedURLs->remove(url);
983 } 983 }
984 984
985 void InspectorResourceAgent::replayXHR(ErrorString*, const String& requestId) 985 void InspectorResourceAgent::replayXHR(ErrorString*, const String& requestId)
986 { 986 {
987 String actualRequestId = requestId; 987 String actualRequestId = requestId;
988 988
989 XHRReplayData* xhrReplayData = m_resourcesData->xhrReplayData(requestId); 989 XHRReplayData* xhrReplayData = m_resourcesData->xhrReplayData(requestId);
990 if (!xhrReplayData) 990 if (!xhrReplayData)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish edReplayXHRFired) 1102 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish edReplayXHRFired)
1103 { 1103 {
1104 } 1104 }
1105 1105
1106 bool InspectorResourceAgent::shouldForceCORSPreflight() 1106 bool InspectorResourceAgent::shouldForceCORSPreflight()
1107 { 1107 {
1108 return m_state->booleanProperty(ResourceAgentState::cacheDisabled, false); 1108 return m_state->booleanProperty(ResourceAgentState::cacheDisabled, false);
1109 } 1109 }
1110 1110
1111 } // namespace blink 1111 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698