| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/inspector/InspectorResourceContentLoader.h" | 6 #include "core/inspector/InspectorResourceContentLoader.h" |
| 7 | 7 |
| 8 #include "core/css/CSSStyleSheet.h" | 8 #include "core/css/CSSStyleSheet.h" |
| 9 #include "core/css/StyleSheetContents.h" | 9 #include "core/css/StyleSheetContents.h" |
| 10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 HashSet<String> urlsToFetch; | 96 HashSet<String> urlsToFetch; |
| 97 | 97 |
| 98 ResourceRequest resourceRequest; | 98 ResourceRequest resourceRequest; |
| 99 HistoryItem* item = document->frame() ? document->frame()->loader().curr
entItem() : nullptr; | 99 HistoryItem* item = document->frame() ? document->frame()->loader().curr
entItem() : nullptr; |
| 100 if (item) { | 100 if (item) { |
| 101 resourceRequest = FrameLoader::requestFromHistoryItem(item, ReturnCa
cheDataDontLoad); | 101 resourceRequest = FrameLoader::requestFromHistoryItem(item, ReturnCa
cheDataDontLoad); |
| 102 } else { | 102 } else { |
| 103 resourceRequest = document->url(); | 103 resourceRequest = document->url(); |
| 104 resourceRequest.setCachePolicy(ReturnCacheDataDontLoad); | 104 resourceRequest.setCachePolicy(ReturnCacheDataDontLoad); |
| 105 } | 105 } |
| 106 resourceRequest.setRequestContext(blink::WebURLRequest::RequestContextIn
ternal); | 106 resourceRequest.setRequestContext(WebURLRequest::RequestContextInternal)
; |
| 107 | 107 |
| 108 if (!resourceRequest.url().string().isEmpty()) { | 108 if (!resourceRequest.url().string().isEmpty()) { |
| 109 urlsToFetch.add(resourceRequest.url().string()); | 109 urlsToFetch.add(resourceRequest.url().string()); |
| 110 FetchRequest request(resourceRequest, FetchInitiatorTypeNames::inter
nal); | 110 FetchRequest request(resourceRequest, FetchInitiatorTypeNames::inter
nal); |
| 111 ResourcePtr<Resource> resource = document->fetcher()->fetchRawResour
ce(request); | 111 ResourcePtr<Resource> resource = document->fetcher()->fetchRawResour
ce(request); |
| 112 if (resource) { | 112 if (resource) { |
| 113 // Prevent garbage collection by holding a reference to this res
ource. | 113 // Prevent garbage collection by holding a reference to this res
ource. |
| 114 m_resources.append(resource.get()); | 114 m_resources.append(resource.get()); |
| 115 ResourceClient* resourceClient = new ResourceClient(this); | 115 ResourceClient* resourceClient = new ResourceClient(this); |
| 116 m_pendingResourceClients.add(resourceClient); | 116 m_pendingResourceClients.add(resourceClient); |
| 117 resourceClient->waitForResource(resource.get()); | 117 resourceClient->waitForResource(resource.get()); |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > styleSheets; | 121 WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > styleSheets; |
| 122 InspectorCSSAgent::collectAllDocumentStyleSheets(document, styleSheets); | 122 InspectorCSSAgent::collectAllDocumentStyleSheets(document, styleSheets); |
| 123 for (CSSStyleSheet* styleSheet : styleSheets) { | 123 for (CSSStyleSheet* styleSheet : styleSheets) { |
| 124 if (styleSheet->isInline() || !styleSheet->contents()->loadCompleted
()) | 124 if (styleSheet->isInline() || !styleSheet->contents()->loadCompleted
()) |
| 125 continue; | 125 continue; |
| 126 String url = styleSheet->baseURL().string(); | 126 String url = styleSheet->baseURL().string(); |
| 127 if (url.isEmpty() || urlsToFetch.contains(url)) | 127 if (url.isEmpty() || urlsToFetch.contains(url)) |
| 128 continue; | 128 continue; |
| 129 urlsToFetch.add(url); | 129 urlsToFetch.add(url); |
| 130 FetchRequest request(ResourceRequest(url), FetchInitiatorTypeNames::
internal); | 130 FetchRequest request(ResourceRequest(url), FetchInitiatorTypeNames::
internal); |
| 131 request.mutableResourceRequest().setRequestContext(blink::WebURLRequ
est::RequestContextInternal); | 131 request.mutableResourceRequest().setRequestContext(WebURLRequest::Re
questContextInternal); |
| 132 ResourcePtr<Resource> resource = document->fetcher()->fetchCSSStyleS
heet(request); | 132 ResourcePtr<Resource> resource = document->fetcher()->fetchCSSStyleS
heet(request); |
| 133 if (!resource) | 133 if (!resource) |
| 134 continue; | 134 continue; |
| 135 // Prevent garbage collection by holding a reference to this resourc
e. | 135 // Prevent garbage collection by holding a reference to this resourc
e. |
| 136 m_resources.append(resource.get()); | 136 m_resources.append(resource.get()); |
| 137 ResourceClient* resourceClient = new ResourceClient(this); | 137 ResourceClient* resourceClient = new ResourceClient(this); |
| 138 m_pendingResourceClients.add(resourceClient); | 138 m_pendingResourceClients.add(resourceClient); |
| 139 resourceClient->waitForResource(resource.get()); | 139 resourceClient->waitForResource(resource.get()); |
| 140 } | 140 } |
| 141 } | 141 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 callback->handleEvent(); | 194 callback->handleEvent(); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void InspectorResourceContentLoader::resourceFinished(ResourceClient* client) | 197 void InspectorResourceContentLoader::resourceFinished(ResourceClient* client) |
| 198 { | 198 { |
| 199 m_pendingResourceClients.remove(client); | 199 m_pendingResourceClients.remove(client); |
| 200 checkDone(); | 200 checkDone(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 } // namespace blink | 203 } // namespace blink |
| OLD | NEW |