| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 { | 89 { |
| 90 } | 90 } |
| 91 | 91 |
| 92 HTMLParserScheduler::~HTMLParserScheduler() | 92 HTMLParserScheduler::~HTMLParserScheduler() |
| 93 { | 93 { |
| 94 } | 94 } |
| 95 | 95 |
| 96 void HTMLParserScheduler::scheduleForResume() | 96 void HTMLParserScheduler::scheduleForResume() |
| 97 { | 97 { |
| 98 ASSERT(!m_isSuspendedWithActiveTimer); | 98 ASSERT(!m_isSuspendedWithActiveTimer); |
| 99 Platform::current()->currentThread()->scheduler()->postLoadingTask(FROM_HERE
, m_cancellableContinueParse.task()); | 99 Platform::current()->currentThread()->scheduler()->postLoadingTask( |
| 100 FROM_HERE, m_cancellableContinueParse.cancelAndCreate()); |
| 100 } | 101 } |
| 101 | 102 |
| 102 void HTMLParserScheduler::suspend() | 103 void HTMLParserScheduler::suspend() |
| 103 { | 104 { |
| 104 ASSERT(!m_isSuspendedWithActiveTimer); | 105 ASSERT(!m_isSuspendedWithActiveTimer); |
| 105 if (!m_cancellableContinueParse.isPending()) | 106 if (!m_cancellableContinueParse.isPending()) |
| 106 return; | 107 return; |
| 107 m_isSuspendedWithActiveTimer = true; | 108 m_isSuspendedWithActiveTimer = true; |
| 108 m_cancellableContinueParse.cancel(); | 109 m_cancellableContinueParse.cancel(); |
| 109 } | 110 } |
| 110 | 111 |
| 111 void HTMLParserScheduler::resume() | 112 void HTMLParserScheduler::resume() |
| 112 { | 113 { |
| 113 ASSERT(!m_cancellableContinueParse.isPending()); | 114 ASSERT(!m_cancellableContinueParse.isPending()); |
| 114 if (!m_isSuspendedWithActiveTimer) | 115 if (!m_isSuspendedWithActiveTimer) |
| 115 return; | 116 return; |
| 116 m_isSuspendedWithActiveTimer = false; | 117 m_isSuspendedWithActiveTimer = false; |
| 117 | 118 |
| 118 Platform::current()->currentThread()->scheduler()->postLoadingTask(FROM_HERE
, m_cancellableContinueParse.task()); | 119 Platform::current()->currentThread()->scheduler()->postLoadingTask( |
| 120 FROM_HERE, m_cancellableContinueParse.cancelAndCreate()); |
| 119 } | 121 } |
| 120 | 122 |
| 121 inline bool HTMLParserScheduler::shouldYield(const SpeculationsPumpSession& sess
ion, bool startingScript) const | 123 inline bool HTMLParserScheduler::shouldYield(const SpeculationsPumpSession& sess
ion, bool startingScript) const |
| 122 { | 124 { |
| 123 if (Platform::current()->currentThread()->scheduler()->shouldYieldForHighPri
orityWork()) | 125 if (Platform::current()->currentThread()->scheduler()->shouldYieldForHighPri
orityWork()) |
| 124 return true; | 126 return true; |
| 125 | 127 |
| 126 const double parserTimeLimit = 0.5; | 128 const double parserTimeLimit = 0.5; |
| 127 if (session.elapsedTime() > parserTimeLimit) | 129 if (session.elapsedTime() > parserTimeLimit) |
| 128 return true; | 130 return true; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 157 ASSERT(!m_cancellableContinueParse.isPending()); | 159 ASSERT(!m_cancellableContinueParse.isPending()); |
| 158 m_isSuspendedWithActiveTimer = true; | 160 m_isSuspendedWithActiveTimer = true; |
| 159 } | 161 } |
| 160 | 162 |
| 161 void HTMLParserScheduler::continueParsing() | 163 void HTMLParserScheduler::continueParsing() |
| 162 { | 164 { |
| 163 m_parser->resumeParsingAfterYield(); | 165 m_parser->resumeParsingAfterYield(); |
| 164 } | 166 } |
| 165 | 167 |
| 166 } | 168 } |
| OLD | NEW |