Index: Source/core/html/HTMLImportLoader.cpp |
diff --git a/Source/core/html/HTMLImportLoader.cpp b/Source/core/html/HTMLImportLoader.cpp |
index bcef452e7279907afc1cc69298edeab29d9e0cf3..f362b776a4b3592753e65f34786e53318567ae90 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 to m_state here. |
+ 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; |