| 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 11 matching lines...) Expand all Loading... |
| 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" |
| 33 #include "wtf/CurrentTime.h" | 34 #include "wtf/CurrentTime.h" |
| 34 | 35 |
| 35 namespace blink { | 36 namespace blink { |
| 36 | 37 |
| 37 ActiveParserSession::ActiveParserSession(Document* document) | 38 ActiveParserSession::ActiveParserSession(Document* document) |
| 38 : m_document(document) | 39 : m_document(document) |
| 39 { | 40 { |
| 40 if (!m_document) | 41 if (!m_document) |
| 41 return; | 42 return; |
| 42 m_document->incrementActiveParserCount(); | 43 m_document->incrementActiveParserCount(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 { | 111 { |
| 111 ASSERT(!m_continueNextChunkTimer.isActive()); | 112 ASSERT(!m_continueNextChunkTimer.isActive()); |
| 112 if (!m_isSuspendedWithActiveTimer) | 113 if (!m_isSuspendedWithActiveTimer) |
| 113 return; | 114 return; |
| 114 m_isSuspendedWithActiveTimer = false; | 115 m_isSuspendedWithActiveTimer = false; |
| 115 m_continueNextChunkTimer.startOneShot(0, FROM_HERE); | 116 m_continueNextChunkTimer.startOneShot(0, FROM_HERE); |
| 116 } | 117 } |
| 117 | 118 |
| 118 inline bool HTMLParserScheduler::shouldYield(const SpeculationsPumpSession& sess
ion) const | 119 inline bool HTMLParserScheduler::shouldYield(const SpeculationsPumpSession& sess
ion) const |
| 119 { | 120 { |
| 120 if (Scheduler::shared()->shouldYieldForHighPriorityWork()) | 121 if (Platform::current()->scheduler() && Platform::current()->scheduler()->sh
ouldYieldForHighPriorityWork()) |
| 121 return true; | 122 return true; |
| 122 | 123 |
| 123 const double parserTimeLimit = 0.5; | 124 const double parserTimeLimit = 0.5; |
| 124 if (session.elapsedTime() > parserTimeLimit) | 125 if (session.elapsedTime() > parserTimeLimit) |
| 125 return true; | 126 return true; |
| 126 | 127 |
| 127 return false; | 128 return false; |
| 128 } | 129 } |
| 129 | 130 |
| 130 bool HTMLParserScheduler::yieldIfNeeded(const SpeculationsPumpSession& session) | 131 bool HTMLParserScheduler::yieldIfNeeded(const SpeculationsPumpSession& session) |
| 131 { | 132 { |
| 132 if (shouldYield(session)) { | 133 if (shouldYield(session)) { |
| 133 scheduleForResume(); | 134 scheduleForResume(); |
| 134 return true; | 135 return true; |
| 135 } | 136 } |
| 136 | 137 |
| 137 return false; | 138 return false; |
| 138 } | 139 } |
| 139 | 140 |
| 140 } | 141 } |
| OLD | NEW |