| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 FrameLoader::resourceRequestFromHistoryItem(item, ReturnCacheDat
aDontLoad); | 102 FrameLoader::resourceRequestFromHistoryItem(item, ReturnCacheDat
aDontLoad); |
| 103 } else { | 103 } else { |
| 104 resourceRequest = document->url(); | 104 resourceRequest = document->url(); |
| 105 resourceRequest.setCachePolicy(ReturnCacheDataDontLoad); | 105 resourceRequest.setCachePolicy(ReturnCacheDataDontLoad); |
| 106 } | 106 } |
| 107 resourceRequest.setRequestContext(WebURLRequest::RequestContextInternal)
; | 107 resourceRequest.setRequestContext(WebURLRequest::RequestContextInternal)
; |
| 108 | 108 |
| 109 if (!resourceRequest.url().string().isEmpty()) { | 109 if (!resourceRequest.url().string().isEmpty()) { |
| 110 urlsToFetch.add(resourceRequest.url().string()); | 110 urlsToFetch.add(resourceRequest.url().string()); |
| 111 FetchRequest request(resourceRequest, FetchInitiatorTypeNames::inter
nal); | 111 FetchRequest request(resourceRequest, FetchInitiatorTypeNames::inter
nal); |
| 112 ResourcePtr<Resource> resource = document->fetcher()->fetchRawResour
ce(request); | 112 ResourcePtr<Resource> resource = RawResource::fetch(request, documen
t->fetcher()); |
| 113 if (resource) { | 113 if (resource) { |
| 114 // Prevent garbage collection by holding a reference to this res
ource. | 114 // Prevent garbage collection by holding a reference to this res
ource. |
| 115 m_resources.append(resource.get()); | 115 m_resources.append(resource.get()); |
| 116 ResourceClient* resourceClient = new ResourceClient(this); | 116 ResourceClient* resourceClient = new ResourceClient(this); |
| 117 m_pendingResourceClients.add(resourceClient); | 117 m_pendingResourceClients.add(resourceClient); |
| 118 resourceClient->waitForResource(resource.get()); | 118 resourceClient->waitForResource(resource.get()); |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 | 121 |
| 122 WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > styleSheets; | 122 WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > styleSheets; |
| 123 InspectorCSSAgent::collectAllDocumentStyleSheets(document, styleSheets); | 123 InspectorCSSAgent::collectAllDocumentStyleSheets(document, styleSheets); |
| 124 for (CSSStyleSheet* styleSheet : styleSheets) { | 124 for (CSSStyleSheet* styleSheet : styleSheets) { |
| 125 if (styleSheet->isInline() || !styleSheet->contents()->loadCompleted
()) | 125 if (styleSheet->isInline() || !styleSheet->contents()->loadCompleted
()) |
| 126 continue; | 126 continue; |
| 127 String url = styleSheet->baseURL().string(); | 127 String url = styleSheet->baseURL().string(); |
| 128 if (url.isEmpty() || urlsToFetch.contains(url)) | 128 if (url.isEmpty() || urlsToFetch.contains(url)) |
| 129 continue; | 129 continue; |
| 130 urlsToFetch.add(url); | 130 urlsToFetch.add(url); |
| 131 FetchRequest request(ResourceRequest(url), FetchInitiatorTypeNames::
internal); | 131 FetchRequest request(ResourceRequest(url), FetchInitiatorTypeNames::
internal); |
| 132 request.mutableResourceRequest().setRequestContext(WebURLRequest::Re
questContextInternal); | 132 request.mutableResourceRequest().setRequestContext(WebURLRequest::Re
questContextInternal); |
| 133 ResourcePtr<Resource> resource = document->fetcher()->fetchCSSStyleS
heet(request); | 133 ResourcePtr<Resource> resource = CSSStyleSheetResource::fetch(reques
t, document->fetcher()); |
| 134 if (!resource) | 134 if (!resource) |
| 135 continue; | 135 continue; |
| 136 // Prevent garbage collection by holding a reference to this resourc
e. | 136 // Prevent garbage collection by holding a reference to this resourc
e. |
| 137 m_resources.append(resource.get()); | 137 m_resources.append(resource.get()); |
| 138 ResourceClient* resourceClient = new ResourceClient(this); | 138 ResourceClient* resourceClient = new ResourceClient(this); |
| 139 m_pendingResourceClients.add(resourceClient); | 139 m_pendingResourceClients.add(resourceClient); |
| 140 resourceClient->waitForResource(resource.get()); | 140 resourceClient->waitForResource(resource.get()); |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 callback->handleEvent(); | 195 callback->handleEvent(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void InspectorResourceContentLoader::resourceFinished(ResourceClient* client) | 198 void InspectorResourceContentLoader::resourceFinished(ResourceClient* client) |
| 199 { | 199 { |
| 200 m_pendingResourceClients.remove(client); | 200 m_pendingResourceClients.remove(client); |
| 201 checkDone(); | 201 checkDone(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 } // namespace blink | 204 } // namespace blink |
| OLD | NEW |