Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp

Issue 2192493002: Let blink scheduler know when background parsing a document (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix some test failures Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698