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

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

Issue 1641853003: Create MediaValuesCached and TokenPreloadScanner on the parser thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@TRV_MediaValuesCached
Patch Set: Disable test on asan bots Created 4 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2010 Google Inc. All Rights Reserved. 3 * Copyright (C) 2010 Google Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 30 matching lines...) Expand all
41 41
42 typedef size_t TokenPreloadScannerCheckpoint; 42 typedef size_t TokenPreloadScannerCheckpoint;
43 43
44 class HTMLParserOptions; 44 class HTMLParserOptions;
45 class HTMLTokenizer; 45 class HTMLTokenizer;
46 class SegmentedString; 46 class SegmentedString;
47 47
48 struct CORE_EXPORT CachedDocumentParameters { 48 struct CORE_EXPORT CachedDocumentParameters {
49 USING_FAST_MALLOC(CachedDocumentParameters); 49 USING_FAST_MALLOC(CachedDocumentParameters);
50 public: 50 public:
51 static PassOwnPtr<CachedDocumentParameters> create(Document* document, PassR efPtrWillBeRawPtr<MediaValuesCached> mediaValues = nullptr) 51 static PassOwnPtr<CachedDocumentParameters> create(Document* document)
52 { 52 {
53 return adoptPtr(new CachedDocumentParameters(document, mediaValues)); 53 return adoptPtr(new CachedDocumentParameters(document));
54 } 54 }
55 55
56 bool doHtmlPreloadScanning; 56 bool doHtmlPreloadScanning;
57 RefPtrWillBeCrossThreadPersistent<MediaValuesCached> mediaValues;
58 Length defaultViewportMinWidth; 57 Length defaultViewportMinWidth;
59 bool viewportMetaZeroValuesQuirk; 58 bool viewportMetaZeroValuesQuirk;
60 bool viewportMetaEnabled; 59 bool viewportMetaEnabled;
61 ReferrerPolicy referrerPolicy; 60 ReferrerPolicy referrerPolicy;
62 61
63 private: 62 private:
64 CachedDocumentParameters(Document*, PassRefPtrWillBeRawPtr<MediaValuesCached >); 63 explicit CachedDocumentParameters(Document*);
65 }; 64 };
66 65
67 class TokenPreloadScanner { 66 class TokenPreloadScanner {
68 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); USING_FAST_MALLOC(TokenPreloadSca nner); 67 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); USING_FAST_MALLOC(TokenPreloadSca nner);
69 public: 68 public:
70 TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<CachedDocumentParame ters>); 69 TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<CachedDocumentParame ters>, const MediaValuesCached::MediaValuesCachedData&);
71 ~TokenPreloadScanner(); 70 ~TokenPreloadScanner();
72 71
73 void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& re quests); 72 void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& re quests);
74 void scan(const CompactHTMLToken&, const SegmentedString&, PreloadRequestStr eam& requests); 73 void scan(const CompactHTMLToken&, const SegmentedString&, PreloadRequestStr eam& requests);
75 74
76 void setPredictedBaseElementURL(const KURL& url) { m_predictedBaseElementURL = url; } 75 void setPredictedBaseElementURL(const KURL& url) { m_predictedBaseElementURL = url; }
77 76
78 // A TokenPreloadScannerCheckpoint is valid until the next call to rewindTo, 77 // A TokenPreloadScannerCheckpoint is valid until the next call to rewindTo,
79 // at which point all outstanding checkpoints are invalidated. 78 // at which point all outstanding checkpoints are invalidated.
80 TokenPreloadScannerCheckpoint createCheckpoint(); 79 TokenPreloadScannerCheckpoint createCheckpoint();
81 void rewindTo(TokenPreloadScannerCheckpoint); 80 void rewindTo(TokenPreloadScannerCheckpoint);
82 81
83 bool isSafeToSendToAnotherThread()
84 {
85 return m_documentURL.isSafeToSendToAnotherThread()
86 && m_predictedBaseElementURL.isSafeToSendToAnotherThread();
87 }
88
89 private: 82 private:
90 class StartTagScanner; 83 class StartTagScanner;
91 84
92 template <typename Token> 85 template <typename Token>
93 inline void scanCommon(const Token&, const SegmentedString&, PreloadRequestS tream& requests); 86 inline void scanCommon(const Token&, const SegmentedString&, PreloadRequestS tream& requests);
94 87
95 template<typename Token> 88 template<typename Token>
96 void updatePredictedBaseURL(const Token&); 89 void updatePredictedBaseURL(const Token&);
97 90
98 struct Checkpoint { 91 struct Checkpoint {
(...skipping 29 matching lines...) Expand all
128 CSSPreloadScanner m_cssScanner; 121 CSSPreloadScanner m_cssScanner;
129 const KURL m_documentURL; 122 const KURL m_documentURL;
130 KURL m_predictedBaseElementURL; 123 KURL m_predictedBaseElementURL;
131 bool m_inStyle; 124 bool m_inStyle;
132 bool m_inPicture; 125 bool m_inPicture;
133 bool m_isAppCacheEnabled; 126 bool m_isAppCacheEnabled;
134 bool m_isCSPEnabled; 127 bool m_isCSPEnabled;
135 PictureData m_pictureData; 128 PictureData m_pictureData;
136 size_t m_templateCount; 129 size_t m_templateCount;
137 OwnPtr<CachedDocumentParameters> m_documentParameters; 130 OwnPtr<CachedDocumentParameters> m_documentParameters;
131 RefPtrWillBePersistent<MediaValuesCached> m_mediaValues;
138 ClientHintsPreferences m_clientHintsPreferences; 132 ClientHintsPreferences m_clientHintsPreferences;
139 133
140 Vector<Checkpoint> m_checkpoints; 134 Vector<Checkpoint> m_checkpoints;
141 }; 135 };
142 136
143 class CORE_EXPORT HTMLPreloadScanner { 137 class CORE_EXPORT HTMLPreloadScanner {
144 WTF_MAKE_NONCOPYABLE(HTMLPreloadScanner); USING_FAST_MALLOC(HTMLPreloadScann er); 138 WTF_MAKE_NONCOPYABLE(HTMLPreloadScanner); USING_FAST_MALLOC(HTMLPreloadScann er);
145 public: 139 public:
146 static PassOwnPtr<HTMLPreloadScanner> create(const HTMLParserOptions& option s, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParamet ers) 140 static PassOwnPtr<HTMLPreloadScanner> create(const HTMLParserOptions& option s, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParamet ers, const MediaValuesCached::MediaValuesCachedData& mediaValuesCachedData)
147 { 141 {
148 return adoptPtr(new HTMLPreloadScanner(options, documentURL, documentPar ameters)); 142 return adoptPtr(new HTMLPreloadScanner(options, documentURL, documentPar ameters, mediaValuesCachedData));
149 } 143 }
150 144
151 145
152 HTMLPreloadScanner(const HTMLParserOptions&, const KURL& documentURL, PassOw nPtr<CachedDocumentParameters>);
153 ~HTMLPreloadScanner(); 146 ~HTMLPreloadScanner();
154 147
155 void appendToEnd(const SegmentedString&); 148 void appendToEnd(const SegmentedString&);
156 void scan(ResourcePreloader*, const KURL& documentBaseElementURL); 149 void scan(ResourcePreloader*, const KURL& documentBaseElementURL);
157 150
158 private: 151 private:
152 HTMLPreloadScanner(const HTMLParserOptions&, const KURL& documentURL, PassOw nPtr<CachedDocumentParameters>, const MediaValuesCached::MediaValuesCachedData&) ;
153
159 TokenPreloadScanner m_scanner; 154 TokenPreloadScanner m_scanner;
160 SegmentedString m_source; 155 SegmentedString m_source;
161 HTMLToken m_token; 156 HTMLToken m_token;
162 OwnPtr<HTMLTokenizer> m_tokenizer; 157 OwnPtr<HTMLTokenizer> m_tokenizer;
163 }; 158 };
164 159
165 } // namespace blink 160 } // namespace blink
166 161
167 #endif 162 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698