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 13 matching lines...) Expand all Loading... |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "core/html/parser/BackgroundHTMLParser.h" | 27 #include "core/html/parser/BackgroundHTMLParser.h" |
28 | 28 |
29 #include "core/HTMLNames.h" | 29 #include "core/HTMLNames.h" |
30 #include "core/html/parser/HTMLDocumentParser.h" | 30 #include "core/html/parser/HTMLDocumentParser.h" |
31 #include "core/html/parser/TextResourceDecoder.h" | 31 #include "core/html/parser/TextResourceDecoder.h" |
32 #include "core/html/parser/XSSAuditor.h" | 32 #include "core/html/parser/XSSAuditor.h" |
33 #include "platform/scheduler/ClosureRunnerTask.h" | 33 #include "platform/scheduler/ClosureRunnerTask.h" |
34 #include "platform/scheduler/Scheduler.h" | |
35 #include "public/platform/Platform.h" | 34 #include "public/platform/Platform.h" |
| 35 #include "public/platform/WebScheduler.h" |
36 #include "wtf/text/TextPosition.h" | 36 #include "wtf/text/TextPosition.h" |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 // On a network with high latency and high bandwidth, using a device | 40 // On a network with high latency and high bandwidth, using a device |
41 // with a fast CPU, we could end up speculatively tokenizing | 41 // with a fast CPU, we could end up speculatively tokenizing |
42 // the whole document, well ahead of when the main-thread actually needs it. | 42 // the whole document, well ahead of when the main-thread actually needs it. |
43 // This is a waste of memory (and potentially time if the speculation fails). | 43 // This is a waste of memory (and potentially time if the speculation fails). |
44 // So we limit our outstanding tokens arbitrarily to 10,000. | 44 // So we limit our outstanding tokens arbitrarily to 10,000. |
45 // Our maximal memory spent speculating will be approximately: | 45 // Our maximal memory spent speculating will be approximately: |
(...skipping 26 matching lines...) Expand all Loading... |
72 } | 72 } |
73 | 73 |
74 static void checkThatXSSInfosAreSafeToSendToAnotherThread(const XSSInfoStream& i
nfos) | 74 static void checkThatXSSInfosAreSafeToSendToAnotherThread(const XSSInfoStream& i
nfos) |
75 { | 75 { |
76 for (size_t i = 0; i < infos.size(); ++i) | 76 for (size_t i = 0; i < infos.size(); ++i) |
77 ASSERT(infos[i]->isSafeToSendToAnotherThread()); | 77 ASSERT(infos[i]->isSafeToSendToAnotherThread()); |
78 } | 78 } |
79 | 79 |
80 #endif | 80 #endif |
81 | 81 |
82 void BackgroundHTMLParser::start(PassRefPtr<WeakReference<BackgroundHTMLParser>>
reference, PassOwnPtr<Configuration> config, Scheduler* scheduler) | 82 void BackgroundHTMLParser::start(PassRefPtr<WeakReference<BackgroundHTMLParser>>
reference, PassOwnPtr<Configuration> config, WebScheduler* scheduler) |
83 { | 83 { |
84 new BackgroundHTMLParser(reference, config, scheduler); | 84 new BackgroundHTMLParser(reference, config, scheduler); |
85 // Caller must free by calling stop(). | 85 // Caller must free by calling stop(). |
86 } | 86 } |
87 | 87 |
88 BackgroundHTMLParser::BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHT
MLParser>> reference, PassOwnPtr<Configuration> config, Scheduler* scheduler) | 88 BackgroundHTMLParser::BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHT
MLParser>> reference, PassOwnPtr<Configuration> config, WebScheduler* scheduler) |
89 : m_weakFactory(reference, this) | 89 : m_weakFactory(reference, this) |
90 , m_token(adoptPtr(new HTMLToken)) | 90 , m_token(adoptPtr(new HTMLToken)) |
91 , m_tokenizer(HTMLTokenizer::create(config->options)) | 91 , m_tokenizer(HTMLTokenizer::create(config->options)) |
92 , m_treeBuilderSimulator(config->options) | 92 , m_treeBuilderSimulator(config->options) |
93 , m_options(config->options) | 93 , m_options(config->options) |
94 , m_parser(config->parser) | 94 , m_parser(config->parser) |
95 , m_pendingTokens(adoptPtr(new CompactHTMLTokenStream)) | 95 , m_pendingTokens(adoptPtr(new CompactHTMLTokenStream)) |
96 , m_xssAuditor(config->xssAuditor.release()) | 96 , m_xssAuditor(config->xssAuditor.release()) |
97 , m_preloadScanner(config->preloadScanner.release()) | 97 , m_preloadScanner(config->preloadScanner.release()) |
98 , m_decoder(config->decoder.release()) | 98 , m_decoder(config->decoder.release()) |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 m_startingScript = false; | 273 m_startingScript = false; |
274 | 274 |
275 m_scheduler->postLoadingTask( | 275 m_scheduler->postLoadingTask( |
276 FROM_HERE, | 276 FROM_HERE, |
277 new ClosureRunnerTask(bind(&HTMLDocumentParser::didReceiveParsedChunkFro
mBackgroundParser, m_parser, chunk.release()))); | 277 new ClosureRunnerTask(bind(&HTMLDocumentParser::didReceiveParsedChunkFro
mBackgroundParser, m_parser, chunk.release()))); |
278 | 278 |
279 m_pendingTokens = adoptPtr(new CompactHTMLTokenStream); | 279 m_pendingTokens = adoptPtr(new CompactHTMLTokenStream); |
280 } | 280 } |
281 | 281 |
282 } | 282 } |
OLD | NEW |