| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 m_haveBackgroundParser = true; | 754 m_haveBackgroundParser = true; |
| 755 | 755 |
| 756 // TODO(alexclarke): Remove WebFrameScheduler::setDocumentParsingInBackgroun
d when background parser goes away. | 756 // TODO(alexclarke): Remove WebFrameScheduler::setDocumentParsingInBackgroun
d when background parser goes away. |
| 757 if (document()->frame() && document()->frame()->frameScheduler()) | 757 if (document()->frame() && document()->frame()->frameScheduler()) |
| 758 document()->frame()->frameScheduler()->setDocumentParsingInBackground(tr
ue); | 758 document()->frame()->frameScheduler()->setDocumentParsingInBackground(tr
ue); |
| 759 | 759 |
| 760 // Make sure that a resolver is set up, so that the correct viewport dimensi
ons will be fed to the background parser and preload scanner. | 760 // Make sure that a resolver is set up, so that the correct viewport dimensi
ons will be fed to the background parser and preload scanner. |
| 761 if (document()->loader()) | 761 if (document()->loader()) |
| 762 document()->ensureStyleResolver(); | 762 document()->ensureStyleResolver(); |
| 763 | 763 |
| 764 RefPtr<WeakReference<BackgroundHTMLParser>> reference = WeakReference<Backgr
oundHTMLParser>::createUnbound(); | |
| 765 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); | |
| 766 | |
| 767 std::unique_ptr<BackgroundHTMLParser::Configuration> config = wrapUnique(new
BackgroundHTMLParser::Configuration); | 764 std::unique_ptr<BackgroundHTMLParser::Configuration> config = wrapUnique(new
BackgroundHTMLParser::Configuration); |
| 768 config->options = m_options; | 765 config->options = m_options; |
| 769 config->parser = m_weakFactory.createWeakPtr(); | 766 config->parser = m_weakFactory.createWeakPtr(); |
| 770 config->xssAuditor = wrapUnique(new XSSAuditor); | 767 config->xssAuditor = wrapUnique(new XSSAuditor); |
| 771 config->xssAuditor->init(document(), &m_xssAuditorDelegate); | 768 config->xssAuditor->init(document(), &m_xssAuditorDelegate); |
| 772 | 769 |
| 773 config->decoder = takeDecoder(); | 770 config->decoder = takeDecoder(); |
| 774 config->tokenizedChunkQueue = m_tokenizedChunkQueue.get(); | 771 config->tokenizedChunkQueue = m_tokenizedChunkQueue.get(); |
| 775 if (document()->settings()) { | 772 if (document()->settings()) { |
| 776 if (document()->settings()->backgroundHtmlParserOutstandingTokenLimit()) | 773 if (document()->settings()->backgroundHtmlParserOutstandingTokenLimit()) |
| 777 config->outstandingTokenLimit = document()->settings()->backgroundHt
mlParserOutstandingTokenLimit(); | 774 config->outstandingTokenLimit = document()->settings()->backgroundHt
mlParserOutstandingTokenLimit(); |
| 778 if (document()->settings()->backgroundHtmlParserPendingTokenLimit()) | 775 if (document()->settings()->backgroundHtmlParserPendingTokenLimit()) |
| 779 config->pendingTokenLimit = document()->settings()->backgroundHtmlPa
rserPendingTokenLimit(); | 776 config->pendingTokenLimit = document()->settings()->backgroundHtmlPa
rserPendingTokenLimit(); |
| 780 config->shouldCoalesceChunks = document()->settings()->parseHTMLOnMainTh
readCoalesceChunks(); | 777 config->shouldCoalesceChunks = document()->settings()->parseHTMLOnMainTh
readCoalesceChunks(); |
| 781 } | 778 } |
| 782 | 779 |
| 783 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); | 780 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); |
| 784 postTaskToLookaheadParser( | 781 |
| 785 Synchronous, | 782 // The background parser is created on the main thread, but may otherwise |
| 786 &BackgroundHTMLParser::start, | 783 // only be used from the parser thread. |
| 787 reference.release(), | 784 m_backgroundParser = BackgroundHTMLParser::create( |
| 788 passed(std::move(config)), | 785 std::move(config), |
| 789 document()->url(), | 786 m_loadingTaskRunner->clone()); |
| 790 passed(CachedDocumentParameters::create(document())), | 787 // TODO(csharrison): This is a hack to initialize MediaValuesCached on the |
| 791 MediaValuesCached::MediaValuesCachedData(*document()), | 788 // correct thread. We should get rid of it. |
| 792 passed(m_loadingTaskRunner->clone())); | 789 postTaskToLookaheadParser(Synchronous, &BackgroundHTMLParser::init, m_backgr
oundParser, document()->url(), passed(CachedDocumentParameters::create(document(
))), MediaValuesCached::MediaValuesCachedData(*document())); |
| 793 } | 790 } |
| 794 | 791 |
| 795 void HTMLDocumentParser::stopBackgroundParser() | 792 void HTMLDocumentParser::stopBackgroundParser() |
| 796 { | 793 { |
| 797 ASSERT(shouldUseThreading()); | 794 ASSERT(shouldUseThreading()); |
| 798 ASSERT(m_haveBackgroundParser); | 795 ASSERT(m_haveBackgroundParser); |
| 799 | 796 |
| 800 if (m_haveBackgroundParser && document()->frame() && document()->frame()->fr
ameScheduler()) | 797 if (m_haveBackgroundParser && document()->frame() && document()->frame()->fr
ameScheduler()) |
| 801 document()->frame()->frameScheduler()->setDocumentParsingInBackground(fa
lse); | 798 document()->frame()->frameScheduler()->setDocumentParsingInBackground(fa
lse); |
| 802 | 799 |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 (*WTF::bind(function, std::forward<Ps>(parameters)...))(); | 1213 (*WTF::bind(function, std::forward<Ps>(parameters)...))(); |
| 1217 return; | 1214 return; |
| 1218 case Asynchronous: | 1215 case Asynchronous: |
| 1219 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, WTF::bind(function, std::
forward<Ps>(parameters)...)); | 1216 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, WTF::bind(function, std::
forward<Ps>(parameters)...)); |
| 1220 return; | 1217 return; |
| 1221 } | 1218 } |
| 1222 NOTREACHED(); | 1219 NOTREACHED(); |
| 1223 } | 1220 } |
| 1224 | 1221 |
| 1225 } // namespace blink | 1222 } // namespace blink |
| OLD | NEW |