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

Side by Side Diff: third_party/WebKit/Source/core/loader/DocumentLoader.h

Issue 2710983003: Move HistoryItem handling to DocumentLoader (Closed)
Patch Set: Address kinuko's comments Created 3 years, 8 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) 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
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
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();
146 void setSentDidFinishLoad() { m_state = SentDidFinishLoad; } 153 void setSentDidFinishLoad() { m_state = SentDidFinishLoad; }
147 bool sentDidFinishLoad() const { return m_state == SentDidFinishLoad; } 154 bool sentDidFinishLoad() const { return m_state == SentDidFinishLoad; }
148 155
149 FrameLoadType loadType() const { return m_loadType; } 156 FrameLoadType loadType() const { return m_loadType; }
150 void setLoadType(FrameLoadType loadType) { m_loadType = loadType; } 157 void setLoadType(FrameLoadType loadType) { m_loadType = loadType; }
151 158
152 NavigationType getNavigationType() const { return m_navigationType; } 159 NavigationType getNavigationType() const { return m_navigationType; }
153 void setNavigationType(NavigationType navigationType) { 160 void setNavigationType(NavigationType navigationType) {
154 m_navigationType = navigationType; 161 m_navigationType = navigationType;
155 } 162 }
156 163
164 void setItemForHistoryNavigation(HistoryItem* item) { m_historyItem = item; }
165 HistoryItem* historyItem() const { return m_historyItem; }
166
157 void startLoadingMainResource(); 167 void startLoadingMainResource();
158 168
159 DocumentLoadTiming& timing() { return m_documentLoadTiming; } 169 DocumentLoadTiming& timing() { return m_documentLoadTiming; }
160 const DocumentLoadTiming& timing() const { return m_documentLoadTiming; } 170 const DocumentLoadTiming& timing() const { return m_documentLoadTiming; }
161 171
162 ApplicationCacheHost* applicationCacheHost() const { 172 ApplicationCacheHost* applicationCacheHost() const {
163 return m_applicationCacheHost.get(); 173 return m_applicationCacheHost.get();
164 } 174 }
165 175
166 void clearRedirectChain(); 176 void clearRedirectChain();
(...skipping 27 matching lines...) Expand all
194 // May return null before the first HTML tag is inserted by the 204 // May return null before the first HTML tag is inserted by the
195 // parser (before didCreateDataSource is called), after the document 205 // parser (before didCreateDataSource is called), after the document
196 // is detached from frame, or in tests. 206 // is detached from frame, or in tests.
197 WebServiceWorkerNetworkProvider* getServiceWorkerNetworkProvider() { 207 WebServiceWorkerNetworkProvider* getServiceWorkerNetworkProvider() {
198 return m_serviceWorkerNetworkProvider.get(); 208 return m_serviceWorkerNetworkProvider.get();
199 } 209 }
200 210
201 std::unique_ptr<SourceLocation> copySourceLocation() const; 211 std::unique_ptr<SourceLocation> copySourceLocation() const;
202 void setSourceLocation(std::unique_ptr<SourceLocation>); 212 void setSourceLocation(std::unique_ptr<SourceLocation>);
203 213
214 void loadFailed(const ResourceError&);
215
204 DECLARE_VIRTUAL_TRACE(); 216 DECLARE_VIRTUAL_TRACE();
205 217
206 protected: 218 protected:
207 DocumentLoader(LocalFrame*, 219 DocumentLoader(LocalFrame*,
208 const ResourceRequest&, 220 const ResourceRequest&,
209 const SubstituteData&, 221 const SubstituteData&,
210 ClientRedirectPolicy); 222 ClientRedirectPolicy);
211 223
212 Vector<KURL> m_redirectChain; 224 Vector<KURL> m_redirectChain;
213 225
(...skipping 14 matching lines...) Expand all
228 240
229 void ensureWriter(const AtomicString& mimeType, 241 void ensureWriter(const AtomicString& mimeType,
230 const KURL& overridingURL = KURL()); 242 const KURL& overridingURL = KURL());
231 void endWriting(); 243 void endWriting();
232 244
233 // Use these method only where it's guaranteed that |m_frame| hasn't been 245 // Use these method only where it's guaranteed that |m_frame| hasn't been
234 // cleared. 246 // cleared.
235 FrameLoader& frameLoader() const; 247 FrameLoader& frameLoader() const;
236 LocalFrameClient& localFrameClient() const; 248 LocalFrameClient& localFrameClient() const;
237 249
238 void commitIfReady();
239 void commitData(const char* bytes, size_t length); 250 void commitData(const char* bytes, size_t length);
240 void clearMainResourceHandle(); 251 void clearMainResourceHandle();
241 252
242 bool maybeCreateArchive(); 253 bool maybeCreateArchive();
243 254
244 void finishedLoading(double finishTime); 255 void finishedLoading(double finishTime);
245 void cancelLoadAfterCSPDenied(const ResourceResponse&); 256 void cancelLoadAfterCSPDenied(const ResourceResponse&);
246 257
258 enum class HistoryNavigationType {
259 kDifferentDocument,
260 kFragment,
261 kHistoryApi
262 };
263 void setHistoryItemStateForCommit(HistoryItem* oldItem,
264 FrameLoadType,
265 HistoryNavigationType);
266
247 // RawResourceClient implementation 267 // RawResourceClient implementation
248 bool redirectReceived(Resource*, 268 bool redirectReceived(Resource*,
249 const ResourceRequest&, 269 const ResourceRequest&,
250 const ResourceResponse&) final; 270 const ResourceResponse&) final;
251 void responseReceived(Resource*, 271 void responseReceived(Resource*,
252 const ResourceResponse&, 272 const ResourceResponse&,
253 std::unique_ptr<WebDataConsumerHandle>) final; 273 std::unique_ptr<WebDataConsumerHandle>) final;
254 void dataReceived(Resource*, const char* data, size_t length) final; 274 void dataReceived(Resource*, const char* data, size_t length) final;
255 275
256 // ResourceClient implementation 276 // ResourceClient implementation
257 void notifyFinished(Resource*) final; 277 void notifyFinished(Resource*) final;
258 String debugName() const override { return "DocumentLoader"; } 278 String debugName() const override { return "DocumentLoader"; }
259 279
260 void processData(const char* data, size_t length); 280 void processData(const char* data, size_t length);
261 281
262 bool maybeLoadEmpty(); 282 bool maybeLoadEmpty();
263 283
264 bool isRedirectAfterPost(const ResourceRequest&, const ResourceResponse&); 284 bool isRedirectAfterPost(const ResourceRequest&, const ResourceResponse&);
265 285
266 bool shouldContinueForResponse() const; 286 bool shouldContinueForResponse() const;
267 287
268 Member<LocalFrame> m_frame; 288 Member<LocalFrame> m_frame;
269 Member<ResourceFetcher> m_fetcher; 289 Member<ResourceFetcher> m_fetcher;
270 290
271 Member<RawResource> m_mainResource; 291 Member<RawResource> m_mainResource;
292 Member<HistoryItem> m_historyItem;
272 293
273 Member<DocumentWriter> m_writer; 294 Member<DocumentWriter> m_writer;
274 295
275 Member<SubresourceFilter> m_subresourceFilter; 296 Member<SubresourceFilter> m_subresourceFilter;
276 297
277 // A reference to actual request used to create the data source. 298 // 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 299 // The only part of this request that should change is the url, and
279 // that only in the case of a same-document navigation. 300 // that only in the case of a same-document navigation.
280 ResourceRequest m_originalRequest; 301 ResourceRequest m_originalRequest;
281 302
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // Used to protect against reentrancy into dataReceived(). 348 // Used to protect against reentrancy into dataReceived().
328 bool m_inDataReceived; 349 bool m_inDataReceived;
329 RefPtr<SharedBuffer> m_dataBuffer; 350 RefPtr<SharedBuffer> m_dataBuffer;
330 }; 351 };
331 352
332 DECLARE_WEAK_IDENTIFIER_MAP(DocumentLoader); 353 DECLARE_WEAK_IDENTIFIER_MAP(DocumentLoader);
333 354
334 } // namespace blink 355 } // namespace blink
335 356
336 #endif // DocumentLoader_h 357 #endif // DocumentLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698