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

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

Issue 1152043005: Add <link rel=preconnect> support to the HTMLPreloadScanner (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 15 matching lines...) Expand all
26 26
27 #ifndef HTMLPreloadScanner_h 27 #ifndef HTMLPreloadScanner_h
28 #define HTMLPreloadScanner_h 28 #define HTMLPreloadScanner_h
29 29
30 #include "core/CoreExport.h" 30 #include "core/CoreExport.h"
31 #include "core/css/MediaValues.h" 31 #include "core/css/MediaValues.h"
32 #include "core/dom/ViewportDescription.h" 32 #include "core/dom/ViewportDescription.h"
33 #include "core/html/parser/CSSPreloadScanner.h" 33 #include "core/html/parser/CSSPreloadScanner.h"
34 #include "core/html/parser/CompactHTMLToken.h" 34 #include "core/html/parser/CompactHTMLToken.h"
35 #include "core/html/parser/HTMLToken.h" 35 #include "core/html/parser/HTMLToken.h"
36 #include "core/loader/Preconnecter.h"
36 #include "platform/text/SegmentedString.h" 37 #include "platform/text/SegmentedString.h"
37 #include "wtf/RefCounted.h" 38 #include "wtf/RefCounted.h"
38 #include "wtf/Vector.h" 39 #include "wtf/Vector.h"
39 40
40 namespace blink { 41 namespace blink {
41 42
42 typedef size_t TokenPreloadScannerCheckpoint; 43 typedef size_t TokenPreloadScannerCheckpoint;
43 44
44 class HTMLParserOptions; 45 class HTMLParserOptions;
45 class HTMLTokenizer; 46 class HTMLTokenizer;
(...skipping 10 matching lines...) Expand all
56 bool viewportMetaZeroValuesQuirk; 57 bool viewportMetaZeroValuesQuirk;
57 bool viewportMetaEnabled; 58 bool viewportMetaEnabled;
58 59
59 private: 60 private:
60 CachedDocumentParameters(Document*, PassRefPtr<MediaValues>); 61 CachedDocumentParameters(Document*, PassRefPtr<MediaValues>);
61 }; 62 };
62 63
63 class TokenPreloadScanner { 64 class TokenPreloadScanner {
64 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); WTF_MAKE_FAST_ALLOCATED(TokenPrel oadScanner); 65 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); WTF_MAKE_FAST_ALLOCATED(TokenPrel oadScanner);
65 public: 66 public:
66 TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<CachedDocumentParame ters>); 67 TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<CachedDocumentParame ters>, PassOwnPtr<PreconnecterHost>);
67 ~TokenPreloadScanner(); 68 ~TokenPreloadScanner();
68 69
69 void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& re quests); 70 void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& re quests);
70 void scan(const CompactHTMLToken&, const SegmentedString&, PreloadRequestStr eam& requests); 71 void scan(const CompactHTMLToken&, const SegmentedString&, PreloadRequestStr eam& requests);
71 72
72 void setPredictedBaseElementURL(const KURL& url) { m_predictedBaseElementURL = url; } 73 void setPredictedBaseElementURL(const KURL& url) { m_predictedBaseElementURL = url; }
73 74
74 // A TokenPreloadScannerCheckpoint is valid until the next call to rewindTo, 75 // A TokenPreloadScannerCheckpoint is valid until the next call to rewindTo,
75 // at which point all outstanding checkpoints are invalidated. 76 // at which point all outstanding checkpoints are invalidated.
76 TokenPreloadScannerCheckpoint createCheckpoint(); 77 TokenPreloadScannerCheckpoint createCheckpoint();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 const KURL m_documentURL; 113 const KURL m_documentURL;
113 KURL m_predictedBaseElementURL; 114 KURL m_predictedBaseElementURL;
114 bool m_inStyle; 115 bool m_inStyle;
115 bool m_inPicture; 116 bool m_inPicture;
116 bool m_isAppCacheEnabled; 117 bool m_isAppCacheEnabled;
117 bool m_isCSPEnabled; 118 bool m_isCSPEnabled;
118 String m_pictureSourceURL; 119 String m_pictureSourceURL;
119 size_t m_templateCount; 120 size_t m_templateCount;
120 OwnPtr<CachedDocumentParameters> m_documentParameters; 121 OwnPtr<CachedDocumentParameters> m_documentParameters;
121 ClientHintsPreferences m_clientHintsPreferences; 122 ClientHintsPreferences m_clientHintsPreferences;
123 OwnPtr<PreconnecterHost> m_preconnecter;
122 124
123 Vector<Checkpoint> m_checkpoints; 125 Vector<Checkpoint> m_checkpoints;
124 }; 126 };
125 127
126 class CORE_EXPORT HTMLPreloadScanner { 128 class CORE_EXPORT HTMLPreloadScanner {
127 WTF_MAKE_NONCOPYABLE(HTMLPreloadScanner); WTF_MAKE_FAST_ALLOCATED(HTMLPreloa dScanner); 129 WTF_MAKE_NONCOPYABLE(HTMLPreloadScanner); WTF_MAKE_FAST_ALLOCATED(HTMLPreloa dScanner);
128 public: 130 public:
129 static PassOwnPtr<HTMLPreloadScanner> create(const HTMLParserOptions& option s, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParamet ers) 131 static PassOwnPtr<HTMLPreloadScanner> create(const HTMLParserOptions& option s, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParamet ers, PassOwnPtr<PreconnecterHost> preconnecter)
130 { 132 {
131 return adoptPtr(new HTMLPreloadScanner(options, documentURL, documentPar ameters)); 133 return adoptPtr(new HTMLPreloadScanner(options, documentURL, documentPar ameters, preconnecter));
132 } 134 }
133 135
134 136
135 HTMLPreloadScanner(const HTMLParserOptions&, const KURL& documentURL, PassOw nPtr<CachedDocumentParameters>); 137 HTMLPreloadScanner(const HTMLParserOptions&, const KURL& documentURL, PassOw nPtr<CachedDocumentParameters>, PassOwnPtr<PreconnecterHost>);
136 ~HTMLPreloadScanner(); 138 ~HTMLPreloadScanner();
137 139
138 void appendToEnd(const SegmentedString&); 140 void appendToEnd(const SegmentedString&);
139 void scan(ResourcePreloader*, const KURL& documentBaseElementURL); 141 void scan(ResourcePreloader*, const KURL& documentBaseElementURL);
140 142
141 private: 143 private:
142 TokenPreloadScanner m_scanner; 144 TokenPreloadScanner m_scanner;
143 SegmentedString m_source; 145 SegmentedString m_source;
144 HTMLToken m_token; 146 HTMLToken m_token;
145 OwnPtr<HTMLTokenizer> m_tokenizer; 147 OwnPtr<HTMLTokenizer> m_tokenizer;
146 }; 148 };
147 149
148 } 150 }
149 151
150 #endif 152 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698