OLD | NEW |
---|---|
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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 TRACE_EVENT_BEGIN0("page-serialization", | 287 TRACE_EVENT_BEGIN0("page-serialization", |
288 "WebFrameSerializer::generateMHTMLParts serializing"); | 288 "WebFrameSerializer::generateMHTMLParts serializing"); |
289 Deque<SerializedResource> resources; | 289 Deque<SerializedResource> resources; |
290 { | 290 { |
291 SCOPED_BLINK_UMA_HISTOGRAM_TIMER( | 291 SCOPED_BLINK_UMA_HISTOGRAM_TIMER( |
292 "PageSerialization.MhtmlGeneration.SerializationTime.SingleFrame"); | 292 "PageSerialization.MhtmlGeneration.SerializationTime.SingleFrame"); |
293 MHTMLFrameSerializerDelegate coreDelegate(*webDelegate); | 293 MHTMLFrameSerializerDelegate coreDelegate(*webDelegate); |
294 FrameSerializer serializer(resources, coreDelegate); | 294 FrameSerializer serializer(resources, coreDelegate); |
295 serializer.serializeFrame(*frame); | 295 serializer.serializeFrame(*frame); |
296 } | 296 } |
297 | |
298 // There was an error serializing the frame (e.g. of an image resource). | |
299 if (resources.isEmpty()) | |
300 return WebThreadSafeData(); | |
carlosk
2017/01/06 23:26:36
To keep tracing logic consistent this should be mo
Charlie Harrison
2017/01/07 02:31:25
Good catch, will fix this in a follow up.
| |
301 | |
297 TRACE_EVENT_END1("page-serialization", | 302 TRACE_EVENT_END1("page-serialization", |
298 "WebFrameSerializer::generateMHTMLParts serializing", | 303 "WebFrameSerializer::generateMHTMLParts serializing", |
299 "resource count", | 304 "resource count", |
300 static_cast<unsigned long long>(resources.size())); | 305 static_cast<unsigned long long>(resources.size())); |
301 | 306 |
302 // Encode serialized resources as MHTML. | 307 // Encode serialized resources as MHTML. |
303 RefPtr<RawData> output = RawData::create(); | 308 RefPtr<RawData> output = RawData::create(); |
304 { | 309 { |
305 DCHECK(!resources.isEmpty()); | |
306 SCOPED_BLINK_UMA_HISTOGRAM_TIMER( | 310 SCOPED_BLINK_UMA_HISTOGRAM_TIMER( |
307 "PageSerialization.MhtmlGeneration.EncodingTime.SingleFrame"); | 311 "PageSerialization.MhtmlGeneration.EncodingTime.SingleFrame"); |
308 // Frame is the 1st resource (see FrameSerializer::serializeFrame doc | 312 // Frame is the 1st resource (see FrameSerializer::serializeFrame doc |
309 // comment). Frames get a Content-ID header. | 313 // comment). Frames get a Content-ID header. |
310 MHTMLArchive::generateMHTMLPart( | 314 MHTMLArchive::generateMHTMLPart( |
311 boundary, webDelegate->getContentID(webFrame), encodingPolicy, | 315 boundary, webDelegate->getContentID(webFrame), encodingPolicy, |
312 resources.takeFirst(), *output->mutableData()); | 316 resources.takeFirst(), *output->mutableData()); |
313 while (!resources.isEmpty()) { | 317 while (!resources.isEmpty()) { |
314 TRACE_EVENT0("page-serialization", | 318 TRACE_EVENT0("page-serialization", |
315 "WebFrameSerializer::generateMHTMLParts encoding"); | 319 "WebFrameSerializer::generateMHTMLParts encoding"); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 const WebString& baseTarget) { | 363 const WebString& baseTarget) { |
360 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. | 364 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. |
361 if (baseTarget.isEmpty()) | 365 if (baseTarget.isEmpty()) |
362 return String("<base href=\".\">"); | 366 return String("<base href=\".\">"); |
363 String baseString = "<base href=\".\" target=\"" + | 367 String baseString = "<base href=\".\" target=\"" + |
364 static_cast<const String&>(baseTarget) + "\">"; | 368 static_cast<const String&>(baseTarget) + "\">"; |
365 return baseString; | 369 return baseString; |
366 } | 370 } |
367 | 371 |
368 } // namespace blink | 372 } // namespace blink |
OLD | NEW |