| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2013 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 , m_treeBuilderSimulator(config->options) | 100 , m_treeBuilderSimulator(config->options) |
| 101 , m_options(config->options) | 101 , m_options(config->options) |
| 102 , m_outstandingTokenLimit(config->outstandingTokenLimit) | 102 , m_outstandingTokenLimit(config->outstandingTokenLimit) |
| 103 , m_parser(config->parser) | 103 , m_parser(config->parser) |
| 104 , m_pendingTokens(adoptPtr(new CompactHTMLTokenStream)) | 104 , m_pendingTokens(adoptPtr(new CompactHTMLTokenStream)) |
| 105 , m_pendingTokenLimit(config->pendingTokenLimit) | 105 , m_pendingTokenLimit(config->pendingTokenLimit) |
| 106 , m_xssAuditor(config->xssAuditor.release()) | 106 , m_xssAuditor(config->xssAuditor.release()) |
| 107 , m_preloadScanner(config->preloadScanner.release()) | 107 , m_preloadScanner(config->preloadScanner.release()) |
| 108 , m_decoder(config->decoder.release()) | 108 , m_decoder(config->decoder.release()) |
| 109 , m_loadingTaskRunner(loadingTaskRunner) | 109 , m_loadingTaskRunner(loadingTaskRunner) |
| 110 , m_parsedChunkQueue(config->parsedChunkQueue) | |
| 111 , m_startingScript(false) | 110 , m_startingScript(false) |
| 112 { | 111 { |
| 113 ASSERT(m_outstandingTokenLimit > 0); | 112 ASSERT(m_outstandingTokenLimit > 0); |
| 114 ASSERT(m_pendingTokenLimit > 0); | 113 ASSERT(m_pendingTokenLimit > 0); |
| 115 ASSERT(m_outstandingTokenLimit >= m_pendingTokenLimit); | 114 ASSERT(m_outstandingTokenLimit >= m_pendingTokenLimit); |
| 116 } | 115 } |
| 117 | 116 |
| 118 BackgroundHTMLParser::~BackgroundHTMLParser() | 117 BackgroundHTMLParser::~BackgroundHTMLParser() |
| 119 { | 118 { |
| 120 } | 119 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 170 |
| 172 void BackgroundHTMLParser::resumeFrom(PassOwnPtr<Checkpoint> checkpoint) | 171 void BackgroundHTMLParser::resumeFrom(PassOwnPtr<Checkpoint> checkpoint) |
| 173 { | 172 { |
| 174 m_parser = checkpoint->parser; | 173 m_parser = checkpoint->parser; |
| 175 m_token = checkpoint->token.release(); | 174 m_token = checkpoint->token.release(); |
| 176 m_tokenizer = checkpoint->tokenizer.release(); | 175 m_tokenizer = checkpoint->tokenizer.release(); |
| 177 m_treeBuilderSimulator.setState(checkpoint->treeBuilderState); | 176 m_treeBuilderSimulator.setState(checkpoint->treeBuilderState); |
| 178 m_input.rewindTo(checkpoint->inputCheckpoint, checkpoint->unparsedInput); | 177 m_input.rewindTo(checkpoint->inputCheckpoint, checkpoint->unparsedInput); |
| 179 m_preloadScanner->rewindTo(checkpoint->preloadScannerCheckpoint); | 178 m_preloadScanner->rewindTo(checkpoint->preloadScannerCheckpoint); |
| 180 m_startingScript = false; | 179 m_startingScript = false; |
| 181 m_parsedChunkQueue->clear(); | |
| 182 pumpTokenizer(); | 180 pumpTokenizer(); |
| 183 } | 181 } |
| 184 | 182 |
| 185 void BackgroundHTMLParser::startedChunkWithCheckpoint(HTMLInputCheckpoint inputC
heckpoint) | 183 void BackgroundHTMLParser::startedChunkWithCheckpoint(HTMLInputCheckpoint inputC
heckpoint) |
| 186 { | 184 { |
| 187 // Note, we should not have to worry about the index being invalid | 185 // Note, we should not have to worry about the index being invalid |
| 188 // as messages from the main thread will be processed in FIFO order. | 186 // as messages from the main thread will be processed in FIFO order. |
| 189 m_input.invalidateCheckpointsBefore(inputCheckpoint); | 187 m_input.invalidateCheckpointsBefore(inputCheckpoint); |
| 190 pumpTokenizer(); | 188 pumpTokenizer(); |
| 191 } | 189 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 chunk->preloads.swap(m_pendingPreloads); | 284 chunk->preloads.swap(m_pendingPreloads); |
| 287 chunk->xssInfos.swap(m_pendingXSSInfos); | 285 chunk->xssInfos.swap(m_pendingXSSInfos); |
| 288 chunk->tokenizerState = m_tokenizer->state(); | 286 chunk->tokenizerState = m_tokenizer->state(); |
| 289 chunk->treeBuilderState = m_treeBuilderSimulator.state(); | 287 chunk->treeBuilderState = m_treeBuilderSimulator.state(); |
| 290 chunk->inputCheckpoint = m_input.createCheckpoint(m_pendingTokens->size()); | 288 chunk->inputCheckpoint = m_input.createCheckpoint(m_pendingTokens->size()); |
| 291 chunk->preloadScannerCheckpoint = m_preloadScanner->createCheckpoint(); | 289 chunk->preloadScannerCheckpoint = m_preloadScanner->createCheckpoint(); |
| 292 chunk->tokens = m_pendingTokens.release(); | 290 chunk->tokens = m_pendingTokens.release(); |
| 293 chunk->startingScript = m_startingScript; | 291 chunk->startingScript = m_startingScript; |
| 294 m_startingScript = false; | 292 m_startingScript = false; |
| 295 | 293 |
| 296 bool isEmpty = m_parsedChunkQueue->enqueue(chunk.release()); | 294 m_loadingTaskRunner->postTask( |
| 297 if (isEmpty) { | 295 BLINK_FROM_HERE, |
| 298 m_loadingTaskRunner->postTask( | 296 new Task(threadSafeBind(&HTMLDocumentParser::didReceiveParsedChunkFromBa
ckgroundParser, AllowCrossThreadAccess(m_parser), chunk.release()))); |
| 299 BLINK_FROM_HERE, | |
| 300 new Task(threadSafeBind(&HTMLDocumentParser::notifyPendingParsedChun
ks, AllowCrossThreadAccess(m_parser)))); | |
| 301 } | |
| 302 | 297 |
| 303 m_pendingTokens = adoptPtr(new CompactHTMLTokenStream); | 298 m_pendingTokens = adoptPtr(new CompactHTMLTokenStream); |
| 304 } | 299 } |
| 305 | 300 |
| 306 } | 301 } |
| OLD | NEW |