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

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

Issue 17640007: Refactoring: Simplify DocumentWriter by reorganizing its lifetime. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Re-landing after fixing ASAN failure on set-parent-src-synchronously.xhtml. Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/inspector/InspectorOverlay.cpp ('k') | Source/core/loader/DocumentLoader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 Frame* frame() const { return m_frame; } 78 Frame* frame() const { return m_frame; }
79 79
80 void detachFromFrame(); 80 void detachFromFrame();
81 81
82 FrameLoader* frameLoader() const; 82 FrameLoader* frameLoader() const;
83 83
84 unsigned long mainResourceIdentifier() const; 84 unsigned long mainResourceIdentifier() const;
85 85
86 void replaceDocument(const String& source, Document*); 86 void replaceDocument(const String& source, Document*);
87 DocumentWriter* beginWriting(const String& mimeType, const String& encod ing, const KURL& = KURL()); 87 DocumentWriter* beginWriting(const String& mimeType, const String& encod ing, const KURL& = KURL());
88 void endWriting(DocumentWriter*);
89
88 String mimeType() const; 90 String mimeType() const;
89 91
90 const ResourceRequest& originalRequest() const; 92 const ResourceRequest& originalRequest() const;
91 const ResourceRequest& originalRequestCopy() const; 93 const ResourceRequest& originalRequestCopy() const;
92 94
93 const ResourceRequest& request() const; 95 const ResourceRequest& request() const;
94 ResourceRequest& request(); 96 ResourceRequest& request();
95 97
96 CachedResourceLoader* cachedResourceLoader() const { return m_cachedReso urceLoader.get(); } 98 CachedResourceLoader* cachedResourceLoader() const { return m_cachedReso urceLoader.get(); }
97 99
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 157
156 virtual void reportMemoryUsage(MemoryObjectInfo*) const; 158 virtual void reportMemoryUsage(MemoryObjectInfo*) const;
157 void checkLoadComplete(); 159 void checkLoadComplete();
158 160
159 protected: 161 protected:
160 DocumentLoader(const ResourceRequest&, const SubstituteData&); 162 DocumentLoader(const ResourceRequest&, const SubstituteData&);
161 163
162 bool m_deferMainResourceDataLoad; 164 bool m_deferMainResourceDataLoad;
163 165
164 private: 166 private:
167 static PassRefPtr<DocumentWriter> createWriterFor(Frame*, const Document * ownerDocument, const KURL&, const String& mimeType, const String& encoding, bo ol userChosen, bool dispatch);
168
169 void ensureWriter();
170 void ensureWriter(const String& mimeType, const KURL& overridingURL = KU RL());
165 171
166 // The URL of the document resulting from this DocumentLoader. 172 // The URL of the document resulting from this DocumentLoader.
167 KURL documentURL() const; 173 KURL documentURL() const;
168 Document* document() const; 174 Document* document() const;
169 175
170 void setRequest(const ResourceRequest&); 176 void setRequest(const ResourceRequest&);
171 177
172 void commitIfReady(); 178 void commitIfReady();
173 void commitData(const char* bytes, size_t length); 179 void commitData(const char* bytes, size_t length);
174 void setMainDocumentError(const ResourceError&); 180 void setMainDocumentError(const ResourceError&);
175 void clearMainResourceLoader(); 181 void clearMainResourceLoader();
176 ResourceLoader* mainResourceLoader() const; 182 ResourceLoader* mainResourceLoader() const;
177 void clearMainResourceHandle(); 183 void clearMainResourceHandle();
178 PassRefPtr<SharedBuffer> mainResourceData() const; 184 PassRefPtr<SharedBuffer> mainResourceData() const;
179 185
180 bool maybeCreateArchive(); 186 void createArchive();
181 void clearArchiveResources(); 187 void clearArchiveResources();
182 188
183 void prepareSubframeArchiveLoadIfNeeded(); 189 void prepareSubframeArchiveLoadIfNeeded();
184 void addAllArchiveResources(MHTMLArchive*); 190 void addAllArchiveResources(MHTMLArchive*);
185 191
186 void willSendRequest(ResourceRequest&, const ResourceResponse&); 192 void willSendRequest(ResourceRequest&, const ResourceResponse&);
187 void finishedLoading(double finishTime); 193 void finishedLoading(double finishTime);
188 void mainReceivedError(const ResourceError&); 194 void mainReceivedError(const ResourceError&);
189 virtual void redirectReceived(CachedResource*, ResourceRequest&, const R esourceResponse&) OVERRIDE; 195 virtual void redirectReceived(CachedResource*, ResourceRequest&, const R esourceResponse&) OVERRIDE;
190 virtual void responseReceived(CachedResource*, const ResourceResponse&) OVERRIDE; 196 virtual void responseReceived(CachedResource*, const ResourceResponse&) OVERRIDE;
(...skipping 14 matching lines...) Expand all
205 void handleSubstituteDataLoadNow(DocumentLoaderTimer*); 211 void handleSubstituteDataLoadNow(DocumentLoaderTimer*);
206 void startDataLoadTimer(); 212 void startDataLoadTimer();
207 213
208 Frame* m_frame; 214 Frame* m_frame;
209 RefPtr<CachedResourceLoader> m_cachedResourceLoader; 215 RefPtr<CachedResourceLoader> m_cachedResourceLoader;
210 216
211 CachedResourceHandle<CachedRawResource> m_mainResource; 217 CachedResourceHandle<CachedRawResource> m_mainResource;
212 ResourceLoaderSet m_resourceLoaders; 218 ResourceLoaderSet m_resourceLoaders;
213 ResourceLoaderSet m_multipartResourceLoaders; 219 ResourceLoaderSet m_multipartResourceLoaders;
214 220
215 mutable DocumentWriter m_writer; 221 RefPtr<DocumentWriter> m_writer;
216 222
217 // A reference to actual request used to create the data source. 223 // A reference to actual request used to create the data source.
218 // This should only be used by the resourceLoadDelegate's 224 // This should only be used by the resourceLoadDelegate's
219 // identifierForInitialRequest:fromDatasource: method. It is 225 // identifierForInitialRequest:fromDatasource: method. It is
220 // not guaranteed to remain unchanged, as requests are mutable. 226 // not guaranteed to remain unchanged, as requests are mutable.
221 ResourceRequest m_originalRequest; 227 ResourceRequest m_originalRequest;
222 228
223 SubstituteData m_substituteData; 229 SubstituteData m_substituteData;
224 230
225 // A copy of the original request used to create the data source. 231 // A copy of the original request used to create the data source.
226 // We have to copy the request because requests are mutable. 232 // We have to copy the request because requests are mutable.
227 ResourceRequest m_originalRequestCopy; 233 ResourceRequest m_originalRequestCopy;
228 234
229 // The 'working' request. It may be mutated 235 // The 'working' request. It may be mutated
230 // several times from the original request to include additional 236 // several times from the original request to include additional
231 // headers, cookie information, canonicalization and redirects. 237 // headers, cookie information, canonicalization and redirects.
232 ResourceRequest m_request; 238 ResourceRequest m_request;
233 239
234 ResourceResponse m_response; 240 ResourceResponse m_response;
235 241
236 ResourceError m_mainDocumentError; 242 ResourceError m_mainDocumentError;
237 243
238 bool m_committed; 244 bool m_committed;
239 bool m_isStopping; 245 bool m_isStopping;
240 bool m_gotFirstByte;
241 bool m_isClientRedirect; 246 bool m_isClientRedirect;
242 247
243 // FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloa dHandled are roughly the same 248 // FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloa dHandled are roughly the same
244 // and should be merged. 249 // and should be merged.
245 bool m_wasOnloadHandled; 250 bool m_wasOnloadHandled;
246 251
247 StringWithDirection m_pageTitle; 252 StringWithDirection m_pageTitle;
248 253
249 String m_overrideEncoding; 254 String m_overrideEncoding;
250 255
(...skipping 11 matching lines...) Expand all
262 unsigned long m_identifierForLoadWithoutResourceLoader; 267 unsigned long m_identifierForLoadWithoutResourceLoader;
263 268
264 DocumentLoaderTimer m_dataLoadTimer; 269 DocumentLoaderTimer m_dataLoadTimer;
265 270
266 friend class ApplicationCacheHost; // for substitute resource delivery 271 friend class ApplicationCacheHost; // for substitute resource delivery
267 OwnPtr<ApplicationCacheHost> m_applicationCacheHost; 272 OwnPtr<ApplicationCacheHost> m_applicationCacheHost;
268 }; 273 };
269 } 274 }
270 275
271 #endif // DocumentLoader_h 276 #endif // DocumentLoader_h
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorOverlay.cpp ('k') | Source/core/loader/DocumentLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698