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

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: Fixed a build breakage Created 7 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 | Annotate | Revision Log
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 Frame* frame() const { return m_frame; } 79 Frame* frame() const { return m_frame; }
80 80
81 void detachFromFrame(); 81 void detachFromFrame();
82 82
83 FrameLoader* frameLoader() const; 83 FrameLoader* frameLoader() const;
84 84
85 unsigned long mainResourceIdentifier() const; 85 unsigned long mainResourceIdentifier() const;
86 86
87 void replaceDocument(const String& source, Document*); 87 void replaceDocument(const String& source, Document*);
88 DocumentWriter* beginWriting(const String& mimeType, const String& encod ing, const KURL& = KURL()); 88 DocumentWriter* beginWriting(const String& mimeType, const String& encod ing, const KURL& = KURL());
89 void endWriting(DocumentWriter*);
90
89 String mimeType() const; 91 String mimeType() const;
90 92
91 const ResourceRequest& originalRequest() const; 93 const ResourceRequest& originalRequest() const;
92 const ResourceRequest& originalRequestCopy() const; 94 const ResourceRequest& originalRequestCopy() const;
93 95
94 const ResourceRequest& request() const; 96 const ResourceRequest& request() const;
95 ResourceRequest& request(); 97 ResourceRequest& request();
96 98
97 CachedResourceLoader* cachedResourceLoader() const { return m_cachedReso urceLoader.get(); } 99 CachedResourceLoader* cachedResourceLoader() const { return m_cachedReso urceLoader.get(); }
98 100
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 162
161 virtual void reportMemoryUsage(MemoryObjectInfo*) const; 163 virtual void reportMemoryUsage(MemoryObjectInfo*) const;
162 void checkLoadComplete(); 164 void checkLoadComplete();
163 165
164 protected: 166 protected:
165 DocumentLoader(const ResourceRequest&, const SubstituteData&); 167 DocumentLoader(const ResourceRequest&, const SubstituteData&);
166 168
167 bool m_deferMainResourceDataLoad; 169 bool m_deferMainResourceDataLoad;
168 170
169 private: 171 private:
172 static PassOwnPtr<DocumentWriter> createWriterFor(Frame*, const Document * ownerDocument, const KURL&, const String& mimeType, const String& encoding, bo ol userChosen, bool dispatch);
173
174 void ensureWriter();
175 void ensureWriter(const String& mimeType);
170 176
171 // The URL of the document resulting from this DocumentLoader. 177 // The URL of the document resulting from this DocumentLoader.
172 KURL documentURL() const; 178 KURL documentURL() const;
173 Document* document() const; 179 Document* document() const;
174 180
175 void setRequest(const ResourceRequest&); 181 void setRequest(const ResourceRequest&);
176 182
177 void commitIfReady(); 183 void commitIfReady();
178 void setMainDocumentError(const ResourceError&); 184 void setMainDocumentError(const ResourceError&);
179 void commitLoad(const char*, int); 185 void commitLoad(const char*, int);
180 void clearMainResourceLoader(); 186 void clearMainResourceLoader();
181 ResourceLoader* mainResourceLoader() const; 187 ResourceLoader* mainResourceLoader() const;
182 void clearMainResourceHandle(); 188 void clearMainResourceHandle();
183 PassRefPtr<SharedBuffer> mainResourceData() const; 189 PassRefPtr<SharedBuffer> mainResourceData() const;
184 190
185 bool maybeCreateArchive(); 191 void createArchive();
186 void clearArchiveResources(); 192 void clearArchiveResources();
187 193
188 void prepareSubframeArchiveLoadIfNeeded(); 194 void prepareSubframeArchiveLoadIfNeeded();
189 void addAllArchiveResources(MHTMLArchive*); 195 void addAllArchiveResources(MHTMLArchive*);
190 196
191 void willSendRequest(ResourceRequest&, const ResourceResponse&); 197 void willSendRequest(ResourceRequest&, const ResourceResponse&);
192 void finishedLoading(double finishTime); 198 void finishedLoading(double finishTime);
193 void mainReceivedError(const ResourceError&); 199 void mainReceivedError(const ResourceError&);
194 virtual void redirectReceived(CachedResource*, ResourceRequest&, const R esourceResponse&) OVERRIDE; 200 virtual void redirectReceived(CachedResource*, ResourceRequest&, const R esourceResponse&) OVERRIDE;
195 virtual void responseReceived(CachedResource*, const ResourceResponse&) OVERRIDE; 201 virtual void responseReceived(CachedResource*, const ResourceResponse&) OVERRIDE;
(...skipping 14 matching lines...) Expand all
210 void handleSubstituteDataLoadNow(DocumentLoaderTimer*); 216 void handleSubstituteDataLoadNow(DocumentLoaderTimer*);
211 void startDataLoadTimer(); 217 void startDataLoadTimer();
212 218
213 Frame* m_frame; 219 Frame* m_frame;
214 RefPtr<CachedResourceLoader> m_cachedResourceLoader; 220 RefPtr<CachedResourceLoader> m_cachedResourceLoader;
215 221
216 CachedResourceHandle<CachedRawResource> m_mainResource; 222 CachedResourceHandle<CachedRawResource> m_mainResource;
217 ResourceLoaderSet m_resourceLoaders; 223 ResourceLoaderSet m_resourceLoaders;
218 ResourceLoaderSet m_multipartResourceLoaders; 224 ResourceLoaderSet m_multipartResourceLoaders;
219 225
220 mutable DocumentWriter m_writer; 226 OwnPtr<DocumentWriter> m_writer;
221 227
222 // A reference to actual request used to create the data source. 228 // A reference to actual request used to create the data source.
223 // This should only be used by the resourceLoadDelegate's 229 // This should only be used by the resourceLoadDelegate's
224 // identifierForInitialRequest:fromDatasource: method. It is 230 // identifierForInitialRequest:fromDatasource: method. It is
225 // not guaranteed to remain unchanged, as requests are mutable. 231 // not guaranteed to remain unchanged, as requests are mutable.
226 ResourceRequest m_originalRequest; 232 ResourceRequest m_originalRequest;
227 233
228 SubstituteData m_substituteData; 234 SubstituteData m_substituteData;
229 235
230 // A copy of the original request used to create the data source. 236 // A copy of the original request used to create the data source.
231 // We have to copy the request because requests are mutable. 237 // We have to copy the request because requests are mutable.
232 ResourceRequest m_originalRequestCopy; 238 ResourceRequest m_originalRequestCopy;
233 239
234 // The 'working' request. It may be mutated 240 // The 'working' request. It may be mutated
235 // several times from the original request to include additional 241 // several times from the original request to include additional
236 // headers, cookie information, canonicalization and redirects. 242 // headers, cookie information, canonicalization and redirects.
237 ResourceRequest m_request; 243 ResourceRequest m_request;
238 244
239 ResourceResponse m_response; 245 ResourceResponse m_response;
240 246
241 ResourceError m_mainDocumentError; 247 ResourceError m_mainDocumentError;
242 248
243 bool m_committed; 249 bool m_committed;
244 bool m_isStopping; 250 bool m_isStopping;
245 bool m_gotFirstByte;
246 bool m_isClientRedirect; 251 bool m_isClientRedirect;
247 252
248 // FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloa dHandled are roughly the same 253 // FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloa dHandled are roughly the same
249 // and should be merged. 254 // and should be merged.
250 bool m_wasOnloadHandled; 255 bool m_wasOnloadHandled;
251 256
252 StringWithDirection m_pageTitle; 257 StringWithDirection m_pageTitle;
253 258
254 String m_overrideEncoding; 259 String m_overrideEncoding;
255 260
(...skipping 11 matching lines...) Expand all
267 unsigned long m_identifierForLoadWithoutResourceLoader; 272 unsigned long m_identifierForLoadWithoutResourceLoader;
268 273
269 DocumentLoaderTimer m_dataLoadTimer; 274 DocumentLoaderTimer m_dataLoadTimer;
270 275
271 friend class ApplicationCacheHost; // for substitute resource delivery 276 friend class ApplicationCacheHost; // for substitute resource delivery
272 OwnPtr<ApplicationCacheHost> m_applicationCacheHost; 277 OwnPtr<ApplicationCacheHost> m_applicationCacheHost;
273 }; 278 };
274 } 279 }
275 280
276 #endif // DocumentLoader_h 281 #endif // DocumentLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698