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

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

Issue 100563004: Redirect HTML resource bytes directly to parser thread (Blink side CL) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@parserthread_decodermove
Patch Set: Missing include Created 7 years 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 15 matching lines...) Expand all
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/HTMLTreeBuilderSimulator.h" 34 #include "core/html/parser/HTMLTreeBuilderSimulator.h"
35 #include "core/html/parser/XSSAuditorDelegate.h" 35 #include "core/html/parser/XSSAuditorDelegate.h"
36 #include "public/platform/WebParserResourceBridge.h"
36 #include "wtf/PassOwnPtr.h" 37 #include "wtf/PassOwnPtr.h"
37 #include "wtf/WeakPtr.h" 38 #include "wtf/WeakPtr.h"
39 #include <vector>
abarth-chromium 2013/12/18 18:28:49 wtf/Vector.h
38 40
39 namespace WebCore { 41 namespace WebCore {
40 42
41 class HTMLDocumentParser; 43 class HTMLDocumentParser;
42 class SharedBuffer; 44 class SharedBuffer;
43 class XSSAuditor; 45 class XSSAuditor;
44 46
45 class BackgroundHTMLParser { 47 class BackgroundHTMLParser : public blink::WebParserResourceBridge::Peer {
46 WTF_MAKE_FAST_ALLOCATED; 48 WTF_MAKE_FAST_ALLOCATED;
47 public: 49 public:
48 struct Configuration { 50 struct Configuration {
49 HTMLParserOptions options; 51 HTMLParserOptions options;
50 WeakPtr<HTMLDocumentParser> parser; 52 WeakPtr<HTMLDocumentParser> parser;
51 OwnPtr<XSSAuditor> xssAuditor; 53 OwnPtr<XSSAuditor> xssAuditor;
52 OwnPtr<TokenPreloadScanner> preloadScanner; 54 OwnPtr<TokenPreloadScanner> preloadScanner;
53 OwnPtr<TextResourceDecoder> decoder; 55 OwnPtr<TextResourceDecoder> decoder;
56 OwnPtr<blink::WebParserResourceBridge> resourceBridge;
54 }; 57 };
55 58
56 static void start(PassRefPtr<WeakReference<BackgroundHTMLParser> >, PassOwnP tr<Configuration>); 59 static void start(PassRefPtr<WeakReference<BackgroundHTMLParser> >, PassOwnP tr<Configuration>);
57 60
58 struct Checkpoint { 61 struct Checkpoint {
59 WeakPtr<HTMLDocumentParser> parser; 62 WeakPtr<HTMLDocumentParser> parser;
60 OwnPtr<HTMLToken> token; 63 OwnPtr<HTMLToken> token;
61 OwnPtr<HTMLTokenizer> tokenizer; 64 OwnPtr<HTMLTokenizer> tokenizer;
62 HTMLTreeBuilderSimulator::State treeBuilderState; 65 HTMLTreeBuilderSimulator::State treeBuilderState;
63 HTMLInputCheckpoint inputCheckpoint; 66 HTMLInputCheckpoint inputCheckpoint;
64 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; 67 TokenPreloadScannerCheckpoint preloadScannerCheckpoint;
65 String unparsedInput; 68 String unparsedInput;
66 }; 69 };
67 70
71 // From blink::WebParserResourceBridge::Peer
72 virtual void OnReceivedData(const char* data, size_t length);
abarth-chromium 2013/12/18 18:28:49 didReceiveData
73
68 void appendBytes(PassOwnPtr<Vector<char> >); 74 void appendBytes(PassOwnPtr<Vector<char> >);
69 void setDecoder(PassOwnPtr<TextResourceDecoder>); 75 void setDecoder(PassOwnPtr<TextResourceDecoder>);
70 void flush(); 76 void flush();
71 void resumeFrom(PassOwnPtr<Checkpoint>); 77 void resumeFrom(PassOwnPtr<Checkpoint>);
72 void startedChunkWithCheckpoint(HTMLInputCheckpoint); 78 void startedChunkWithCheckpoint(HTMLInputCheckpoint);
73 void finish(); 79 void finish();
74 void stop(); 80 void stop();
81 void resourceFilterAdded();
75 82
76 void forcePlaintextForTextDocument(); 83 void forcePlaintextForTextDocument();
77 84
78 private: 85 private:
79 BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser> >, PassO wnPtr<Configuration>); 86 BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser> >, PassO wnPtr<Configuration>);
80 ~BackgroundHTMLParser(); 87 virtual ~BackgroundHTMLParser();
81 88
82 void append(const String&); 89 void append(const String&);
83 void markEndOfFile(); 90 void markEndOfFile();
84 void pumpTokenizer(); 91 void pumpTokenizer();
85 void sendTokensToMainThread(); 92 void sendTokensToMainThread();
86 void updateDocument(const String& decodedData); 93 void updateDocument(const String& decodedData);
87 94
88 WeakPtrFactory<BackgroundHTMLParser> m_weakFactory; 95 WeakPtrFactory<BackgroundHTMLParser> m_weakFactory;
89 BackgroundHTMLInputStream m_input; 96 BackgroundHTMLInputStream m_input;
90 HTMLSourceTracker m_sourceTracker; 97 HTMLSourceTracker m_sourceTracker;
91 OwnPtr<HTMLToken> m_token; 98 OwnPtr<HTMLToken> m_token;
92 OwnPtr<HTMLTokenizer> m_tokenizer; 99 OwnPtr<HTMLTokenizer> m_tokenizer;
93 HTMLTreeBuilderSimulator m_treeBuilderSimulator; 100 HTMLTreeBuilderSimulator m_treeBuilderSimulator;
94 HTMLParserOptions m_options; 101 HTMLParserOptions m_options;
95 WeakPtr<HTMLDocumentParser> m_parser; 102 WeakPtr<HTMLDocumentParser> m_parser;
96 103
97 OwnPtr<CompactHTMLTokenStream> m_pendingTokens; 104 OwnPtr<CompactHTMLTokenStream> m_pendingTokens;
98 PreloadRequestStream m_pendingPreloads; 105 PreloadRequestStream m_pendingPreloads;
99 XSSInfoStream m_pendingXSSInfos; 106 XSSInfoStream m_pendingXSSInfos;
100 107
101 OwnPtr<XSSAuditor> m_xssAuditor; 108 OwnPtr<XSSAuditor> m_xssAuditor;
102 OwnPtr<TokenPreloadScanner> m_preloadScanner; 109 OwnPtr<TokenPreloadScanner> m_preloadScanner;
103 OwnPtr<TextResourceDecoder> m_decoder; 110 OwnPtr<TextResourceDecoder> m_decoder;
111 OwnPtr<blink::WebParserResourceBridge> m_resourceBridge;
104 DocumentEncodingData m_lastSeenEncodingData; 112 DocumentEncodingData m_lastSeenEncodingData;
113 bool m_parserThreadIsStandalone;
114 typedef std::vector< std::pair<const char*, size_t> > DataQueue;
abarth-chromium 2013/12/18 18:28:49 Please use a named struct instead of std::pair
115 DataQueue m_queuedData;
105 }; 116 };
106 117
107 } 118 }
108 119
109 #endif 120 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698