| 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 14 matching lines...) Expand all Loading... |
| 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 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 // parserChunkSize is used to define how many tokens the parser will | |
| 36 // process before checking against parserTimeLimit and possibly yielding. | |
| 37 // This is a performance optimization to prevent checking after every token. | |
| 38 const int HTMLParserScheduler::parserChunkSize = 4096; | |
| 39 | |
| 40 // parserTimeLimit is the seconds the parser will run in one write() call | |
| 41 // before yielding. Inline <script> execution can cause it to exceed the limit. | |
| 42 const double HTMLParserScheduler::parserTimeLimit = 0.2; | |
| 43 | |
| 44 ActiveParserSession::ActiveParserSession(Document* document) | 35 ActiveParserSession::ActiveParserSession(Document* document) |
| 45 : m_document(document) | 36 : m_document(document) |
| 46 { | 37 { |
| 47 if (!m_document) | 38 if (!m_document) |
| 48 return; | 39 return; |
| 49 m_document->incrementActiveParserCount(); | 40 m_document->incrementActiveParserCount(); |
| 50 } | 41 } |
| 51 | 42 |
| 52 ActiveParserSession::~ActiveParserSession() | 43 ActiveParserSession::~ActiveParserSession() |
| 53 { | 44 { |
| 54 if (!m_document) | 45 if (!m_document) |
| 55 return; | 46 return; |
| 56 m_document->decrementActiveParserCount(); | 47 m_document->decrementActiveParserCount(); |
| 57 } | 48 } |
| 58 | 49 |
| 59 PumpSession::PumpSession(unsigned& nestingLevel, Document* document) | 50 PumpSession::PumpSession(unsigned& nestingLevel, Document* document) |
| 60 : NestingLevelIncrementer(nestingLevel) | 51 : NestingLevelIncrementer(nestingLevel) |
| 61 , ActiveParserSession(document) | 52 , ActiveParserSession(document) |
| 62 // Setting processedTokens to INT_MAX causes us to check for yields | |
| 63 // after any token during any parse where yielding is allowed. | |
| 64 // At that time we'll initialize startTime. | |
| 65 , processedTokens(INT_MAX) | |
| 66 , startTime(0) | |
| 67 , needsYield(false) | |
| 68 , didSeeScript(false) | |
| 69 { | 53 { |
| 70 } | 54 } |
| 71 | 55 |
| 72 PumpSession::~PumpSession() | 56 PumpSession::~PumpSession() |
| 73 { | 57 { |
| 74 } | 58 } |
| 75 | 59 |
| 76 HTMLParserScheduler::HTMLParserScheduler(HTMLDocumentParser* parser) | 60 HTMLParserScheduler::HTMLParserScheduler(HTMLDocumentParser* parser) |
| 77 : m_parser(parser) | 61 : m_parser(parser) |
| 78 , m_continueNextChunkTimer(this, &HTMLParserScheduler::continueNextChunkTime
rFired) | 62 , m_continueNextChunkTimer(this, &HTMLParserScheduler::continueNextChunkTime
rFired) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 108 void HTMLParserScheduler::resume() | 92 void HTMLParserScheduler::resume() |
| 109 { | 93 { |
| 110 ASSERT(!m_continueNextChunkTimer.isActive()); | 94 ASSERT(!m_continueNextChunkTimer.isActive()); |
| 111 if (!m_isSuspendedWithActiveTimer) | 95 if (!m_isSuspendedWithActiveTimer) |
| 112 return; | 96 return; |
| 113 m_isSuspendedWithActiveTimer = false; | 97 m_isSuspendedWithActiveTimer = false; |
| 114 m_continueNextChunkTimer.startOneShot(0, FROM_HERE); | 98 m_continueNextChunkTimer.startOneShot(0, FROM_HERE); |
| 115 } | 99 } |
| 116 | 100 |
| 117 } | 101 } |
| OLD | NEW |