Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(609)

Side by Side Diff: Source/core/html/parser/BackgroundHTMLParser.h

Issue 74513003: Moved text decoding to the parser thread (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@parserthread_step25
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
24 */ 24 */
25 25
26 #ifndef BackgroundHTMLParser_h 26 #ifndef BackgroundHTMLParser_h
27 #define BackgroundHTMLParser_h 27 #define BackgroundHTMLParser_h
28 28
29 #include "core/html/parser/BackgroundHTMLInputStream.h" 29 #include "core/html/parser/BackgroundHTMLInputStream.h"
30 #include "core/html/parser/CompactHTMLToken.h" 30 #include "core/html/parser/CompactHTMLToken.h"
31 #include "core/html/parser/HTMLParserOptions.h" 31 #include "core/html/parser/HTMLParserOptions.h"
32 #include "core/html/parser/HTMLPreloadScanner.h" 32 #include "core/html/parser/HTMLPreloadScanner.h"
33 #include "core/html/parser/HTMLSourceTracker.h" 33 #include "core/html/parser/HTMLSourceTracker.h"
34 #include "core/html/parser/HTMLToken.h"
35 #include "core/html/parser/HTMLTokenizer.h"
36 #include "core/html/parser/HTMLTreeBuilderSimulator.h" 34 #include "core/html/parser/HTMLTreeBuilderSimulator.h"
37 #include "core/html/parser/XSSAuditorDelegate.h" 35 #include "core/html/parser/XSSAuditorDelegate.h"
38 #include "wtf/PassOwnPtr.h" 36 #include "wtf/PassOwnPtr.h"
39 #include "wtf/WeakPtr.h" 37 #include "wtf/WeakPtr.h"
40 38
41 namespace WebCore { 39 namespace WebCore {
42 40
43 class HTMLDocumentParser; 41 class HTMLDocumentParser;
42 class SharedBuffer;
44 class XSSAuditor; 43 class XSSAuditor;
45 44
46 class BackgroundHTMLParser { 45 class BackgroundHTMLParser {
47 WTF_MAKE_FAST_ALLOCATED; 46 WTF_MAKE_FAST_ALLOCATED;
48 public: 47 public:
49 struct Configuration { 48 struct Configuration {
50 HTMLParserOptions options; 49 HTMLParserOptions options;
51 WeakPtr<HTMLDocumentParser> parser; 50 WeakPtr<HTMLDocumentParser> parser;
52 OwnPtr<XSSAuditor> xssAuditor; 51 OwnPtr<XSSAuditor> xssAuditor;
53 OwnPtr<TokenPreloadScanner> preloadScanner; 52 OwnPtr<TokenPreloadScanner> preloadScanner;
54 }; 53 };
55 54
56 static void create(PassRefPtr<WeakReference<BackgroundHTMLParser> > referenc e, PassOwnPtr<Configuration> config) 55 static void create(PassRefPtr<WeakReference<BackgroundHTMLParser> >, PassOwn Ptr<Configuration>, PassOwnPtr<TextResourceDecoder>);
abarth-chromium 2013/11/18 06:57:10 Why not put the TextResourceDecoder in the Configu
eseidel 2013/11/18 20:07:40 +1
57 {
58 new BackgroundHTMLParser(reference, config);
59 // Caller must free by calling stop().
60 }
61 56
62 struct Checkpoint { 57 struct Checkpoint {
63 WeakPtr<HTMLDocumentParser> parser; 58 WeakPtr<HTMLDocumentParser> parser;
64 OwnPtr<HTMLToken> token; 59 OwnPtr<HTMLToken> token;
65 OwnPtr<HTMLTokenizer> tokenizer; 60 OwnPtr<HTMLTokenizer> tokenizer;
66 HTMLTreeBuilderSimulator::State treeBuilderState; 61 HTMLTreeBuilderSimulator::State treeBuilderState;
67 HTMLInputCheckpoint inputCheckpoint; 62 HTMLInputCheckpoint inputCheckpoint;
68 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; 63 TokenPreloadScannerCheckpoint preloadScannerCheckpoint;
69 String unparsedInput; 64 String unparsedInput;
70 }; 65 };
71 66
72 void append(const String&); 67 void append(const String&);
68 void appendBytes(PassRefPtr<SharedBuffer> data);
69 void flush();
73 void resumeFrom(PassOwnPtr<Checkpoint>); 70 void resumeFrom(PassOwnPtr<Checkpoint>);
74 void startedChunkWithCheckpoint(HTMLInputCheckpoint); 71 void startedChunkWithCheckpoint(HTMLInputCheckpoint);
75 void finish(); 72 void finish();
76 void stop(); 73 void stop();
77 74
78 void forcePlaintextForTextDocument(); 75 void forcePlaintextForTextDocument();
79 76
80 private: 77 private:
81 BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser> >, PassO wnPtr<Configuration>); 78 BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser> >, PassO wnPtr<Configuration>, PassOwnPtr<TextResourceDecoder>);
79 ~BackgroundHTMLParser();
82 80
83 void markEndOfFile(); 81 void markEndOfFile();
84 void pumpTokenizer(); 82 void pumpTokenizer();
85 void sendTokensToMainThread(); 83 void sendTokensToMainThread();
84 void updateDocument(String& decodedData);
86 85
87 WeakPtrFactory<BackgroundHTMLParser> m_weakFactory; 86 WeakPtrFactory<BackgroundHTMLParser> m_weakFactory;
88 BackgroundHTMLInputStream m_input; 87 BackgroundHTMLInputStream m_input;
89 HTMLSourceTracker m_sourceTracker; 88 HTMLSourceTracker m_sourceTracker;
90 OwnPtr<HTMLToken> m_token; 89 OwnPtr<HTMLToken> m_token;
91 OwnPtr<HTMLTokenizer> m_tokenizer; 90 OwnPtr<HTMLTokenizer> m_tokenizer;
92 HTMLTreeBuilderSimulator m_treeBuilderSimulator; 91 HTMLTreeBuilderSimulator m_treeBuilderSimulator;
93 HTMLParserOptions m_options; 92 HTMLParserOptions m_options;
94 WeakPtr<HTMLDocumentParser> m_parser; 93 WeakPtr<HTMLDocumentParser> m_parser;
95 94
96 OwnPtr<CompactHTMLTokenStream> m_pendingTokens; 95 OwnPtr<CompactHTMLTokenStream> m_pendingTokens;
97 PreloadRequestStream m_pendingPreloads; 96 PreloadRequestStream m_pendingPreloads;
98 XSSInfoStream m_pendingXSSInfos; 97 XSSInfoStream m_pendingXSSInfos;
99 98
100 OwnPtr<XSSAuditor> m_xssAuditor; 99 OwnPtr<XSSAuditor> m_xssAuditor;
101 OwnPtr<TokenPreloadScanner> m_preloadScanner; 100 OwnPtr<TokenPreloadScanner> m_preloadScanner;
101 OwnPtr<TextResourceDecoder> m_decoder;
102 DocumentEncodingData m_lastSeenEncodingData;
102 }; 103 };
103 104
104 } 105 }
105 106
106 #endif 107 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698