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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 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 16 matching lines...) Expand all
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/MediaValuesCached.h" 31 #include "core/css/MediaValuesCached.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 "platform/text/SegmentedString.h" 36 #include "platform/text/SegmentedString.h"
37 #include "wtf/PtrUtil.h"
37 #include "wtf/Vector.h" 38 #include "wtf/Vector.h"
39 #include <memory>
38 40
39 namespace blink { 41 namespace blink {
40 42
41 typedef size_t TokenPreloadScannerCheckpoint; 43 typedef size_t TokenPreloadScannerCheckpoint;
42 44
43 class HTMLParserOptions; 45 class HTMLParserOptions;
44 class HTMLTokenizer; 46 class HTMLTokenizer;
45 class SegmentedString; 47 class SegmentedString;
46 48
47 struct ViewportDescriptionWrapper { 49 struct ViewportDescriptionWrapper {
48 ViewportDescription description; 50 ViewportDescription description;
49 bool set; 51 bool set;
50 ViewportDescriptionWrapper() 52 ViewportDescriptionWrapper()
51 : set(false) 53 : set(false)
52 { 54 {
53 } 55 }
54 }; 56 };
55 57
56 struct CORE_EXPORT CachedDocumentParameters { 58 struct CORE_EXPORT CachedDocumentParameters {
57 USING_FAST_MALLOC(CachedDocumentParameters); 59 USING_FAST_MALLOC(CachedDocumentParameters);
58 public: 60 public:
59 static PassOwnPtr<CachedDocumentParameters> create(Document* document) 61 static std::unique_ptr<CachedDocumentParameters> create(Document* document)
60 { 62 {
61 return adoptPtr(new CachedDocumentParameters(document)); 63 return wrapUnique(new CachedDocumentParameters(document));
62 } 64 }
63 65
64 bool doHtmlPreloadScanning; 66 bool doHtmlPreloadScanning;
65 bool doDocumentWritePreloadScanning; 67 bool doDocumentWritePreloadScanning;
66 Length defaultViewportMinWidth; 68 Length defaultViewportMinWidth;
67 bool viewportMetaZeroValuesQuirk; 69 bool viewportMetaZeroValuesQuirk;
68 bool viewportMetaEnabled; 70 bool viewportMetaEnabled;
69 ReferrerPolicy referrerPolicy; 71 ReferrerPolicy referrerPolicy;
70 72
71 private: 73 private:
72 explicit CachedDocumentParameters(Document*); 74 explicit CachedDocumentParameters(Document*);
73 }; 75 };
74 76
75 class TokenPreloadScanner { 77 class TokenPreloadScanner {
76 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); USING_FAST_MALLOC(TokenPreloadSca nner); 78 WTF_MAKE_NONCOPYABLE(TokenPreloadScanner); USING_FAST_MALLOC(TokenPreloadSca nner);
77 public: 79 public:
78 TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<CachedDocumentParame ters>, const MediaValuesCached::MediaValuesCachedData&); 80 TokenPreloadScanner(const KURL& documentURL, std::unique_ptr<CachedDocumentP arameters>, const MediaValuesCached::MediaValuesCachedData&);
79 ~TokenPreloadScanner(); 81 ~TokenPreloadScanner();
80 82
81 void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& re quests, ViewportDescriptionWrapper*); 83 void scan(const HTMLToken&, const SegmentedString&, PreloadRequestStream& re quests, ViewportDescriptionWrapper*);
82 void scan(const CompactHTMLToken&, const SegmentedString&, PreloadRequestStr eam& requests, ViewportDescriptionWrapper*, bool* likelyDocumentWriteScript); 84 void scan(const CompactHTMLToken&, const SegmentedString&, PreloadRequestStr eam& requests, ViewportDescriptionWrapper*, bool* likelyDocumentWriteScript);
83 85
84 void setPredictedBaseElementURL(const KURL& url) { m_predictedBaseElementURL = url; } 86 void setPredictedBaseElementURL(const KURL& url) { m_predictedBaseElementURL = url; }
85 87
86 // A TokenPreloadScannerCheckpoint is valid until the next call to rewindTo, 88 // A TokenPreloadScannerCheckpoint is valid until the next call to rewindTo,
87 // at which point all outstanding checkpoints are invalidated. 89 // at which point all outstanding checkpoints are invalidated.
88 TokenPreloadScannerCheckpoint createCheckpoint(); 90 TokenPreloadScannerCheckpoint createCheckpoint();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 CSSPreloadScanner m_cssScanner; 137 CSSPreloadScanner m_cssScanner;
136 const KURL m_documentURL; 138 const KURL m_documentURL;
137 KURL m_predictedBaseElementURL; 139 KURL m_predictedBaseElementURL;
138 bool m_inStyle; 140 bool m_inStyle;
139 bool m_inPicture; 141 bool m_inPicture;
140 bool m_inScript; 142 bool m_inScript;
141 bool m_isAppCacheEnabled; 143 bool m_isAppCacheEnabled;
142 bool m_isCSPEnabled; 144 bool m_isCSPEnabled;
143 PictureData m_pictureData; 145 PictureData m_pictureData;
144 size_t m_templateCount; 146 size_t m_templateCount;
145 OwnPtr<CachedDocumentParameters> m_documentParameters; 147 std::unique_ptr<CachedDocumentParameters> m_documentParameters;
146 Persistent<MediaValuesCached> m_mediaValues; 148 Persistent<MediaValuesCached> m_mediaValues;
147 ClientHintsPreferences m_clientHintsPreferences; 149 ClientHintsPreferences m_clientHintsPreferences;
148 150
149 bool m_didRewind = false; 151 bool m_didRewind = false;
150 152
151 Vector<Checkpoint> m_checkpoints; 153 Vector<Checkpoint> m_checkpoints;
152 }; 154 };
153 155
154 class CORE_EXPORT HTMLPreloadScanner { 156 class CORE_EXPORT HTMLPreloadScanner {
155 WTF_MAKE_NONCOPYABLE(HTMLPreloadScanner); USING_FAST_MALLOC(HTMLPreloadScann er); 157 WTF_MAKE_NONCOPYABLE(HTMLPreloadScanner); USING_FAST_MALLOC(HTMLPreloadScann er);
156 public: 158 public:
157 static PassOwnPtr<HTMLPreloadScanner> create(const HTMLParserOptions& option s, const KURL& documentURL, PassOwnPtr<CachedDocumentParameters> documentParamet ers, const MediaValuesCached::MediaValuesCachedData& mediaValuesCachedData) 159 static std::unique_ptr<HTMLPreloadScanner> create(const HTMLParserOptions& o ptions, const KURL& documentURL, std::unique_ptr<CachedDocumentParameters> docum entParameters, const MediaValuesCached::MediaValuesCachedData& mediaValuesCached Data)
158 { 160 {
159 return adoptPtr(new HTMLPreloadScanner(options, documentURL, std::move(d ocumentParameters), mediaValuesCachedData)); 161 return wrapUnique(new HTMLPreloadScanner(options, documentURL, std::move (documentParameters), mediaValuesCachedData));
160 } 162 }
161 163
162 164
163 ~HTMLPreloadScanner(); 165 ~HTMLPreloadScanner();
164 166
165 void appendToEnd(const SegmentedString&); 167 void appendToEnd(const SegmentedString&);
166 void scanAndPreload(ResourcePreloader*, const KURL& documentBaseElementURL, ViewportDescriptionWrapper*); 168 void scanAndPreload(ResourcePreloader*, const KURL& documentBaseElementURL, ViewportDescriptionWrapper*);
167 169
168 private: 170 private:
169 HTMLPreloadScanner(const HTMLParserOptions&, const KURL& documentURL, PassOw nPtr<CachedDocumentParameters>, const MediaValuesCached::MediaValuesCachedData&) ; 171 HTMLPreloadScanner(const HTMLParserOptions&, const KURL& documentURL, std::u nique_ptr<CachedDocumentParameters>, const MediaValuesCached::MediaValuesCachedD ata&);
170 172
171 TokenPreloadScanner m_scanner; 173 TokenPreloadScanner m_scanner;
172 SegmentedString m_source; 174 SegmentedString m_source;
173 HTMLToken m_token; 175 HTMLToken m_token;
174 OwnPtr<HTMLTokenizer> m_tokenizer; 176 std::unique_ptr<HTMLTokenizer> m_tokenizer;
175 }; 177 };
176 178
177 } // namespace blink 179 } // namespace blink
178 180
179 #endif 181 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698