| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 69 } |
| 70 | 70 |
| 71 static void checkThatXSSInfosAreSafeToSendToAnotherThread(const XSSInfoStream& i
nfos) | 71 static void checkThatXSSInfosAreSafeToSendToAnotherThread(const XSSInfoStream& i
nfos) |
| 72 { | 72 { |
| 73 for (size_t i = 0; i < infos.size(); ++i) | 73 for (size_t i = 0; i < infos.size(); ++i) |
| 74 ASSERT(infos[i]->isSafeToSendToAnotherThread()); | 74 ASSERT(infos[i]->isSafeToSendToAnotherThread()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 #endif | 77 #endif |
| 78 | 78 |
| 79 void BackgroundHTMLParser::start(PassRefPtr<WeakReference<BackgroundHTMLParser>
> reference, PassOwnPtr<Configuration> config) | 79 void BackgroundHTMLParser::start(PassRefPtr<WeakReference<BackgroundHTMLParser>>
reference, PassOwnPtr<Configuration> config) |
| 80 { | 80 { |
| 81 new BackgroundHTMLParser(reference, config); | 81 new BackgroundHTMLParser(reference, config); |
| 82 // Caller must free by calling stop(). | 82 // Caller must free by calling stop(). |
| 83 } | 83 } |
| 84 | 84 |
| 85 BackgroundHTMLParser::BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHT
MLParser> > reference, PassOwnPtr<Configuration> config) | 85 BackgroundHTMLParser::BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHT
MLParser>> reference, PassOwnPtr<Configuration> config) |
| 86 : m_weakFactory(reference, this) | 86 : m_weakFactory(reference, this) |
| 87 , m_token(adoptPtr(new HTMLToken)) | 87 , m_token(adoptPtr(new HTMLToken)) |
| 88 , m_tokenizer(HTMLTokenizer::create(config->options)) | 88 , m_tokenizer(HTMLTokenizer::create(config->options)) |
| 89 , m_treeBuilderSimulator(config->options) | 89 , m_treeBuilderSimulator(config->options) |
| 90 , m_options(config->options) | 90 , m_options(config->options) |
| 91 , m_parser(config->parser) | 91 , m_parser(config->parser) |
| 92 , m_pendingTokens(adoptPtr(new CompactHTMLTokenStream)) | 92 , m_pendingTokens(adoptPtr(new CompactHTMLTokenStream)) |
| 93 , m_xssAuditor(config->xssAuditor.release()) | 93 , m_xssAuditor(config->xssAuditor.release()) |
| 94 , m_preloadScanner(config->preloadScanner.release()) | 94 , m_preloadScanner(config->preloadScanner.release()) |
| 95 , m_decoder(config->decoder.release()) | 95 , m_decoder(config->decoder.release()) |
| 96 { | 96 { |
| 97 } | 97 } |
| 98 | 98 |
| 99 BackgroundHTMLParser::~BackgroundHTMLParser() | 99 BackgroundHTMLParser::~BackgroundHTMLParser() |
| 100 { | 100 { |
| 101 } | 101 } |
| 102 | 102 |
| 103 void BackgroundHTMLParser::appendRawBytesFromParserThread(const char* data, int
dataLength) | 103 void BackgroundHTMLParser::appendRawBytesFromParserThread(const char* data, int
dataLength) |
| 104 { | 104 { |
| 105 ASSERT(m_decoder); | 105 ASSERT(m_decoder); |
| 106 updateDocument(m_decoder->decode(data, dataLength)); | 106 updateDocument(m_decoder->decode(data, dataLength)); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void BackgroundHTMLParser::appendRawBytesFromMainThread(PassOwnPtr<Vector<char>
> buffer) | 109 void BackgroundHTMLParser::appendRawBytesFromMainThread(PassOwnPtr<Vector<char>>
buffer) |
| 110 { | 110 { |
| 111 ASSERT(m_decoder); | 111 ASSERT(m_decoder); |
| 112 updateDocument(m_decoder->decode(buffer->data(), buffer->size())); | 112 updateDocument(m_decoder->decode(buffer->data(), buffer->size())); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void BackgroundHTMLParser::appendDecodedBytes(const String& input) | 115 void BackgroundHTMLParser::appendDecodedBytes(const String& input) |
| 116 { | 116 { |
| 117 ASSERT(!m_input.current().isClosed()); | 117 ASSERT(!m_input.current().isClosed()); |
| 118 m_input.append(input); | 118 m_input.append(input); |
| 119 pumpTokenizer(); | 119 pumpTokenizer(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 chunk->treeBuilderState = m_treeBuilderSimulator.state(); | 252 chunk->treeBuilderState = m_treeBuilderSimulator.state(); |
| 253 chunk->inputCheckpoint = m_input.createCheckpoint(m_pendingTokens->size()); | 253 chunk->inputCheckpoint = m_input.createCheckpoint(m_pendingTokens->size()); |
| 254 chunk->preloadScannerCheckpoint = m_preloadScanner->createCheckpoint(); | 254 chunk->preloadScannerCheckpoint = m_preloadScanner->createCheckpoint(); |
| 255 chunk->tokens = m_pendingTokens.release(); | 255 chunk->tokens = m_pendingTokens.release(); |
| 256 callOnMainThread(bind(&HTMLDocumentParser::didReceiveParsedChunkFromBackgrou
ndParser, m_parser, chunk.release())); | 256 callOnMainThread(bind(&HTMLDocumentParser::didReceiveParsedChunkFromBackgrou
ndParser, m_parser, chunk.release())); |
| 257 | 257 |
| 258 m_pendingTokens = adoptPtr(new CompactHTMLTokenStream); | 258 m_pendingTokens = adoptPtr(new CompactHTMLTokenStream); |
| 259 } | 259 } |
| 260 | 260 |
| 261 } | 261 } |
| OLD | NEW |