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

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

Powered by Google App Engine
This is Rietveld 408576698