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

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

Issue 2550373005: Make WebTaskRunner ThreadSafeRefCounted (Closed)
Patch Set: mac fix Created 4 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // pendingTokenLimit 64 // pendingTokenLimit
65 size_t outstandingTokenLimit; 65 size_t outstandingTokenLimit;
66 size_t pendingTokenLimit; 66 size_t pendingTokenLimit;
67 bool shouldCoalesceChunks; 67 bool shouldCoalesceChunks;
68 }; 68 };
69 69
70 // The returned BackgroundHTMLParser should only be used on the parser 70 // The returned BackgroundHTMLParser should only be used on the parser
71 // thread: it must first be initialized by calling init(), and free by 71 // thread: it must first be initialized by calling init(), and free by
72 // calling stop(). 72 // calling stop().
73 static WeakPtr<BackgroundHTMLParser> create(std::unique_ptr<Configuration>, 73 static WeakPtr<BackgroundHTMLParser> create(std::unique_ptr<Configuration>,
74 std::unique_ptr<WebTaskRunner>); 74 RefPtr<WebTaskRunner>);
75 void init(const KURL& documentURL, 75 void init(const KURL& documentURL,
76 std::unique_ptr<CachedDocumentParameters>, 76 std::unique_ptr<CachedDocumentParameters>,
77 const MediaValuesCached::MediaValuesCachedData&); 77 const MediaValuesCached::MediaValuesCachedData&);
78 78
79 struct Checkpoint { 79 struct Checkpoint {
80 USING_FAST_MALLOC(Checkpoint); 80 USING_FAST_MALLOC(Checkpoint);
81 81
82 public: 82 public:
83 WeakPtr<HTMLDocumentParser> parser; 83 WeakPtr<HTMLDocumentParser> parser;
84 std::unique_ptr<HTMLToken> token; 84 std::unique_ptr<HTMLToken> token;
85 std::unique_ptr<HTMLTokenizer> tokenizer; 85 std::unique_ptr<HTMLTokenizer> tokenizer;
86 HTMLTreeBuilderSimulator::State treeBuilderState; 86 HTMLTreeBuilderSimulator::State treeBuilderState;
87 HTMLInputCheckpoint inputCheckpoint; 87 HTMLInputCheckpoint inputCheckpoint;
88 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; 88 TokenPreloadScannerCheckpoint preloadScannerCheckpoint;
89 String unparsedInput; 89 String unparsedInput;
90 }; 90 };
91 91
92 void appendRawBytesFromMainThread(std::unique_ptr<Vector<char>>, 92 void appendRawBytesFromMainThread(std::unique_ptr<Vector<char>>,
93 double bytesReceivedTime); 93 double bytesReceivedTime);
94 void setDecoder(std::unique_ptr<TextResourceDecoder>); 94 void setDecoder(std::unique_ptr<TextResourceDecoder>);
95 void flush(); 95 void flush();
96 void resumeFrom(std::unique_ptr<Checkpoint>); 96 void resumeFrom(std::unique_ptr<Checkpoint>);
97 void startedChunkWithCheckpoint(HTMLInputCheckpoint); 97 void startedChunkWithCheckpoint(HTMLInputCheckpoint);
98 void finish(); 98 void finish();
99 void stop(); 99 void stop();
100 100
101 void forcePlaintextForTextDocument(); 101 void forcePlaintextForTextDocument();
102 102
103 private: 103 private:
104 BackgroundHTMLParser(std::unique_ptr<Configuration>, 104 BackgroundHTMLParser(std::unique_ptr<Configuration>, RefPtr<WebTaskRunner>);
105 std::unique_ptr<WebTaskRunner>);
106 ~BackgroundHTMLParser(); 105 ~BackgroundHTMLParser();
107 106
108 void appendDecodedBytes(const String&); 107 void appendDecodedBytes(const String&);
109 void markEndOfFile(); 108 void markEndOfFile();
110 void pumpTokenizer(); 109 void pumpTokenizer();
111 110
112 // Returns whether or not the HTMLDocumentParser should be notified of 111 // Returns whether or not the HTMLDocumentParser should be notified of
113 // pending chunks. 112 // pending chunks.
114 bool queueChunkForMainThread(); 113 bool queueChunkForMainThread();
115 void notifyMainThreadOfNewChunks(); 114 void notifyMainThreadOfNewChunks();
(...skipping 17 matching lines...) Expand all
133 PreloadRequestStream m_pendingPreloads; 132 PreloadRequestStream m_pendingPreloads;
134 // Indices into |m_pendingTokens|. 133 // Indices into |m_pendingTokens|.
135 Vector<int> m_likelyDocumentWriteScriptIndices; 134 Vector<int> m_likelyDocumentWriteScriptIndices;
136 ViewportDescriptionWrapper m_viewportDescription; 135 ViewportDescriptionWrapper m_viewportDescription;
137 XSSInfoStream m_pendingXSSInfos; 136 XSSInfoStream m_pendingXSSInfos;
138 137
139 std::unique_ptr<XSSAuditor> m_xssAuditor; 138 std::unique_ptr<XSSAuditor> m_xssAuditor;
140 std::unique_ptr<TokenPreloadScanner> m_preloadScanner; 139 std::unique_ptr<TokenPreloadScanner> m_preloadScanner;
141 std::unique_ptr<TextResourceDecoder> m_decoder; 140 std::unique_ptr<TextResourceDecoder> m_decoder;
142 DocumentEncodingData m_lastSeenEncodingData; 141 DocumentEncodingData m_lastSeenEncodingData;
143 std::unique_ptr<WebTaskRunner> m_loadingTaskRunner; 142 RefPtr<WebTaskRunner> m_loadingTaskRunner;
144 RefPtr<TokenizedChunkQueue> m_tokenizedChunkQueue; 143 RefPtr<TokenizedChunkQueue> m_tokenizedChunkQueue;
145 144
146 // Index into |m_pendingTokens| of the last <meta> csp token found. Will be 145 // Index into |m_pendingTokens| of the last <meta> csp token found. Will be
147 // |TokenizedChunk::noPendingToken| if none have been found. 146 // |TokenizedChunk::noPendingToken| if none have been found.
148 int m_pendingCSPMetaTokenIndex; 147 int m_pendingCSPMetaTokenIndex;
149 148
150 bool m_startingScript; 149 bool m_startingScript;
151 double m_lastBytesReceivedTime; 150 double m_lastBytesReceivedTime;
152 bool m_shouldCoalesceChunks; 151 bool m_shouldCoalesceChunks;
153 }; 152 };
154 153
155 } // namespace blink 154 } // namespace blink
156 155
157 #endif 156 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698