Chromium Code Reviews| Index: Source/core/html/HTMLImportLoader.cpp |
| diff --git a/Source/core/html/HTMLImportLoader.cpp b/Source/core/html/HTMLImportLoader.cpp |
| index bcef452e7279907afc1cc69298edeab29d9e0cf3..f5d1e0ef1c5b23538ceef1476bc82365f36c62cb 100644 |
| --- a/Source/core/html/HTMLImportLoader.cpp |
| +++ b/Source/core/html/HTMLImportLoader.cpp |
| @@ -33,6 +33,7 @@ |
| #include "core/dom/Document.h" |
| #include "core/html/HTMLDocument.h" |
| +#include "core/html/HTMLImportLoaderClient.h" |
| #include "core/loader/DocumentWriter.h" |
| #include "core/loader/cache/ResourceFetcher.h" |
| #include "core/page/ContentSecurityPolicyResponseHeaders.h" |
| @@ -85,12 +86,16 @@ void HTMLImportLoader::setState(State state) |
| writer->end(); |
| } |
| - if (m_state == StateReady || m_state == StateError) |
| - dispose(); |
| + // Since DocumentWriter::end() let setState() reenter, we shouldn't refer m_state here. |
|
dglazkov
2013/08/08 17:04:18
refer _to_ m_state.
|
| + if (state == StateReady || state == StateError) |
| + didFinish(); |
| } |
| -void HTMLImportLoader::dispose() |
| +void HTMLImportLoader::didFinish() |
| { |
| + for (size_t i = 0; i < m_clients.size(); ++i) |
| + m_clients[i]->didFinish(); |
| + |
| if (m_resource) { |
| m_resource->removeClient(this); |
| m_resource = 0; |
| @@ -139,6 +144,20 @@ Document* HTMLImportLoader::importedDocument() const |
| return m_importedDocument.get(); |
| } |
| +void HTMLImportLoader::addClient(HTMLImportLoaderClient* client) |
| +{ |
| + ASSERT(notFound == m_clients.find(client)); |
| + m_clients.append(client); |
| + if (isDone()) |
| + client->didFinish(); |
| +} |
| + |
| +void HTMLImportLoader::removeClient(HTMLImportLoaderClient* client) |
| +{ |
| + ASSERT(notFound != m_clients.find(client)); |
| + m_clients.remove(m_clients.find(client)); |
| +} |
| + |
| void HTMLImportLoader::importDestroyed() |
| { |
| m_parent = 0; |