OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 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 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 #include "wtf/RefPtr.h" | 55 #include "wtf/RefPtr.h" |
56 | 56 |
57 #include <memory> | 57 #include <memory> |
58 | 58 |
59 namespace blink { | 59 namespace blink { |
60 | 60 |
61 class ApplicationCacheHost; | 61 class ApplicationCacheHost; |
62 class SubresourceFilter; | 62 class SubresourceFilter; |
63 class ResourceFetcher; | 63 class ResourceFetcher; |
64 class DocumentInit; | 64 class DocumentInit; |
65 class HistoryItem; | |
65 class LocalFrame; | 66 class LocalFrame; |
66 class LocalFrameClient; | 67 class LocalFrameClient; |
67 class FrameLoader; | 68 class FrameLoader; |
68 class ResourceTimingInfo; | 69 class ResourceTimingInfo; |
70 class SerializedScriptValue; | |
69 class WebServiceWorkerNetworkProvider; | 71 class WebServiceWorkerNetworkProvider; |
70 struct ViewportDescriptionWrapper; | 72 struct ViewportDescriptionWrapper; |
71 | 73 |
72 class CORE_EXPORT DocumentLoader | 74 class CORE_EXPORT DocumentLoader |
73 : public GarbageCollectedFinalized<DocumentLoader>, | 75 : public GarbageCollectedFinalized<DocumentLoader>, |
74 private RawResourceClient { | 76 private RawResourceClient { |
75 USING_GARBAGE_COLLECTED_MIXIN(DocumentLoader); | 77 USING_GARBAGE_COLLECTED_MIXIN(DocumentLoader); |
76 | 78 |
77 public: | 79 public: |
78 static DocumentLoader* create(LocalFrame* frame, | 80 static DocumentLoader* create(LocalFrame* frame, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 | 115 |
114 const KURL& url() const; | 116 const KURL& url() const; |
115 const KURL& unreachableURL() const; | 117 const KURL& unreachableURL() const; |
116 const KURL& urlForHistory() const; | 118 const KURL& urlForHistory() const; |
117 | 119 |
118 const AtomicString& responseMIMEType() const; | 120 const AtomicString& responseMIMEType() const; |
119 | 121 |
120 void didChangePerformanceTiming(); | 122 void didChangePerformanceTiming(); |
121 void didObserveLoadingBehavior(WebLoadingBehaviorFlag); | 123 void didObserveLoadingBehavior(WebLoadingBehaviorFlag); |
122 void updateForSameDocumentNavigation(const KURL&, | 124 void updateForSameDocumentNavigation(const KURL&, |
123 SameDocumentNavigationSource); | 125 SameDocumentNavigationSource, |
126 PassRefPtr<SerializedScriptValue>, | |
127 HistoryScrollRestorationType, | |
128 FrameLoadType, | |
129 Document*); | |
124 const ResourceResponse& response() const { return m_response; } | 130 const ResourceResponse& response() const { return m_response; } |
125 bool isClientRedirect() const { return m_isClientRedirect; } | 131 bool isClientRedirect() const { return m_isClientRedirect; } |
126 void setIsClientRedirect(bool isClientRedirect) { | 132 void setIsClientRedirect(bool isClientRedirect) { |
127 m_isClientRedirect = isClientRedirect; | 133 m_isClientRedirect = isClientRedirect; |
128 } | 134 } |
129 bool replacesCurrentHistoryItem() const { | 135 bool replacesCurrentHistoryItem() const { |
130 return m_replacesCurrentHistoryItem; | 136 return m_replacesCurrentHistoryItem; |
131 } | 137 } |
132 void setReplacesCurrentHistoryItem(bool replacesCurrentHistoryItem) { | 138 void setReplacesCurrentHistoryItem(bool replacesCurrentHistoryItem) { |
133 m_replacesCurrentHistoryItem = replacesCurrentHistoryItem; | 139 m_replacesCurrentHistoryItem = replacesCurrentHistoryItem; |
134 } | 140 } |
135 | 141 |
136 bool isCommittedButEmpty() const { | 142 bool isCommittedButEmpty() const { |
137 return m_state >= Committed && !m_dataReceived; | 143 return m_state >= Committed && !m_dataReceived; |
138 } | 144 } |
139 | 145 |
140 // Without PlzNavigate, this is only false for a narrow window during | 146 // Without PlzNavigate, this is only false for a narrow window during |
141 // navigation start. For PlzNavigate, a navigation sent to the browser will | 147 // navigation start. For PlzNavigate, a navigation sent to the browser will |
142 // leave a dummy DocumentLoader in the NotStarted state until the navigation | 148 // leave a dummy DocumentLoader in the NotStarted state until the navigation |
143 // is actually handled in the renderer. | 149 // is actually handled in the renderer. |
144 bool didStart() const { return m_state != NotStarted; } | 150 bool didStart() const { return m_state != NotStarted; } |
145 | 151 |
152 void markAsCommitted() { | |
kinuko
2017/03/30 05:05:00
Is the DCHECK the reason you wanted to use differe
Nate Chapin
2017/03/30 20:13:56
The DCHECK is part of the reason. The other is tha
| |
153 DCHECK_LT(m_state, Committed); | |
154 m_state = Committed; | |
155 } | |
146 void setSentDidFinishLoad() { m_state = SentDidFinishLoad; } | 156 void setSentDidFinishLoad() { m_state = SentDidFinishLoad; } |
147 bool sentDidFinishLoad() const { return m_state == SentDidFinishLoad; } | 157 bool sentDidFinishLoad() const { return m_state == SentDidFinishLoad; } |
148 | 158 |
149 FrameLoadType loadType() const { return m_loadType; } | 159 FrameLoadType loadType() const { return m_loadType; } |
150 void setLoadType(FrameLoadType loadType) { m_loadType = loadType; } | 160 void setLoadType(FrameLoadType loadType) { m_loadType = loadType; } |
151 | 161 |
152 NavigationType getNavigationType() const { return m_navigationType; } | 162 NavigationType getNavigationType() const { return m_navigationType; } |
153 void setNavigationType(NavigationType navigationType) { | 163 void setNavigationType(NavigationType navigationType) { |
154 m_navigationType = navigationType; | 164 m_navigationType = navigationType; |
155 } | 165 } |
156 | 166 |
167 void setItemForHistoryNavigation(HistoryItem* item) { m_historyItem = item; } | |
168 HistoryItem* historyItem() const { return m_historyItem; } | |
169 | |
157 void startLoadingMainResource(); | 170 void startLoadingMainResource(); |
158 | 171 |
159 DocumentLoadTiming& timing() { return m_documentLoadTiming; } | 172 DocumentLoadTiming& timing() { return m_documentLoadTiming; } |
160 const DocumentLoadTiming& timing() const { return m_documentLoadTiming; } | 173 const DocumentLoadTiming& timing() const { return m_documentLoadTiming; } |
161 | 174 |
162 ApplicationCacheHost* applicationCacheHost() const { | 175 ApplicationCacheHost* applicationCacheHost() const { |
163 return m_applicationCacheHost.get(); | 176 return m_applicationCacheHost.get(); |
164 } | 177 } |
165 | 178 |
166 void clearRedirectChain(); | 179 void clearRedirectChain(); |
(...skipping 27 matching lines...) Expand all Loading... | |
194 // May return null before the first HTML tag is inserted by the | 207 // May return null before the first HTML tag is inserted by the |
195 // parser (before didCreateDataSource is called), after the document | 208 // parser (before didCreateDataSource is called), after the document |
196 // is detached from frame, or in tests. | 209 // is detached from frame, or in tests. |
197 WebServiceWorkerNetworkProvider* getServiceWorkerNetworkProvider() { | 210 WebServiceWorkerNetworkProvider* getServiceWorkerNetworkProvider() { |
198 return m_serviceWorkerNetworkProvider.get(); | 211 return m_serviceWorkerNetworkProvider.get(); |
199 } | 212 } |
200 | 213 |
201 std::unique_ptr<SourceLocation> copySourceLocation() const; | 214 std::unique_ptr<SourceLocation> copySourceLocation() const; |
202 void setSourceLocation(std::unique_ptr<SourceLocation>); | 215 void setSourceLocation(std::unique_ptr<SourceLocation>); |
203 | 216 |
217 void loadFailed(const ResourceError&); | |
218 | |
204 DECLARE_VIRTUAL_TRACE(); | 219 DECLARE_VIRTUAL_TRACE(); |
205 | 220 |
206 protected: | 221 protected: |
207 DocumentLoader(LocalFrame*, | 222 DocumentLoader(LocalFrame*, |
208 const ResourceRequest&, | 223 const ResourceRequest&, |
209 const SubstituteData&, | 224 const SubstituteData&, |
210 ClientRedirectPolicy); | 225 ClientRedirectPolicy); |
211 | 226 |
212 Vector<KURL> m_redirectChain; | 227 Vector<KURL> m_redirectChain; |
213 | 228 |
(...skipping 14 matching lines...) Expand all Loading... | |
228 | 243 |
229 void ensureWriter(const AtomicString& mimeType, | 244 void ensureWriter(const AtomicString& mimeType, |
230 const KURL& overridingURL = KURL()); | 245 const KURL& overridingURL = KURL()); |
231 void endWriting(); | 246 void endWriting(); |
232 | 247 |
233 // Use these method only where it's guaranteed that |m_frame| hasn't been | 248 // Use these method only where it's guaranteed that |m_frame| hasn't been |
234 // cleared. | 249 // cleared. |
235 FrameLoader& frameLoader() const; | 250 FrameLoader& frameLoader() const; |
236 LocalFrameClient& localFrameClient() const; | 251 LocalFrameClient& localFrameClient() const; |
237 | 252 |
238 void commitIfReady(); | |
239 void commitData(const char* bytes, size_t length); | 253 void commitData(const char* bytes, size_t length); |
240 void clearMainResourceHandle(); | 254 void clearMainResourceHandle(); |
241 | 255 |
242 bool maybeCreateArchive(); | 256 bool maybeCreateArchive(); |
243 | 257 |
244 void finishedLoading(double finishTime); | 258 void finishedLoading(double finishTime); |
245 void cancelLoadAfterCSPDenied(const ResourceResponse&); | 259 void cancelLoadAfterCSPDenied(const ResourceResponse&); |
246 | 260 |
261 enum class HistoryNavigationType { DifferentDocument, Fragment, HistoryApi }; | |
kinuko
2017/03/30 05:05:00
nit: prefixing 'k' for new enums? (other enums in
Nate Chapin
2017/03/30 20:13:56
Aww...that makes it have to line wrap :(
Done.
| |
262 void setHistoryItemStateForCommit(HistoryItem* oldItem, | |
263 FrameLoadType, | |
264 HistoryNavigationType); | |
265 | |
247 // RawResourceClient implementation | 266 // RawResourceClient implementation |
248 bool redirectReceived(Resource*, | 267 bool redirectReceived(Resource*, |
249 const ResourceRequest&, | 268 const ResourceRequest&, |
250 const ResourceResponse&) final; | 269 const ResourceResponse&) final; |
251 void responseReceived(Resource*, | 270 void responseReceived(Resource*, |
252 const ResourceResponse&, | 271 const ResourceResponse&, |
253 std::unique_ptr<WebDataConsumerHandle>) final; | 272 std::unique_ptr<WebDataConsumerHandle>) final; |
254 void dataReceived(Resource*, const char* data, size_t length) final; | 273 void dataReceived(Resource*, const char* data, size_t length) final; |
255 | 274 |
256 // ResourceClient implementation | 275 // ResourceClient implementation |
257 void notifyFinished(Resource*) final; | 276 void notifyFinished(Resource*) final; |
258 String debugName() const override { return "DocumentLoader"; } | 277 String debugName() const override { return "DocumentLoader"; } |
259 | 278 |
260 void processData(const char* data, size_t length); | 279 void processData(const char* data, size_t length); |
261 | 280 |
262 bool maybeLoadEmpty(); | 281 bool maybeLoadEmpty(); |
263 | 282 |
264 bool isRedirectAfterPost(const ResourceRequest&, const ResourceResponse&); | 283 bool isRedirectAfterPost(const ResourceRequest&, const ResourceResponse&); |
265 | 284 |
266 bool shouldContinueForResponse() const; | 285 bool shouldContinueForResponse() const; |
267 | 286 |
268 Member<LocalFrame> m_frame; | 287 Member<LocalFrame> m_frame; |
269 Member<ResourceFetcher> m_fetcher; | 288 Member<ResourceFetcher> m_fetcher; |
270 | 289 |
271 Member<RawResource> m_mainResource; | 290 Member<RawResource> m_mainResource; |
291 Member<HistoryItem> m_historyItem; | |
272 | 292 |
273 Member<DocumentWriter> m_writer; | 293 Member<DocumentWriter> m_writer; |
274 | 294 |
275 Member<SubresourceFilter> m_subresourceFilter; | 295 Member<SubresourceFilter> m_subresourceFilter; |
276 | 296 |
277 // A reference to actual request used to create the data source. | 297 // A reference to actual request used to create the data source. |
278 // The only part of this request that should change is the url, and | 298 // The only part of this request that should change is the url, and |
279 // that only in the case of a same-document navigation. | 299 // that only in the case of a same-document navigation. |
280 ResourceRequest m_originalRequest; | 300 ResourceRequest m_originalRequest; |
281 | 301 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 // Used to protect against reentrancy into dataReceived(). | 347 // Used to protect against reentrancy into dataReceived(). |
328 bool m_inDataReceived; | 348 bool m_inDataReceived; |
329 RefPtr<SharedBuffer> m_dataBuffer; | 349 RefPtr<SharedBuffer> m_dataBuffer; |
330 }; | 350 }; |
331 | 351 |
332 DECLARE_WEAK_IDENTIFIER_MAP(DocumentLoader); | 352 DECLARE_WEAK_IDENTIFIER_MAP(DocumentLoader); |
333 | 353 |
334 } // namespace blink | 354 } // namespace blink |
335 | 355 |
336 #endif // DocumentLoader_h | 356 #endif // DocumentLoader_h |
OLD | NEW |