Index: sky/engine/core/html/parser/HTMLDocumentParser.cpp |
diff --git a/sky/engine/core/html/parser/HTMLDocumentParser.cpp b/sky/engine/core/html/parser/HTMLDocumentParser.cpp |
index d84502f1959d99fbbddb59f65da15146625dadb8..869ab63144d612b2a98e0fde0b8b8fbe3e2dbd9c 100644 |
--- a/sky/engine/core/html/parser/HTMLDocumentParser.cpp |
+++ b/sky/engine/core/html/parser/HTMLDocumentParser.cpp |
@@ -73,12 +73,15 @@ HTMLDocumentParser::~HTMLDocumentParser() |
#endif |
} |
-void HTMLDocumentParser::parse(mojo::ScopedDataPipeConsumerHandle source) |
+void HTMLDocumentParser::parse(mojo::ScopedDataPipeConsumerHandle source, |
+ const base::Closure& completionCallback) |
{ |
ASSERT(!isStopped()); |
ASSERT(!m_haveBackgroundParser); |
m_haveBackgroundParser = true; |
+ m_completionCallback = completionCallback; |
+ |
OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new BackgroundHTMLParser::Configuration); |
config->source = source.Pass(); |
config->parser = m_weakFactory.GetWeakPtr(); |
@@ -355,8 +358,14 @@ void HTMLDocumentParser::end() |
if (m_haveBackgroundParser) |
stopBackgroundParser(); |
+ // Notice that we copy the compleition callback into a local variable |
+ // because we might be deleted after we call ffinish() below. |
+ base::Closure completionCallback = m_completionCallback; |
+ |
// Informs the the rest of WebCore that parsing is really finished (and deletes this). |
m_treeBuilder->finished(); |
+ |
+ completionCallback.Run(); |
} |
void HTMLDocumentParser::attemptToEnd() |