Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(888)

Unified Diff: Source/core/html/HTMLImportLoader.cpp

Issue 22573005: [HTML Imports] Implement "load" and "error" events. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: For landing Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/HTMLImportLoader.h ('k') | Source/core/html/HTMLImportLoaderClient.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « Source/core/html/HTMLImportLoader.h ('k') | Source/core/html/HTMLImportLoaderClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698