| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 void InspectorResourceContentLoader::ResourceClient::setCSSStyleSheet(const Stri
ng&, const KURL& url, const String&, const CSSStyleSheetResource* resource) | 44 void InspectorResourceContentLoader::ResourceClient::setCSSStyleSheet(const Stri
ng&, const KURL& url, const String&, const CSSStyleSheetResource* resource) |
| 45 { | 45 { |
| 46 if (m_loader) | 46 if (m_loader) |
| 47 m_loader->resourceFinished(this); | 47 m_loader->resourceFinished(this); |
| 48 const_cast<CSSStyleSheetResource*>(resource)->removeClient(this); | 48 const_cast<CSSStyleSheetResource*>(resource)->removeClient(this); |
| 49 delete this; | 49 delete this; |
| 50 } | 50 } |
| 51 | 51 |
| 52 InspectorResourceContentLoader::InspectorResourceContentLoader(Page* page) | 52 InspectorResourceContentLoader::InspectorResourceContentLoader(Page* page) |
| 53 : m_allRequestsStarted(false) | 53 : m_allRequestsStarted(false) |
| 54 , m_started(false) |
| 55 , m_page(page) |
| 54 { | 56 { |
| 57 } |
| 58 |
| 59 void InspectorResourceContentLoader::start() |
| 60 { |
| 61 m_started = true; |
| 55 Vector<Document*> documents; | 62 Vector<Document*> documents; |
| 56 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverse
Next()) { | 63 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver
seNext()) { |
| 57 if (!frame->isLocalFrame()) | 64 if (!frame->isLocalFrame()) |
| 58 continue; | 65 continue; |
| 59 LocalFrame* localFrame = toLocalFrame(frame); | 66 LocalFrame* localFrame = toLocalFrame(frame); |
| 60 documents.append(localFrame->document()); | 67 documents.append(localFrame->document()); |
| 61 documents.appendVector(InspectorPageAgent::importsForFrame(localFrame)); | 68 documents.appendVector(InspectorPageAgent::importsForFrame(localFrame)); |
| 62 } | 69 } |
| 63 for (Vector<Document*>::const_iterator documentIt = documents.begin(); docum
entIt != documents.end(); ++documentIt) { | 70 for (Vector<Document*>::const_iterator documentIt = documents.begin(); docum
entIt != documents.end(); ++documentIt) { |
| 64 Document* document = *documentIt; | 71 Document* document = *documentIt; |
| 65 | 72 |
| 66 HashSet<String> urlsToFetch; | 73 HashSet<String> urlsToFetch; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 81 ResourceClient* resourceClient = new ResourceClient(this); | 88 ResourceClient* resourceClient = new ResourceClient(this); |
| 82 m_pendingResourceClients.add(resourceClient); | 89 m_pendingResourceClients.add(resourceClient); |
| 83 resourceClient->waitForResource(resource.get()); | 90 resourceClient->waitForResource(resource.get()); |
| 84 } | 91 } |
| 85 } | 92 } |
| 86 | 93 |
| 87 m_allRequestsStarted = true; | 94 m_allRequestsStarted = true; |
| 88 checkDone(); | 95 checkDone(); |
| 89 } | 96 } |
| 90 | 97 |
| 91 void InspectorResourceContentLoader::addListener(PassOwnPtr<VoidCallback> callba
ck) | 98 void InspectorResourceContentLoader::ensureResourcesContentLoaded(PassOwnPtr<Voi
dCallback> callback) |
| 92 { | 99 { |
| 100 if (!m_started) |
| 101 start(); |
| 93 m_callbacks.append(callback); | 102 m_callbacks.append(callback); |
| 94 checkDone(); | 103 checkDone(); |
| 95 } | 104 } |
| 96 | 105 |
| 97 InspectorResourceContentLoader::~InspectorResourceContentLoader() | 106 InspectorResourceContentLoader::~InspectorResourceContentLoader() |
| 98 { | 107 { |
| 99 stop(); | 108 stop(); |
| 100 } | 109 } |
| 101 | 110 |
| 102 void InspectorResourceContentLoader::stop() | 111 void InspectorResourceContentLoader::stop() |
| (...skipping 22 matching lines...) Expand all Loading... |
| 125 (*it)->handleEvent(); | 134 (*it)->handleEvent(); |
| 126 } | 135 } |
| 127 | 136 |
| 128 void InspectorResourceContentLoader::resourceFinished(ResourceClient* client) | 137 void InspectorResourceContentLoader::resourceFinished(ResourceClient* client) |
| 129 { | 138 { |
| 130 m_pendingResourceClients.remove(client); | 139 m_pendingResourceClients.remove(client); |
| 131 checkDone(); | 140 checkDone(); |
| 132 } | 141 } |
| 133 | 142 |
| 134 } // namespace WebCore | 143 } // namespace WebCore |
| OLD | NEW |