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 24 matching lines...) Expand all Loading... |
35 #include "core/html/parser/HTMLTreeBuilderSimulator.h" | 35 #include "core/html/parser/HTMLTreeBuilderSimulator.h" |
36 #include "core/html/parser/TextResourceDecoder.h" | 36 #include "core/html/parser/TextResourceDecoder.h" |
37 #include "core/html/parser/XSSAuditorDelegate.h" | 37 #include "core/html/parser/XSSAuditorDelegate.h" |
38 #include "wtf/PassOwnPtr.h" | 38 #include "wtf/PassOwnPtr.h" |
39 #include "wtf/WeakPtr.h" | 39 #include "wtf/WeakPtr.h" |
40 | 40 |
41 namespace blink { | 41 namespace blink { |
42 | 42 |
43 class HTMLDocumentParser; | 43 class HTMLDocumentParser; |
44 class XSSAuditor; | 44 class XSSAuditor; |
45 class WebTaskRunner; | 45 class WebScheduler; |
46 | 46 |
47 class BackgroundHTMLParser { | 47 class BackgroundHTMLParser { |
48 WTF_MAKE_FAST_ALLOCATED(BackgroundHTMLParser); | 48 WTF_MAKE_FAST_ALLOCATED(BackgroundHTMLParser); |
49 WTF_MAKE_NONCOPYABLE(BackgroundHTMLParser); | 49 WTF_MAKE_NONCOPYABLE(BackgroundHTMLParser); |
50 public: | 50 public: |
51 struct Configuration { | 51 struct Configuration { |
52 WTF_MAKE_FAST_ALLOCATED(Configuration); | 52 WTF_MAKE_FAST_ALLOCATED(Configuration); |
53 public: | 53 public: |
54 Configuration(); | 54 Configuration(); |
55 HTMLParserOptions options; | 55 HTMLParserOptions options; |
56 WeakPtr<HTMLDocumentParser> parser; | 56 WeakPtr<HTMLDocumentParser> parser; |
57 OwnPtr<XSSAuditor> xssAuditor; | 57 OwnPtr<XSSAuditor> xssAuditor; |
58 OwnPtr<TokenPreloadScanner> preloadScanner; | 58 OwnPtr<TokenPreloadScanner> preloadScanner; |
59 OwnPtr<TextResourceDecoder> decoder; | 59 OwnPtr<TextResourceDecoder> decoder; |
60 // outstandingTokenLimit must be greater than or equal to | 60 // outstandingTokenLimit must be greater than or equal to |
61 // pendingTokenLimit | 61 // pendingTokenLimit |
62 size_t outstandingTokenLimit; | 62 size_t outstandingTokenLimit; |
63 size_t pendingTokenLimit; | 63 size_t pendingTokenLimit; |
64 }; | 64 }; |
65 | 65 |
66 static void start(PassRefPtr<WeakReference<BackgroundHTMLParser>>, PassOwnPt
r<Configuration>, PassOwnPtr<WebTaskRunner>); | 66 static void start(PassRefPtr<WeakReference<BackgroundHTMLParser>>, PassOwnPt
r<Configuration>, WebScheduler*); |
67 | 67 |
68 struct Checkpoint { | 68 struct Checkpoint { |
69 WTF_MAKE_FAST_ALLOCATED(CheckPoint); | 69 WTF_MAKE_FAST_ALLOCATED(CheckPoint); |
70 public: | 70 public: |
71 WeakPtr<HTMLDocumentParser> parser; | 71 WeakPtr<HTMLDocumentParser> parser; |
72 OwnPtr<HTMLToken> token; | 72 OwnPtr<HTMLToken> token; |
73 OwnPtr<HTMLTokenizer> tokenizer; | 73 OwnPtr<HTMLTokenizer> tokenizer; |
74 HTMLTreeBuilderSimulator::State treeBuilderState; | 74 HTMLTreeBuilderSimulator::State treeBuilderState; |
75 HTMLInputCheckpoint inputCheckpoint; | 75 HTMLInputCheckpoint inputCheckpoint; |
76 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; | 76 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; |
77 String unparsedInput; | 77 String unparsedInput; |
78 }; | 78 }; |
79 | 79 |
80 void appendRawBytesFromParserThread(const char* data, int dataLength); | 80 void appendRawBytesFromParserThread(const char* data, int dataLength); |
81 | 81 |
82 void appendRawBytesFromMainThread(PassOwnPtr<Vector<char>>); | 82 void appendRawBytesFromMainThread(PassOwnPtr<Vector<char>>); |
83 void setDecoder(PassOwnPtr<TextResourceDecoder>); | 83 void setDecoder(PassOwnPtr<TextResourceDecoder>); |
84 void flush(); | 84 void flush(); |
85 void resumeFrom(PassOwnPtr<Checkpoint>); | 85 void resumeFrom(PassOwnPtr<Checkpoint>); |
86 void startedChunkWithCheckpoint(HTMLInputCheckpoint); | 86 void startedChunkWithCheckpoint(HTMLInputCheckpoint); |
87 void finish(); | 87 void finish(); |
88 void stop(); | 88 void stop(); |
89 | 89 |
90 void forcePlaintextForTextDocument(); | 90 void forcePlaintextForTextDocument(); |
91 | 91 |
92 private: | 92 private: |
93 BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser>>, PassOw
nPtr<Configuration>, PassOwnPtr<WebTaskRunner>); | 93 BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser>>, PassOw
nPtr<Configuration>, WebScheduler*); |
94 ~BackgroundHTMLParser(); | 94 ~BackgroundHTMLParser(); |
95 | 95 |
96 void appendDecodedBytes(const String&); | 96 void appendDecodedBytes(const String&); |
97 void markEndOfFile(); | 97 void markEndOfFile(); |
98 void pumpTokenizer(); | 98 void pumpTokenizer(); |
99 void sendTokensToMainThread(); | 99 void sendTokensToMainThread(); |
100 void updateDocument(const String& decodedData); | 100 void updateDocument(const String& decodedData); |
101 | 101 |
102 WeakPtrFactory<BackgroundHTMLParser> m_weakFactory; | 102 WeakPtrFactory<BackgroundHTMLParser> m_weakFactory; |
103 BackgroundHTMLInputStream m_input; | 103 BackgroundHTMLInputStream m_input; |
104 HTMLSourceTracker m_sourceTracker; | 104 HTMLSourceTracker m_sourceTracker; |
105 OwnPtr<HTMLToken> m_token; | 105 OwnPtr<HTMLToken> m_token; |
106 OwnPtr<HTMLTokenizer> m_tokenizer; | 106 OwnPtr<HTMLTokenizer> m_tokenizer; |
107 HTMLTreeBuilderSimulator m_treeBuilderSimulator; | 107 HTMLTreeBuilderSimulator m_treeBuilderSimulator; |
108 HTMLParserOptions m_options; | 108 HTMLParserOptions m_options; |
109 const size_t m_outstandingTokenLimit; | 109 const size_t m_outstandingTokenLimit; |
110 WeakPtr<HTMLDocumentParser> m_parser; | 110 WeakPtr<HTMLDocumentParser> m_parser; |
111 | 111 |
112 OwnPtr<CompactHTMLTokenStream> m_pendingTokens; | 112 OwnPtr<CompactHTMLTokenStream> m_pendingTokens; |
113 const size_t m_pendingTokenLimit; | 113 const size_t m_pendingTokenLimit; |
114 PreloadRequestStream m_pendingPreloads; | 114 PreloadRequestStream m_pendingPreloads; |
115 XSSInfoStream m_pendingXSSInfos; | 115 XSSInfoStream m_pendingXSSInfos; |
116 | 116 |
117 OwnPtr<XSSAuditor> m_xssAuditor; | 117 OwnPtr<XSSAuditor> m_xssAuditor; |
118 OwnPtr<TokenPreloadScanner> m_preloadScanner; | 118 OwnPtr<TokenPreloadScanner> m_preloadScanner; |
119 OwnPtr<TextResourceDecoder> m_decoder; | 119 OwnPtr<TextResourceDecoder> m_decoder; |
120 DocumentEncodingData m_lastSeenEncodingData; | 120 DocumentEncodingData m_lastSeenEncodingData; |
121 OwnPtr<WebTaskRunner> m_loadingTaskRunner; | 121 WebScheduler* m_scheduler; // NOT OWNED, scheduler will outlive BackgroundHT
MLParser |
122 | 122 |
123 bool m_startingScript; | 123 bool m_startingScript; |
124 }; | 124 }; |
125 | 125 |
126 } | 126 } |
127 | 127 |
128 #endif | 128 #endif |
OLD | NEW |