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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 USING_FAST_MALLOC(BackgroundHTMLParser); | 49 USING_FAST_MALLOC(BackgroundHTMLParser); |
50 WTF_MAKE_NONCOPYABLE(BackgroundHTMLParser); | 50 WTF_MAKE_NONCOPYABLE(BackgroundHTMLParser); |
51 public: | 51 public: |
52 struct Configuration { | 52 struct Configuration { |
53 USING_FAST_MALLOC(Configuration); | 53 USING_FAST_MALLOC(Configuration); |
54 public: | 54 public: |
55 Configuration(); | 55 Configuration(); |
56 HTMLParserOptions options; | 56 HTMLParserOptions options; |
57 WeakPtr<HTMLDocumentParser> parser; | 57 WeakPtr<HTMLDocumentParser> parser; |
58 OwnPtr<XSSAuditor> xssAuditor; | 58 OwnPtr<XSSAuditor> xssAuditor; |
| 59 OwnPtr<TokenPreloadScanner> preloadScanner; |
59 OwnPtr<TextResourceDecoder> decoder; | 60 OwnPtr<TextResourceDecoder> decoder; |
60 RefPtr<ParsedChunkQueue> parsedChunkQueue; | 61 RefPtr<ParsedChunkQueue> parsedChunkQueue; |
61 // outstandingTokenLimit must be greater than or equal to | 62 // outstandingTokenLimit must be greater than or equal to |
62 // pendingTokenLimit | 63 // pendingTokenLimit |
63 size_t outstandingTokenLimit; | 64 size_t outstandingTokenLimit; |
64 size_t pendingTokenLimit; | 65 size_t pendingTokenLimit; |
65 }; | 66 }; |
66 | 67 |
67 static void start(PassRefPtr<WeakReference<BackgroundHTMLParser>>, PassOwnPt
r<Configuration>, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters>,
const MediaValuesCached::MediaValuesCachedData&, PassOwnPtr<WebTaskRunner>); | 68 static void start(PassRefPtr<WeakReference<BackgroundHTMLParser>>, PassOwnPt
r<Configuration>, PassOwnPtr<WebTaskRunner>); |
68 | 69 |
69 struct Checkpoint { | 70 struct Checkpoint { |
70 USING_FAST_MALLOC(Checkpoint); | 71 USING_FAST_MALLOC(Checkpoint); |
71 public: | 72 public: |
72 WeakPtr<HTMLDocumentParser> parser; | 73 WeakPtr<HTMLDocumentParser> parser; |
73 OwnPtr<HTMLToken> token; | 74 OwnPtr<HTMLToken> token; |
74 OwnPtr<HTMLTokenizer> tokenizer; | 75 OwnPtr<HTMLTokenizer> tokenizer; |
75 HTMLTreeBuilderSimulator::State treeBuilderState; | 76 HTMLTreeBuilderSimulator::State treeBuilderState; |
76 HTMLInputCheckpoint inputCheckpoint; | 77 HTMLInputCheckpoint inputCheckpoint; |
77 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; | 78 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; |
78 String unparsedInput; | 79 String unparsedInput; |
79 }; | 80 }; |
80 | 81 |
81 void appendRawBytesFromParserThread(const char* data, int dataLength); | 82 void appendRawBytesFromParserThread(const char* data, int dataLength); |
82 | 83 |
83 void appendRawBytesFromMainThread(PassOwnPtr<Vector<char>>); | 84 void appendRawBytesFromMainThread(PassOwnPtr<Vector<char>>); |
84 void setDecoder(PassOwnPtr<TextResourceDecoder>); | 85 void setDecoder(PassOwnPtr<TextResourceDecoder>); |
85 void flush(); | 86 void flush(); |
86 void resumeFrom(PassOwnPtr<Checkpoint>); | 87 void resumeFrom(PassOwnPtr<Checkpoint>); |
87 void startedChunkWithCheckpoint(HTMLInputCheckpoint); | 88 void startedChunkWithCheckpoint(HTMLInputCheckpoint); |
88 void finish(); | 89 void finish(); |
89 void stop(); | 90 void stop(); |
90 | 91 |
91 void forcePlaintextForTextDocument(); | 92 void forcePlaintextForTextDocument(); |
92 | 93 |
93 private: | 94 private: |
94 BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser>>, PassOw
nPtr<Configuration>, const KURL& documentURL, PassOwnPtr<CachedDocumentParameter
s>, const MediaValuesCached::MediaValuesCachedData&, PassOwnPtr<WebTaskRunner>); | 95 BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser>>, PassOw
nPtr<Configuration>, PassOwnPtr<WebTaskRunner>); |
95 ~BackgroundHTMLParser(); | 96 ~BackgroundHTMLParser(); |
96 | 97 |
97 void appendDecodedBytes(const String&); | 98 void appendDecodedBytes(const String&); |
98 void markEndOfFile(); | 99 void markEndOfFile(); |
99 void pumpTokenizer(); | 100 void pumpTokenizer(); |
100 void sendTokensToMainThread(); | 101 void sendTokensToMainThread(); |
101 void updateDocument(const String& decodedData); | 102 void updateDocument(const String& decodedData); |
102 | 103 |
103 WeakPtrFactory<BackgroundHTMLParser> m_weakFactory; | 104 WeakPtrFactory<BackgroundHTMLParser> m_weakFactory; |
104 BackgroundHTMLInputStream m_input; | 105 BackgroundHTMLInputStream m_input; |
(...skipping 16 matching lines...) Expand all Loading... |
121 DocumentEncodingData m_lastSeenEncodingData; | 122 DocumentEncodingData m_lastSeenEncodingData; |
122 OwnPtr<WebTaskRunner> m_loadingTaskRunner; | 123 OwnPtr<WebTaskRunner> m_loadingTaskRunner; |
123 RefPtr<ParsedChunkQueue> m_parsedChunkQueue; | 124 RefPtr<ParsedChunkQueue> m_parsedChunkQueue; |
124 | 125 |
125 bool m_startingScript; | 126 bool m_startingScript; |
126 }; | 127 }; |
127 | 128 |
128 } // namespace blink | 129 } // namespace blink |
129 | 130 |
130 #endif | 131 #endif |
OLD | NEW |