| 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 |
| 764 std::unique_ptr<BackgroundHTMLParser::Configuration> config = wrapUnique(new
BackgroundHTMLParser::Configuration); | 767 std::unique_ptr<BackgroundHTMLParser::Configuration> config = wrapUnique(new
BackgroundHTMLParser::Configuration); |
| 765 config->options = m_options; | 768 config->options = m_options; |
| 766 config->parser = m_weakFactory.createWeakPtr(); | 769 config->parser = m_weakFactory.createWeakPtr(); |
| 767 config->xssAuditor = wrapUnique(new XSSAuditor); | 770 config->xssAuditor = wrapUnique(new XSSAuditor); |
| 768 config->xssAuditor->init(document(), &m_xssAuditorDelegate); | 771 config->xssAuditor->init(document(), &m_xssAuditorDelegate); |
| 769 | 772 |
| 770 config->decoder = takeDecoder(); | 773 config->decoder = takeDecoder(); |
| 771 config->tokenizedChunkQueue = m_tokenizedChunkQueue.get(); | 774 config->tokenizedChunkQueue = m_tokenizedChunkQueue.get(); |
| 772 if (document()->settings()) { | 775 if (document()->settings()) { |
| 773 if (document()->settings()->backgroundHtmlParserOutstandingTokenLimit()) | 776 if (document()->settings()->backgroundHtmlParserOutstandingTokenLimit()) |
| 774 config->outstandingTokenLimit = document()->settings()->backgroundHt
mlParserOutstandingTokenLimit(); | 777 config->outstandingTokenLimit = document()->settings()->backgroundHt
mlParserOutstandingTokenLimit(); |
| 775 if (document()->settings()->backgroundHtmlParserPendingTokenLimit()) | 778 if (document()->settings()->backgroundHtmlParserPendingTokenLimit()) |
| 776 config->pendingTokenLimit = document()->settings()->backgroundHtmlPa
rserPendingTokenLimit(); | 779 config->pendingTokenLimit = document()->settings()->backgroundHtmlPa
rserPendingTokenLimit(); |
| 777 config->shouldCoalesceChunks = document()->settings()->parseHTMLOnMainTh
readCoalesceChunks(); | 780 config->shouldCoalesceChunks = document()->settings()->parseHTMLOnMainTh
readCoalesceChunks(); |
| 778 } | 781 } |
| 779 | 782 |
| 780 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); | 783 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); |
| 781 | 784 postTaskToLookaheadParser( |
| 782 // The background parser is created on the main thread, but may otherwise | 785 Synchronous, |
| 783 // only be used from the parser thread. | 786 &BackgroundHTMLParser::start, |
| 784 m_backgroundParser = BackgroundHTMLParser::create( | 787 reference.release(), |
| 785 std::move(config), | 788 passed(std::move(config)), |
| 786 m_loadingTaskRunner->clone()); | 789 document()->url(), |
| 787 // TODO(csharrison): This is a hack to initialize MediaValuesCached on the | 790 passed(CachedDocumentParameters::create(document())), |
| 788 // correct thread. We should get rid of it. | 791 MediaValuesCached::MediaValuesCachedData(*document()), |
| 789 postTaskToLookaheadParser(Synchronous, &BackgroundHTMLParser::init, m_backgr
oundParser, document()->url(), passed(CachedDocumentParameters::create(document(
))), MediaValuesCached::MediaValuesCachedData(*document())); | 792 passed(m_loadingTaskRunner->clone())); |
| 790 } | 793 } |
| 791 | 794 |
| 792 void HTMLDocumentParser::stopBackgroundParser() | 795 void HTMLDocumentParser::stopBackgroundParser() |
| 793 { | 796 { |
| 794 ASSERT(shouldUseThreading()); | 797 ASSERT(shouldUseThreading()); |
| 795 ASSERT(m_haveBackgroundParser); | 798 ASSERT(m_haveBackgroundParser); |
| 796 | 799 |
| 797 if (m_haveBackgroundParser && document()->frame() && document()->frame()->fr
ameScheduler()) | 800 if (m_haveBackgroundParser && document()->frame() && document()->frame()->fr
ameScheduler()) |
| 798 document()->frame()->frameScheduler()->setDocumentParsingInBackground(fa
lse); | 801 document()->frame()->frameScheduler()->setDocumentParsingInBackground(fa
lse); |
| 799 | 802 |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 (*WTF::bind(function, std::forward<Ps>(parameters)...))(); | 1216 (*WTF::bind(function, std::forward<Ps>(parameters)...))(); |
| 1214 return; | 1217 return; |
| 1215 case Asynchronous: | 1218 case Asynchronous: |
| 1216 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, WTF::bind(function, std::
forward<Ps>(parameters)...)); | 1219 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, WTF::bind(function, std::
forward<Ps>(parameters)...)); |
| 1217 return; | 1220 return; |
| 1218 } | 1221 } |
| 1219 NOTREACHED(); | 1222 NOTREACHED(); |
| 1220 } | 1223 } |
| 1221 | 1224 |
| 1222 } // namespace blink | 1225 } // namespace blink |
| OLD | NEW |