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

Side by Side Diff: Source/core/html/parser/HTMLParserScheduler.cpp

Issue 1087203002: Patch 2/3 to get WebScheduler via WebThread (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Style nits Created 5 years, 8 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
« no previous file with comments | « Source/core/html/parser/HTMLDocumentParser.cpp ('k') | Source/platform/ThreadTimers.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 11 matching lines...) Expand all
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/html/parser/HTMLParserScheduler.h" 27 #include "core/html/parser/HTMLParserScheduler.h"
28 28
29 #include "core/dom/Document.h" 29 #include "core/dom/Document.h"
30 #include "core/html/parser/HTMLDocumentParser.h" 30 #include "core/html/parser/HTMLDocumentParser.h"
31 #include "core/frame/FrameView.h" 31 #include "core/frame/FrameView.h"
32 #include "platform/scheduler/Scheduler.h" 32 #include "public/platform/Platform.h"
33 #include "public/platform/WebScheduler.h"
34 #include "public/platform/WebThread.h"
33 #include "wtf/CurrentTime.h" 35 #include "wtf/CurrentTime.h"
34 36
35 namespace blink { 37 namespace blink {
36 38
37 ActiveParserSession::ActiveParserSession(unsigned& nestingLevel, Document* docum ent) 39 ActiveParserSession::ActiveParserSession(unsigned& nestingLevel, Document* docum ent)
38 : NestingLevelIncrementer(nestingLevel) 40 : NestingLevelIncrementer(nestingLevel)
39 , m_document(document) 41 , m_document(document)
40 { 42 {
41 if (!m_document) 43 if (!m_document)
42 return; 44 return;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 { 89 {
88 } 90 }
89 91
90 HTMLParserScheduler::~HTMLParserScheduler() 92 HTMLParserScheduler::~HTMLParserScheduler()
91 { 93 {
92 } 94 }
93 95
94 void HTMLParserScheduler::scheduleForResume() 96 void HTMLParserScheduler::scheduleForResume()
95 { 97 {
96 ASSERT(!m_isSuspendedWithActiveTimer); 98 ASSERT(!m_isSuspendedWithActiveTimer);
97 Scheduler::shared()->postLoadingTask(FROM_HERE, m_cancellableContinueParse.t ask()); 99 Platform::current()->currentThread()->scheduler()->postLoadingTask(FROM_HERE , m_cancellableContinueParse.task());
98 } 100 }
99 101
100 void HTMLParserScheduler::suspend() 102 void HTMLParserScheduler::suspend()
101 { 103 {
102 ASSERT(!m_isSuspendedWithActiveTimer); 104 ASSERT(!m_isSuspendedWithActiveTimer);
103 if (!m_cancellableContinueParse.isPending()) 105 if (!m_cancellableContinueParse.isPending())
104 return; 106 return;
105 m_isSuspendedWithActiveTimer = true; 107 m_isSuspendedWithActiveTimer = true;
106 m_cancellableContinueParse.cancel(); 108 m_cancellableContinueParse.cancel();
107 } 109 }
108 110
109 void HTMLParserScheduler::resume() 111 void HTMLParserScheduler::resume()
110 { 112 {
111 ASSERT(!m_cancellableContinueParse.isPending()); 113 ASSERT(!m_cancellableContinueParse.isPending());
112 if (!m_isSuspendedWithActiveTimer) 114 if (!m_isSuspendedWithActiveTimer)
113 return; 115 return;
114 m_isSuspendedWithActiveTimer = false; 116 m_isSuspendedWithActiveTimer = false;
115 117
116 Scheduler::shared()->postLoadingTask(FROM_HERE, m_cancellableContinueParse.t ask()); 118 Platform::current()->currentThread()->scheduler()->postLoadingTask(FROM_HERE , m_cancellableContinueParse.task());
117 } 119 }
118 120
119 inline bool HTMLParserScheduler::shouldYield(const SpeculationsPumpSession& sess ion, bool startingScript) const 121 inline bool HTMLParserScheduler::shouldYield(const SpeculationsPumpSession& sess ion, bool startingScript) const
120 { 122 {
121 if (Scheduler::shared()->shouldYieldForHighPriorityWork()) 123 if (Platform::current()->currentThread()->scheduler()->shouldYieldForHighPri orityWork())
122 return true; 124 return true;
123 125
124 const double parserTimeLimit = 0.5; 126 const double parserTimeLimit = 0.5;
125 if (session.elapsedTime() > parserTimeLimit) 127 if (session.elapsedTime() > parserTimeLimit)
126 return true; 128 return true;
127 129
128 // Yield if a lot of DOM work has been done in this session and a script tag is 130 // Yield if a lot of DOM work has been done in this session and a script tag is
129 // about to be parsed. This significantly improves render performance for do cuments 131 // about to be parsed. This significantly improves render performance for do cuments
130 // that place their scripts at the bottom of the page. Yielding too often 132 // that place their scripts at the bottom of the page. Yielding too often
131 // significantly slows down the parsing so a balance needs to be struck to 133 // significantly slows down the parsing so a balance needs to be struck to
(...skipping 23 matching lines...) Expand all
155 ASSERT(!m_cancellableContinueParse.isPending()); 157 ASSERT(!m_cancellableContinueParse.isPending());
156 m_isSuspendedWithActiveTimer = true; 158 m_isSuspendedWithActiveTimer = true;
157 } 159 }
158 160
159 void HTMLParserScheduler::continueParsing() 161 void HTMLParserScheduler::continueParsing()
160 { 162 {
161 m_parser->resumeParsingAfterYield(); 163 m_parser->resumeParsingAfterYield();
162 } 164 }
163 165
164 } 166 }
OLDNEW
« no previous file with comments | « Source/core/html/parser/HTMLDocumentParser.cpp ('k') | Source/platform/ThreadTimers.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698