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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 class BackgroundHTMLParser { | 48 class BackgroundHTMLParser { |
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 RevocableCrossThreadWeakPersistent<HTMLDocumentParser> parser; |
58 std::unique_ptr<XSSAuditor> xssAuditor; | 58 std::unique_ptr<XSSAuditor> xssAuditor; |
59 std::unique_ptr<TextResourceDecoder> decoder; | 59 std::unique_ptr<TextResourceDecoder> decoder; |
60 RefPtr<TokenizedChunkQueue> tokenizedChunkQueue; | 60 RefPtr<TokenizedChunkQueue> tokenizedChunkQueue; |
61 // outstandingTokenLimit must be greater than or equal to | 61 // outstandingTokenLimit must be greater than or equal to |
62 // pendingTokenLimit | 62 // pendingTokenLimit |
63 size_t outstandingTokenLimit; | 63 size_t outstandingTokenLimit; |
64 size_t pendingTokenLimit; | 64 size_t pendingTokenLimit; |
65 bool shouldCoalesceChunks; | 65 bool shouldCoalesceChunks; |
66 }; | 66 }; |
67 | 67 |
68 // The returned BackgroundHTMLParser should only be used on the parser | 68 // The returned BackgroundHTMLParser should only be used on the parser |
69 // thread: it must first be initialized by calling init(), and free by | 69 // thread: it must first be initialized by calling init(), and free by |
70 // calling stop(). | 70 // calling stop(). |
71 static WeakPtr<BackgroundHTMLParser> create(std::unique_ptr<Configuration>,
std::unique_ptr<WebTaskRunner>); | 71 static WeakPtr<BackgroundHTMLParser> create(std::unique_ptr<Configuration>,
std::unique_ptr<WebTaskRunner>); |
72 void init(const KURL& documentURL, std::unique_ptr<CachedDocumentParameters>
, const MediaValuesCached::MediaValuesCachedData&); | 72 void init(const KURL& documentURL, std::unique_ptr<CachedDocumentParameters>
, const MediaValuesCached::MediaValuesCachedData&); |
73 | 73 |
74 struct Checkpoint { | 74 struct Checkpoint { |
75 USING_FAST_MALLOC(Checkpoint); | 75 USING_FAST_MALLOC(Checkpoint); |
76 public: | 76 public: |
77 WeakPtr<HTMLDocumentParser> parser; | 77 RevocableCrossThreadWeakPersistent<HTMLDocumentParser> parser; |
78 std::unique_ptr<HTMLToken> token; | 78 std::unique_ptr<HTMLToken> token; |
79 std::unique_ptr<HTMLTokenizer> tokenizer; | 79 std::unique_ptr<HTMLTokenizer> tokenizer; |
80 HTMLTreeBuilderSimulator::State treeBuilderState; | 80 HTMLTreeBuilderSimulator::State treeBuilderState; |
81 HTMLInputCheckpoint inputCheckpoint; | 81 HTMLInputCheckpoint inputCheckpoint; |
82 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; | 82 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; |
83 String unparsedInput; | 83 String unparsedInput; |
84 }; | 84 }; |
85 | 85 |
86 void appendRawBytesFromMainThread(std::unique_ptr<Vector<char>>, double byte
sReceivedTime); | 86 void appendRawBytesFromMainThread(std::unique_ptr<Vector<char>>, double byte
sReceivedTime); |
87 void setDecoder(std::unique_ptr<TextResourceDecoder>); | 87 void setDecoder(std::unique_ptr<TextResourceDecoder>); |
(...skipping 23 matching lines...) Expand all Loading... |
111 void runOnMainThread(FunctionType, Ps&&...); | 111 void runOnMainThread(FunctionType, Ps&&...); |
112 | 112 |
113 WeakPtrFactory<BackgroundHTMLParser> m_weakFactory; | 113 WeakPtrFactory<BackgroundHTMLParser> m_weakFactory; |
114 BackgroundHTMLInputStream m_input; | 114 BackgroundHTMLInputStream m_input; |
115 HTMLSourceTracker m_sourceTracker; | 115 HTMLSourceTracker m_sourceTracker; |
116 std::unique_ptr<HTMLToken> m_token; | 116 std::unique_ptr<HTMLToken> m_token; |
117 std::unique_ptr<HTMLTokenizer> m_tokenizer; | 117 std::unique_ptr<HTMLTokenizer> m_tokenizer; |
118 HTMLTreeBuilderSimulator m_treeBuilderSimulator; | 118 HTMLTreeBuilderSimulator m_treeBuilderSimulator; |
119 HTMLParserOptions m_options; | 119 HTMLParserOptions m_options; |
120 const size_t m_outstandingTokenLimit; | 120 const size_t m_outstandingTokenLimit; |
121 WeakPtr<HTMLDocumentParser> m_parser; | 121 RevocableCrossThreadWeakPersistent<HTMLDocumentParser> m_parser; |
122 | 122 |
123 std::unique_ptr<CompactHTMLTokenStream> m_pendingTokens; | 123 std::unique_ptr<CompactHTMLTokenStream> m_pendingTokens; |
124 const size_t m_pendingTokenLimit; | 124 const size_t m_pendingTokenLimit; |
125 PreloadRequestStream m_pendingPreloads; | 125 PreloadRequestStream m_pendingPreloads; |
126 // Indices into |m_pendingTokens|. | 126 // Indices into |m_pendingTokens|. |
127 Vector<int> m_likelyDocumentWriteScriptIndices; | 127 Vector<int> m_likelyDocumentWriteScriptIndices; |
128 ViewportDescriptionWrapper m_viewportDescription; | 128 ViewportDescriptionWrapper m_viewportDescription; |
129 XSSInfoStream m_pendingXSSInfos; | 129 XSSInfoStream m_pendingXSSInfos; |
130 | 130 |
131 std::unique_ptr<XSSAuditor> m_xssAuditor; | 131 std::unique_ptr<XSSAuditor> m_xssAuditor; |
132 std::unique_ptr<TokenPreloadScanner> m_preloadScanner; | 132 std::unique_ptr<TokenPreloadScanner> m_preloadScanner; |
133 std::unique_ptr<TextResourceDecoder> m_decoder; | 133 std::unique_ptr<TextResourceDecoder> m_decoder; |
134 DocumentEncodingData m_lastSeenEncodingData; | 134 DocumentEncodingData m_lastSeenEncodingData; |
135 std::unique_ptr<WebTaskRunner> m_loadingTaskRunner; | 135 std::unique_ptr<WebTaskRunner> m_loadingTaskRunner; |
136 RefPtr<TokenizedChunkQueue> m_tokenizedChunkQueue; | 136 RefPtr<TokenizedChunkQueue> m_tokenizedChunkQueue; |
137 | 137 |
138 // Index into |m_pendingTokens| of the last <meta> csp token found. Will be | 138 // Index into |m_pendingTokens| of the last <meta> csp token found. Will be |
139 // |TokenizedChunk::noPendingToken| if none have been found. | 139 // |TokenizedChunk::noPendingToken| if none have been found. |
140 int m_pendingCSPMetaTokenIndex; | 140 int m_pendingCSPMetaTokenIndex; |
141 | 141 |
142 bool m_startingScript; | 142 bool m_startingScript; |
143 double m_lastBytesReceivedTime; | 143 double m_lastBytesReceivedTime; |
144 bool m_shouldCoalesceChunks; | 144 bool m_shouldCoalesceChunks; |
145 }; | 145 }; |
146 | 146 |
147 } // namespace blink | 147 } // namespace blink |
148 | 148 |
149 #endif | 149 #endif |
OLD | NEW |