| 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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 } | 714 } |
| 715 | 715 |
| 716 void HTMLDocumentParser::startBackgroundParser() | 716 void HTMLDocumentParser::startBackgroundParser() |
| 717 { | 717 { |
| 718 ASSERT(!isStopped()); | 718 ASSERT(!isStopped()); |
| 719 ASSERT(shouldUseThreading()); | 719 ASSERT(shouldUseThreading()); |
| 720 ASSERT(!m_haveBackgroundParser); | 720 ASSERT(!m_haveBackgroundParser); |
| 721 ASSERT(document()); | 721 ASSERT(document()); |
| 722 m_haveBackgroundParser = true; | 722 m_haveBackgroundParser = true; |
| 723 | 723 |
| 724 if (document()->frame() && document()->frame()->frameScheduler()) |
| 725 document()->frame()->frameScheduler()->setDocumentParsingInBackground(tr
ue); |
| 726 |
| 724 // 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. | 727 // 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. |
| 725 if (document()->loader()) | 728 if (document()->loader()) |
| 726 document()->ensureStyleResolver(); | 729 document()->ensureStyleResolver(); |
| 727 | 730 |
| 728 RefPtr<WeakReference<BackgroundHTMLParser>> reference = WeakReference<Backgr
oundHTMLParser>::createUnbound(); | 731 RefPtr<WeakReference<BackgroundHTMLParser>> reference = WeakReference<Backgr
oundHTMLParser>::createUnbound(); |
| 729 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); | 732 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); |
| 730 | 733 |
| 731 std::unique_ptr<BackgroundHTMLParser::Configuration> config = wrapUnique(new
BackgroundHTMLParser::Configuration); | 734 std::unique_ptr<BackgroundHTMLParser::Configuration> config = wrapUnique(new
BackgroundHTMLParser::Configuration); |
| 732 config->options = m_options; | 735 config->options = m_options; |
| 733 config->parser = m_weakFactory.createWeakPtr(); | 736 config->parser = m_weakFactory.createWeakPtr(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 755 MediaValuesCached::MediaValuesCachedData(*document()), | 758 MediaValuesCached::MediaValuesCachedData(*document()), |
| 756 passed(m_loadingTaskRunner->clone())); | 759 passed(m_loadingTaskRunner->clone())); |
| 757 } | 760 } |
| 758 | 761 |
| 759 void HTMLDocumentParser::stopBackgroundParser() | 762 void HTMLDocumentParser::stopBackgroundParser() |
| 760 { | 763 { |
| 761 ASSERT(shouldUseThreading()); | 764 ASSERT(shouldUseThreading()); |
| 762 ASSERT(m_haveBackgroundParser); | 765 ASSERT(m_haveBackgroundParser); |
| 763 m_haveBackgroundParser = false; | 766 m_haveBackgroundParser = false; |
| 764 | 767 |
| 768 if (document()->frame() && document()->frame()->frameScheduler()) |
| 769 document()->frame()->frameScheduler()->setDocumentParsingInBackground(fa
lse); |
| 770 |
| 765 // Make this sync, as lsan triggers on some unittests if the task runner is | 771 // Make this sync, as lsan triggers on some unittests if the task runner is |
| 766 // used. Note that these lifetimes will be much more concrete if | 772 // used. Note that these lifetimes will be much more concrete if |
| 767 // ParseHTMLOnMainThread lands (the lookahead parser will be a member). | 773 // ParseHTMLOnMainThread lands (the lookahead parser will be a member). |
| 768 postTaskToLookaheadParser(Synchronous, &BackgroundHTMLParser::stop, m_backgr
oundParser); | 774 postTaskToLookaheadParser(Synchronous, &BackgroundHTMLParser::stop, m_backgr
oundParser); |
| 769 m_weakFactory.revokeAll(); | 775 m_weakFactory.revokeAll(); |
| 770 } | 776 } |
| 771 | 777 |
| 772 void HTMLDocumentParser::append(const String& inputSource) | 778 void HTMLDocumentParser::append(const String& inputSource) |
| 773 { | 779 { |
| 774 if (isStopped()) | 780 if (isStopped()) |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 (*WTF::bind(function, std::forward<Ps>(parameters)...))(); | 1162 (*WTF::bind(function, std::forward<Ps>(parameters)...))(); |
| 1157 return; | 1163 return; |
| 1158 case Asynchronous: | 1164 case Asynchronous: |
| 1159 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, WTF::bind(function, std::
forward<Ps>(parameters)...)); | 1165 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, WTF::bind(function, std::
forward<Ps>(parameters)...)); |
| 1160 return; | 1166 return; |
| 1161 } | 1167 } |
| 1162 NOTREACHED(); | 1168 NOTREACHED(); |
| 1163 } | 1169 } |
| 1164 | 1170 |
| 1165 } // namespace blink | 1171 } // namespace blink |
| OLD | NEW |