Use WeakPtrs to communicate between the HTMLDocumentParser and the BackgroundHTMLParser
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Feb 2013 19:30:54 +0000 (19:30 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Feb 2013 19:30:54 +0000 (19:30 +0000)
commit8e54166576d7140b17fb1b03ab26a6074b140cce
treeb5547487d55f60eee345cf1a6fec03228d70b218
parent42edc72e6df7a0c0c11541787fd69ac33bc7f595
Use WeakPtrs to communicate between the HTMLDocumentParser and the BackgroundHTMLParser
https://bugs.webkit.org/show_bug.cgi?id=107190

Reviewed by Eric Seidel.

Source/WebCore:

This patch replaces the parser map with WeakPtr. We now use WeakPtrs to
communicate from the main thread to the background thread. (We were
already using WeakPtrs to communicate from the background thread to the
main thread.) This change lets us remove a bunch of boilerplate code.

* html/parser/BackgroundHTMLParser.cpp:
(WebCore::BackgroundHTMLParser::BackgroundHTMLParser):
(WebCore::BackgroundHTMLParser::stop):
(WebCore):
* html/parser/BackgroundHTMLParser.h:
(WebCore::BackgroundHTMLParser::create):
(BackgroundHTMLParser):
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::didFailSpeculation):
(WebCore::HTMLDocumentParser::startBackgroundParser):
(WebCore::HTMLDocumentParser::stopBackgroundParser):
(WebCore::HTMLDocumentParser::append):
(WebCore::HTMLDocumentParser::finish):
* html/parser/HTMLDocumentParser.h:
(WebCore):
(HTMLDocumentParser):

Source/WTF:

Add the ability to create an unbound weak reference. This facility lets
you start sending messages to a WeakPtr on another thread before the
object backing the WeakPtr has actually been created.

* wtf/WeakPtr.h:
(WTF::WeakReference::createUnbound):
(WTF::WeakReference::bindTo):
(WeakReference):
(WTF::WeakReference::WeakReference):
(WTF::WeakPtr::WeakPtr):
(WeakPtr):
(WTF::WeakPtrFactory::WeakPtrFactory):
(WeakPtrFactory):
(WTF::WeakPtrFactory::revokeAll):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142305 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/wtf/WeakPtr.h
Source/WebCore/ChangeLog
Source/WebCore/html/parser/BackgroundHTMLParser.cpp
Source/WebCore/html/parser/BackgroundHTMLParser.h
Source/WebCore/html/parser/HTMLDocumentParser.cpp
Source/WebCore/html/parser/HTMLDocumentParser.h