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

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

Issue 141143007: Revert of Revert "Moved text decoding to the parser thread" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 11 months 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
« no previous file with comments | « Source/core/html/HTMLBaseElement.cpp ('k') | Source/core/html/parser/BackgroundHTMLParser.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
53 OwnPtr<TextResourceDecoder> decoder;
54 }; 54 };
55 55
56 static void create(PassRefPtr<WeakReference<BackgroundHTMLParser> > referenc e, PassOwnPtr<Configuration> config) 56 static void start(PassRefPtr<WeakReference<BackgroundHTMLParser> >, PassOwnP tr<Configuration>);
57 {
58 new BackgroundHTMLParser(reference, config);
59 // Caller must free by calling stop().
60 }
61 57
62 struct Checkpoint { 58 struct Checkpoint {
63 WeakPtr<HTMLDocumentParser> parser; 59 WeakPtr<HTMLDocumentParser> parser;
64 OwnPtr<HTMLToken> token; 60 OwnPtr<HTMLToken> token;
65 OwnPtr<HTMLTokenizer> tokenizer; 61 OwnPtr<HTMLTokenizer> tokenizer;
66 HTMLTreeBuilderSimulator::State treeBuilderState; 62 HTMLTreeBuilderSimulator::State treeBuilderState;
67 HTMLInputCheckpoint inputCheckpoint; 63 HTMLInputCheckpoint inputCheckpoint;
68 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; 64 TokenPreloadScannerCheckpoint preloadScannerCheckpoint;
69 String unparsedInput; 65 String unparsedInput;
70 }; 66 };
71 67
72 void append(const String&); 68 void appendBytes(PassOwnPtr<Vector<char> >);
69 void setDecoder(PassOwnPtr<TextResourceDecoder>);
70 void flush();
73 void resumeFrom(PassOwnPtr<Checkpoint>); 71 void resumeFrom(PassOwnPtr<Checkpoint>);
74 void startedChunkWithCheckpoint(HTMLInputCheckpoint); 72 void startedChunkWithCheckpoint(HTMLInputCheckpoint);
75 void finish(); 73 void finish();
76 void stop(); 74 void stop();
77 75
78 void forcePlaintextForTextDocument(); 76 void forcePlaintextForTextDocument();
79 77
80 private: 78 private:
81 BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser> >, PassO wnPtr<Configuration>); 79 BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser> >, PassO wnPtr<Configuration>);
80 ~BackgroundHTMLParser();
82 81
82 void append(const String&);
83 void markEndOfFile(); 83 void markEndOfFile();
84 void pumpTokenizer(); 84 void pumpTokenizer();
85 void sendTokensToMainThread(); 85 void sendTokensToMainThread();
86 void updateDocument(const String& decodedData);
86 87
87 WeakPtrFactory<BackgroundHTMLParser> m_weakFactory; 88 WeakPtrFactory<BackgroundHTMLParser> m_weakFactory;
88 BackgroundHTMLInputStream m_input; 89 BackgroundHTMLInputStream m_input;
89 HTMLSourceTracker m_sourceTracker; 90 HTMLSourceTracker m_sourceTracker;
90 OwnPtr<HTMLToken> m_token; 91 OwnPtr<HTMLToken> m_token;
91 OwnPtr<HTMLTokenizer> m_tokenizer; 92 OwnPtr<HTMLTokenizer> m_tokenizer;
92 HTMLTreeBuilderSimulator m_treeBuilderSimulator; 93 HTMLTreeBuilderSimulator m_treeBuilderSimulator;
93 HTMLParserOptions m_options; 94 HTMLParserOptions m_options;
94 WeakPtr<HTMLDocumentParser> m_parser; 95 WeakPtr<HTMLDocumentParser> m_parser;
95 96
96 OwnPtr<CompactHTMLTokenStream> m_pendingTokens; 97 OwnPtr<CompactHTMLTokenStream> m_pendingTokens;
97 PreloadRequestStream m_pendingPreloads; 98 PreloadRequestStream m_pendingPreloads;
98 XSSInfoStream m_pendingXSSInfos; 99 XSSInfoStream m_pendingXSSInfos;
99 100
100 OwnPtr<XSSAuditor> m_xssAuditor; 101 OwnPtr<XSSAuditor> m_xssAuditor;
101 OwnPtr<TokenPreloadScanner> m_preloadScanner; 102 OwnPtr<TokenPreloadScanner> m_preloadScanner;
103 OwnPtr<TextResourceDecoder> m_decoder;
104 DocumentEncodingData m_lastSeenEncodingData;
102 }; 105 };
103 106
104 } 107 }
105 108
106 #endif 109 #endif
OLDNEW
« no previous file with comments | « Source/core/html/HTMLBaseElement.cpp ('k') | Source/core/html/parser/BackgroundHTMLParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698