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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return currentTime() - m_startTime; | 77 return currentTime() - m_startTime; |
78 } | 78 } |
79 | 79 |
80 void SpeculationsPumpSession::addedElementTokens(size_t count) | 80 void SpeculationsPumpSession::addedElementTokens(size_t count) |
81 { | 81 { |
82 m_processedElementTokens += count; | 82 m_processedElementTokens += count; |
83 } | 83 } |
84 | 84 |
85 HTMLParserScheduler::HTMLParserScheduler(HTMLDocumentParser* parser) | 85 HTMLParserScheduler::HTMLParserScheduler(HTMLDocumentParser* parser) |
86 : m_parser(parser) | 86 : m_parser(parser) |
| 87 , m_loadingTaskRunner(Platform::current()->currentThread()->scheduler()->loa
dingTaskRunner()) |
87 , m_cancellableContinueParse(WTF::bind(&HTMLParserScheduler::continueParsing
, this)) | 88 , m_cancellableContinueParse(WTF::bind(&HTMLParserScheduler::continueParsing
, this)) |
88 , m_isSuspendedWithActiveTimer(false) | 89 , m_isSuspendedWithActiveTimer(false) |
89 { | 90 { |
90 } | 91 } |
91 | 92 |
92 HTMLParserScheduler::~HTMLParserScheduler() | 93 HTMLParserScheduler::~HTMLParserScheduler() |
93 { | 94 { |
94 } | 95 } |
95 | 96 |
96 void HTMLParserScheduler::scheduleForResume() | 97 void HTMLParserScheduler::scheduleForResume() |
97 { | 98 { |
98 ASSERT(!m_isSuspendedWithActiveTimer); | 99 ASSERT(!m_isSuspendedWithActiveTimer); |
99 Platform::current()->currentThread()->scheduler()->postLoadingTask( | 100 m_loadingTaskRunner->postTask(FROM_HERE, m_cancellableContinueParse.cancelAn
dCreate()); |
100 FROM_HERE, m_cancellableContinueParse.cancelAndCreate()); | |
101 } | 101 } |
102 | 102 |
103 void HTMLParserScheduler::suspend() | 103 void HTMLParserScheduler::suspend() |
104 { | 104 { |
105 ASSERT(!m_isSuspendedWithActiveTimer); | 105 ASSERT(!m_isSuspendedWithActiveTimer); |
106 if (!m_cancellableContinueParse.isPending()) | 106 if (!m_cancellableContinueParse.isPending()) |
107 return; | 107 return; |
108 m_isSuspendedWithActiveTimer = true; | 108 m_isSuspendedWithActiveTimer = true; |
109 m_cancellableContinueParse.cancel(); | 109 m_cancellableContinueParse.cancel(); |
110 } | 110 } |
111 | 111 |
112 void HTMLParserScheduler::resume() | 112 void HTMLParserScheduler::resume() |
113 { | 113 { |
114 ASSERT(!m_cancellableContinueParse.isPending()); | 114 ASSERT(!m_cancellableContinueParse.isPending()); |
115 if (!m_isSuspendedWithActiveTimer) | 115 if (!m_isSuspendedWithActiveTimer) |
116 return; | 116 return; |
117 m_isSuspendedWithActiveTimer = false; | 117 m_isSuspendedWithActiveTimer = false; |
118 | 118 |
119 Platform::current()->currentThread()->scheduler()->postLoadingTask( | 119 m_loadingTaskRunner->postTask(FROM_HERE, m_cancellableContinueParse.cancelAn
dCreate()); |
120 FROM_HERE, m_cancellableContinueParse.cancelAndCreate()); | |
121 } | 120 } |
122 | 121 |
123 void HTMLParserScheduler::detach() | 122 void HTMLParserScheduler::detach() |
124 { | 123 { |
125 m_cancellableContinueParse.cancel(); | 124 m_cancellableContinueParse.cancel(); |
126 m_isSuspendedWithActiveTimer = false; | 125 m_isSuspendedWithActiveTimer = false; |
127 } | 126 } |
128 | 127 |
129 inline bool HTMLParserScheduler::shouldYield(const SpeculationsPumpSession& sess
ion, bool startingScript) const | 128 inline bool HTMLParserScheduler::shouldYield(const SpeculationsPumpSession& sess
ion, bool startingScript) const |
130 { | 129 { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 ASSERT(!m_cancellableContinueParse.isPending()); | 164 ASSERT(!m_cancellableContinueParse.isPending()); |
166 m_isSuspendedWithActiveTimer = true; | 165 m_isSuspendedWithActiveTimer = true; |
167 } | 166 } |
168 | 167 |
169 void HTMLParserScheduler::continueParsing() | 168 void HTMLParserScheduler::continueParsing() |
170 { | 169 { |
171 m_parser->resumeParsingAfterYield(); | 170 m_parser->resumeParsingAfterYield(); |
172 } | 171 } |
173 | 172 |
174 } | 173 } |
OLD | NEW |