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

Side by Side Diff: Source/platform/mhtml/MHTMLArchive.cpp

Issue 374053002: Oilpan: move MHTML objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Put MHTMLParser on the stack Created 6 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
« no previous file with comments | « Source/platform/mhtml/MHTMLArchive.h ('k') | Source/platform/mhtml/MHTMLParser.h » ('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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "platform/mhtml/MHTMLArchive.h" 32 #include "platform/mhtml/MHTMLArchive.h"
33 33
34 #include "platform/DateComponents.h" 34 #include "platform/DateComponents.h"
35 #include "platform/MIMETypeRegistry.h" 35 #include "platform/MIMETypeRegistry.h"
36 #include "platform/SerializedResource.h" 36 #include "platform/SerializedResource.h"
37 #include "platform/SharedBuffer.h" 37 #include "platform/SharedBuffer.h"
38 #include "platform/mhtml/ArchiveResource.h"
38 #include "platform/mhtml/MHTMLParser.h" 39 #include "platform/mhtml/MHTMLParser.h"
39 #include "platform/text/QuotedPrintable.h" 40 #include "platform/text/QuotedPrintable.h"
40 #include "platform/weborigin/SchemeRegistry.h" 41 #include "platform/weborigin/SchemeRegistry.h"
41 #include "wtf/CryptographicallyRandomNumber.h" 42 #include "wtf/CryptographicallyRandomNumber.h"
42 #include "wtf/DateMath.h" 43 #include "wtf/DateMath.h"
43 #include "wtf/text/Base64.h" 44 #include "wtf/text/Base64.h"
44 #include "wtf/text/StringBuilder.h" 45 #include "wtf/text/StringBuilder.h"
45 46
46 namespace WebCore { 47 namespace WebCore {
47 48
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 80 }
80 return stringBuilder.toString(); 81 return stringBuilder.toString();
81 } 82 }
82 83
83 MHTMLArchive::MHTMLArchive() 84 MHTMLArchive::MHTMLArchive()
84 { 85 {
85 } 86 }
86 87
87 MHTMLArchive::~MHTMLArchive() 88 MHTMLArchive::~MHTMLArchive()
88 { 89 {
90 #if !ENABLE(OILPAN)
89 // Because all frames know about each other we need to perform a deep cleari ng of the archives graph. 91 // Because all frames know about each other we need to perform a deep cleari ng of the archives graph.
90 clearAllSubframeArchives(); 92 clearAllSubframeArchives();
93 #endif
91 } 94 }
92 95
93 PassRefPtr<MHTMLArchive> MHTMLArchive::create() 96 PassRefPtrWillBeRawPtr<MHTMLArchive> MHTMLArchive::create()
94 { 97 {
95 return adoptRef(new MHTMLArchive); 98 return adoptRefWillBeNoop(new MHTMLArchive);
96 } 99 }
97 100
98 PassRefPtr<MHTMLArchive> MHTMLArchive::create(const KURL& url, SharedBuffer* dat a) 101 PassRefPtrWillBeRawPtr<MHTMLArchive> MHTMLArchive::create(const KURL& url, Share dBuffer* data)
99 { 102 {
100 // For security reasons we only load MHTML pages from local URLs. 103 // For security reasons we only load MHTML pages from local URLs.
101 if (!SchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol())) 104 if (!SchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol()))
102 return nullptr; 105 return nullptr;
103 106
104 MHTMLParser parser(data); 107 MHTMLParser parser(data);
105 RefPtr<MHTMLArchive> mainArchive = parser.parseArchive(); 108 RefPtrWillBeRawPtr<MHTMLArchive> mainArchive = parser.parseArchive();
106 if (!mainArchive) 109 if (!mainArchive)
107 return nullptr; // Invalid MHTML file. 110 return nullptr; // Invalid MHTML file.
108 111
109 // Since MHTML is a flat format, we need to make all frames aware of all res ources. 112 // Since MHTML is a flat format, we need to make all frames aware of all res ources.
110 for (size_t i = 0; i < parser.frameCount(); ++i) { 113 for (size_t i = 0; i < parser.frameCount(); ++i) {
111 RefPtr<MHTMLArchive> archive = parser.frameAt(i); 114 RefPtrWillBeRawPtr<MHTMLArchive> archive = parser.frameAt(i);
112 for (size_t j = 1; j < parser.frameCount(); ++j) { 115 for (size_t j = 1; j < parser.frameCount(); ++j) {
113 if (i != j) 116 if (i != j)
114 archive->addSubframeArchive(parser.frameAt(j)); 117 archive->addSubframeArchive(parser.frameAt(j));
115 } 118 }
116 for (size_t j = 0; j < parser.subResourceCount(); ++j) 119 for (size_t j = 0; j < parser.subResourceCount(); ++j)
117 archive->addSubresource(parser.subResourceAt(j)); 120 archive->addSubresource(parser.subResourceAt(j));
118 } 121 }
119 return mainArchive.release(); 122 return mainArchive.release();
120 } 123 }
121 124
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 210 }
208 } 211 }
209 } 212 }
210 213
211 asciiString = String("--" + boundary + "--\r\n").utf8(); 214 asciiString = String("--" + boundary + "--\r\n").utf8();
212 mhtmlData->append(asciiString.data(), asciiString.length()); 215 mhtmlData->append(asciiString.data(), asciiString.length());
213 216
214 return mhtmlData.release(); 217 return mhtmlData.release();
215 } 218 }
216 219
217 void MHTMLArchive::clearAllSubframeArchives() 220 void MHTMLArchive::clearAllSubframeArchives()
haraken 2014/07/08 08:50:08 I'm curious why we need to call clearAllSubframeAr
haraken 2014/07/08 08:50:08 Can we add #if !ENABLE(OILPAN) to this method?
sof 2014/07/08 09:10:00 I think you're right, I didn't see the point of th
218 { 221 {
219 Vector<RefPtr<MHTMLArchive> > clearedArchives; 222 SubFrameArchives clearedArchives;
220 clearAllSubframeArchivesImpl(&clearedArchives); 223 clearAllSubframeArchivesImpl(&clearedArchives);
221 } 224 }
222 225
223 void MHTMLArchive::clearAllSubframeArchivesImpl(Vector<RefPtr<MHTMLArchive> >* c learedArchives) 226 void MHTMLArchive::clearAllSubframeArchivesImpl(SubFrameArchives* clearedArchive s)
haraken 2014/07/08 08:50:07 Ditto.
224 { 227 {
225 for (Vector<RefPtr<MHTMLArchive> >::iterator it = m_subframeArchives.begin() ; it != m_subframeArchives.end(); ++it) { 228 for (SubFrameArchives::iterator it = m_subframeArchives.begin(); it != m_sub frameArchives.end(); ++it) {
226 if (!clearedArchives->contains(*it)) { 229 if (!clearedArchives->contains(*it)) {
227 clearedArchives->append(*it); 230 clearedArchives->append(*it);
228 (*it)->clearAllSubframeArchivesImpl(clearedArchives); 231 (*it)->clearAllSubframeArchivesImpl(clearedArchives);
229 } 232 }
230 } 233 }
231 m_subframeArchives.clear(); 234 m_subframeArchives.clear();
232 } 235 }
233 236
237 void MHTMLArchive::trace(Visitor* visitor)
238 {
239 visitor->trace(m_mainResource);
240 visitor->trace(m_subresources);
241 visitor->trace(m_subframeArchives);
234 } 242 }
243
244 }
OLDNEW
« no previous file with comments | « Source/platform/mhtml/MHTMLArchive.h ('k') | Source/platform/mhtml/MHTMLParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698