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

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

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

Powered by Google App Engine
This is Rietveld 408576698