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/FetchInitiatorTypeNames.h" | 8 #include "core/FetchInitiatorTypeNames.h" |
9 #include "core/css/CSSStyleSheet.h" | 9 #include "core/css/CSSStyleSheet.h" |
10 #include "core/css/StyleSheetContents.h" | 10 #include "core/css/StyleSheetContents.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 ResourcePtr<Resource> resource = document->fetcher()->fetchRawResour
ce(request); | 110 ResourcePtr<Resource> resource = document->fetcher()->fetchRawResour
ce(request); |
111 if (resource) { | 111 if (resource) { |
112 // Prevent garbage collection by holding a reference to this res
ource. | 112 // Prevent garbage collection by holding a reference to this res
ource. |
113 m_resources.append(resource.get()); | 113 m_resources.append(resource.get()); |
114 ResourceClient* resourceClient = new ResourceClient(this); | 114 ResourceClient* resourceClient = new ResourceClient(this); |
115 m_pendingResourceClients.add(resourceClient); | 115 m_pendingResourceClients.add(resourceClient); |
116 resourceClient->waitForResource(resource.get()); | 116 resourceClient->waitForResource(resource.get()); |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > styleSheets; | 120 WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet>> styleSheets; |
121 InspectorCSSAgent::collectAllDocumentStyleSheets(document, styleSheets); | 121 InspectorCSSAgent::collectAllDocumentStyleSheets(document, styleSheets); |
122 for (CSSStyleSheet* styleSheet : styleSheets) { | 122 for (CSSStyleSheet* styleSheet : styleSheets) { |
123 if (styleSheet->isInline() || !styleSheet->contents()->loadCompleted
()) | 123 if (styleSheet->isInline() || !styleSheet->contents()->loadCompleted
()) |
124 continue; | 124 continue; |
125 String url = styleSheet->baseURL().string(); | 125 String url = styleSheet->baseURL().string(); |
126 if (url.isEmpty() || urlsToFetch.contains(url)) | 126 if (url.isEmpty() || urlsToFetch.contains(url)) |
127 continue; | 127 continue; |
128 urlsToFetch.add(url); | 128 urlsToFetch.add(url); |
129 FetchRequest request(ResourceRequest(url), FetchInitiatorTypeNames::
internal); | 129 FetchRequest request(ResourceRequest(url), FetchInitiatorTypeNames::
internal); |
130 request.mutableResourceRequest().setRequestContext(blink::WebURLRequ
est::RequestContextInternal); | 130 request.mutableResourceRequest().setRequestContext(blink::WebURLRequ
est::RequestContextInternal); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 180 |
181 bool InspectorResourceContentLoader::hasFinished() | 181 bool InspectorResourceContentLoader::hasFinished() |
182 { | 182 { |
183 return m_allRequestsStarted && m_pendingResourceClients.size() == 0; | 183 return m_allRequestsStarted && m_pendingResourceClients.size() == 0; |
184 } | 184 } |
185 | 185 |
186 void InspectorResourceContentLoader::checkDone() | 186 void InspectorResourceContentLoader::checkDone() |
187 { | 187 { |
188 if (!hasFinished()) | 188 if (!hasFinished()) |
189 return; | 189 return; |
190 PersistentHeapVectorWillBeHeapVector<Member<VoidCallback> > callbacks; | 190 PersistentHeapVectorWillBeHeapVector<Member<VoidCallback>> callbacks; |
191 callbacks.swap(m_callbacks); | 191 callbacks.swap(m_callbacks); |
192 for (const auto& callback : callbacks) | 192 for (const auto& callback : callbacks) |
193 callback->handleEvent(); | 193 callback->handleEvent(); |
194 } | 194 } |
195 | 195 |
196 void InspectorResourceContentLoader::resourceFinished(ResourceClient* client) | 196 void InspectorResourceContentLoader::resourceFinished(ResourceClient* client) |
197 { | 197 { |
198 m_pendingResourceClients.remove(client); | 198 m_pendingResourceClients.remove(client); |
199 checkDone(); | 199 checkDone(); |
200 } | 200 } |
201 | 201 |
202 } // namespace blink | 202 } // namespace blink |
OLD | NEW |