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

Side by Side Diff: third_party/WebKit/Source/web/WebFrameSerializer.cpp

Issue 2344153003: Adds tracing to MHTML generation call chain. (Closed)
Patch Set: Address code review comments Created 4 years, 3 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 | « third_party/WebKit/Source/core/frame/FrameSerializer.cpp ('k') | no next file » | 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 27 matching lines...) Expand all
38 #include "core/frame/LocalFrame.h" 38 #include "core/frame/LocalFrame.h"
39 #include "core/frame/RemoteFrame.h" 39 #include "core/frame/RemoteFrame.h"
40 #include "core/html/HTMLAllCollection.h" 40 #include "core/html/HTMLAllCollection.h"
41 #include "core/html/HTMLFrameElementBase.h" 41 #include "core/html/HTMLFrameElementBase.h"
42 #include "core/html/HTMLFrameOwnerElement.h" 42 #include "core/html/HTMLFrameOwnerElement.h"
43 #include "core/html/HTMLInputElement.h" 43 #include "core/html/HTMLInputElement.h"
44 #include "core/html/HTMLTableElement.h" 44 #include "core/html/HTMLTableElement.h"
45 #include "core/loader/DocumentLoader.h" 45 #include "core/loader/DocumentLoader.h"
46 #include "platform/SerializedResource.h" 46 #include "platform/SerializedResource.h"
47 #include "platform/SharedBuffer.h" 47 #include "platform/SharedBuffer.h"
48 #include "platform/TraceEvent.h"
48 #include "platform/mhtml/MHTMLArchive.h" 49 #include "platform/mhtml/MHTMLArchive.h"
49 #include "platform/mhtml/MHTMLParser.h" 50 #include "platform/mhtml/MHTMLParser.h"
50 #include "platform/network/ResourceRequest.h" 51 #include "platform/network/ResourceRequest.h"
51 #include "platform/network/ResourceResponse.h" 52 #include "platform/network/ResourceResponse.h"
52 #include "platform/weborigin/KURL.h" 53 #include "platform/weborigin/KURL.h"
53 #include "public/platform/WebString.h" 54 #include "public/platform/WebString.h"
54 #include "public/platform/WebURL.h" 55 #include "public/platform/WebURL.h"
55 #include "public/platform/WebURLResponse.h" 56 #include "public/platform/WebURLResponse.h"
56 #include "public/platform/WebVector.h" 57 #include "public/platform/WebVector.h"
57 #include "public/web/WebDataSource.h" 58 #include "public/web/WebDataSource.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 return true; 174 return true;
174 175
175 return !cacheControlNoStoreHeaderPresent(*webLocalFrameImpl); 176 return !cacheControlNoStoreHeaderPresent(*webLocalFrameImpl);
176 } 177 }
177 178
178 } // namespace 179 } // namespace
179 180
180 WebData WebFrameSerializer::generateMHTMLHeader( 181 WebData WebFrameSerializer::generateMHTMLHeader(
181 const WebString& boundary, WebLocalFrame* frame, MHTMLPartsGenerationDelegat e* delegate) 182 const WebString& boundary, WebLocalFrame* frame, MHTMLPartsGenerationDelegat e* delegate)
182 { 183 {
184 TRACE_EVENT0("page-serialization", "WebFrameSerializer::generateMHTMLHeader" );
183 DCHECK(frame); 185 DCHECK(frame);
184 DCHECK(delegate); 186 DCHECK(delegate);
185 187
186 if (!frameShouldBeSerializedAsMHTML(frame, delegate->cacheControlPolicy())) 188 if (!frameShouldBeSerializedAsMHTML(frame, delegate->cacheControlPolicy()))
187 return WebData(); 189 return WebData();
188 190
189 WebLocalFrameImpl* webLocalFrameImpl = toWebLocalFrameImpl(frame); 191 WebLocalFrameImpl* webLocalFrameImpl = toWebLocalFrameImpl(frame);
190 DCHECK(webLocalFrameImpl); 192 DCHECK(webLocalFrameImpl);
191 193
192 Document* document = webLocalFrameImpl->frame()->document(); 194 Document* document = webLocalFrameImpl->frame()->document();
193 195
194 RefPtr<SharedBuffer> buffer = SharedBuffer::create(); 196 RefPtr<SharedBuffer> buffer = SharedBuffer::create();
195 MHTMLArchive::generateMHTMLHeader( 197 MHTMLArchive::generateMHTMLHeader(
196 boundary, document->title(), document->suggestedMIMEType(), 198 boundary, document->title(), document->suggestedMIMEType(),
197 *buffer); 199 *buffer);
198 return buffer.release(); 200 return buffer.release();
199 } 201 }
200 202
201 WebData WebFrameSerializer::generateMHTMLParts( 203 WebData WebFrameSerializer::generateMHTMLParts(
202 const WebString& boundary, WebLocalFrame* webFrame, MHTMLPartsGenerationDele gate* webDelegate) 204 const WebString& boundary, WebLocalFrame* webFrame, MHTMLPartsGenerationDele gate* webDelegate)
203 { 205 {
206 TRACE_EVENT0("page-serialization", "WebFrameSerializer::generateMHTMLParts") ;
204 DCHECK(webFrame); 207 DCHECK(webFrame);
205 DCHECK(webDelegate); 208 DCHECK(webDelegate);
206 209
207 if (!frameShouldBeSerializedAsMHTML(webFrame, webDelegate->cacheControlPolic y())) 210 if (!frameShouldBeSerializedAsMHTML(webFrame, webDelegate->cacheControlPolic y()))
208 return WebData(); 211 return WebData();
209 212
210 // Translate arguments from public to internal blink APIs. 213 // Translate arguments from public to internal blink APIs.
211 LocalFrame* frame = toWebLocalFrameImpl(webFrame)->frame(); 214 LocalFrame* frame = toWebLocalFrameImpl(webFrame)->frame();
212 MHTMLArchive::EncodingPolicy encodingPolicy = webDelegate->useBinaryEncoding () 215 MHTMLArchive::EncodingPolicy encodingPolicy = webDelegate->useBinaryEncoding ()
213 ? MHTMLArchive::EncodingPolicy::UseBinaryEncoding 216 ? MHTMLArchive::EncodingPolicy::UseBinaryEncoding
214 : MHTMLArchive::EncodingPolicy::UseDefaultEncoding; 217 : MHTMLArchive::EncodingPolicy::UseDefaultEncoding;
215 218
216 // Serialize. 219 // Serialize.
217 Vector<SerializedResource> resources; 220 Vector<SerializedResource> resources;
221 TRACE_EVENT_BEGIN0("page-serialization", "WebFrameSerializer::generateMHTMLP arts serializing");
218 MHTMLFrameSerializerDelegate coreDelegate(*webDelegate); 222 MHTMLFrameSerializerDelegate coreDelegate(*webDelegate);
219 FrameSerializer serializer(resources, coreDelegate); 223 FrameSerializer serializer(resources, coreDelegate);
220 serializer.serializeFrame(*frame); 224 serializer.serializeFrame(*frame);
225 TRACE_EVENT_END1("page-serialization", "WebFrameSerializer::generateMHTMLPar ts serializing",
226 "resource count", static_cast<unsigned long long>(resources.size()));
221 227
222 // Get Content-ID for the frame being serialized. 228 // Get Content-ID for the frame being serialized.
223 String frameContentID = webDelegate->getContentID(webFrame); 229 String frameContentID = webDelegate->getContentID(webFrame);
224 230
225 // Encode serializer's output as MHTML. 231 // Encode serializer's output as MHTML.
226 RefPtr<SharedBuffer> output = SharedBuffer::create(); 232 RefPtr<SharedBuffer> output = SharedBuffer::create();
227 bool isFirstResource = true; 233 bool isFirstResource = true;
228 for (const SerializedResource& resource : resources) { 234 for (const SerializedResource& resource : resources) {
235 TRACE_EVENT0("page-serialization", "WebFrameSerializer::generateMHTMLPar ts encoding");
229 // Frame is the 1st resource (see FrameSerializer::serializeFrame doc 236 // Frame is the 1st resource (see FrameSerializer::serializeFrame doc
230 // comment). Frames get a Content-ID header. 237 // comment). Frames get a Content-ID header.
231 String contentID = isFirstResource ? frameContentID : String(); 238 String contentID = isFirstResource ? frameContentID : String();
232 239
233 MHTMLArchive::generateMHTMLPart( 240 MHTMLArchive::generateMHTMLPart(
234 boundary, contentID, encodingPolicy, resource, *output); 241 boundary, contentID, encodingPolicy, resource, *output);
235 242
236 isFirstResource = false; 243 isFirstResource = false;
237 } 244 }
238 return output.release(); 245 return output.release();
239 } 246 }
240 247
241 WebData WebFrameSerializer::generateMHTMLFooter(const WebString& boundary) 248 WebData WebFrameSerializer::generateMHTMLFooter(const WebString& boundary)
242 { 249 {
250 TRACE_EVENT0("page-serialization", "WebFrameSerializer::generateMHTMLFooter" );
243 RefPtr<SharedBuffer> buffer = SharedBuffer::create(); 251 RefPtr<SharedBuffer> buffer = SharedBuffer::create();
244 MHTMLArchive::generateMHTMLFooter(boundary, *buffer); 252 MHTMLArchive::generateMHTMLFooter(boundary, *buffer);
245 return buffer.release(); 253 return buffer.release();
246 } 254 }
247 255
248 bool WebFrameSerializer::serialize( 256 bool WebFrameSerializer::serialize(
249 WebLocalFrame* frame, 257 WebLocalFrame* frame,
250 WebFrameSerializerClient* client, 258 WebFrameSerializerClient* client,
251 WebFrameSerializer::LinkRewritingDelegate* delegate) 259 WebFrameSerializer::LinkRewritingDelegate* delegate)
252 { 260 {
(...skipping 20 matching lines...) Expand all
273 WebString WebFrameSerializer::generateBaseTagDeclaration(const WebString& baseTa rget) 281 WebString WebFrameSerializer::generateBaseTagDeclaration(const WebString& baseTa rget)
274 { 282 {
275 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. 283 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|.
276 if (baseTarget.isEmpty()) 284 if (baseTarget.isEmpty())
277 return String("<base href=\".\">"); 285 return String("<base href=\".\">");
278 String baseString = "<base href=\".\" target=\"" + static_cast<const String& >(baseTarget) + "\">"; 286 String baseString = "<base href=\".\" target=\"" + static_cast<const String& >(baseTarget) + "\">";
279 return baseString; 287 return baseString;
280 } 288 }
281 289
282 } // namespace blink 290 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameSerializer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698