| 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 25 matching lines...) Expand all Loading... |
| 36 #include "core/frame/Frame.h" | 36 #include "core/frame/Frame.h" |
| 37 #include "core/frame/FrameSerializer.h" | 37 #include "core/frame/FrameSerializer.h" |
| 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/Histogram.h" |
| 46 #include "platform/SerializedResource.h" | 47 #include "platform/SerializedResource.h" |
| 47 #include "platform/SharedBuffer.h" | 48 #include "platform/SharedBuffer.h" |
| 48 #include "platform/TraceEvent.h" | 49 #include "platform/TraceEvent.h" |
| 49 #include "platform/mhtml/MHTMLArchive.h" | 50 #include "platform/mhtml/MHTMLArchive.h" |
| 50 #include "platform/mhtml/MHTMLParser.h" | 51 #include "platform/mhtml/MHTMLParser.h" |
| 51 #include "platform/network/ResourceRequest.h" | 52 #include "platform/network/ResourceRequest.h" |
| 52 #include "platform/network/ResourceResponse.h" | 53 #include "platform/network/ResourceResponse.h" |
| 53 #include "platform/weborigin/KURL.h" | 54 #include "platform/weborigin/KURL.h" |
| 54 #include "public/platform/WebString.h" | 55 #include "public/platform/WebString.h" |
| 55 #include "public/platform/WebURL.h" | 56 #include "public/platform/WebURL.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 if (!frameShouldBeSerializedAsMHTML(webFrame, webDelegate->cacheControlPolic
y())) | 211 if (!frameShouldBeSerializedAsMHTML(webFrame, webDelegate->cacheControlPolic
y())) |
| 211 return WebData(); | 212 return WebData(); |
| 212 | 213 |
| 213 // Translate arguments from public to internal blink APIs. | 214 // Translate arguments from public to internal blink APIs. |
| 214 LocalFrame* frame = toWebLocalFrameImpl(webFrame)->frame(); | 215 LocalFrame* frame = toWebLocalFrameImpl(webFrame)->frame(); |
| 215 MHTMLArchive::EncodingPolicy encodingPolicy = webDelegate->useBinaryEncoding
() | 216 MHTMLArchive::EncodingPolicy encodingPolicy = webDelegate->useBinaryEncoding
() |
| 216 ? MHTMLArchive::EncodingPolicy::UseBinaryEncoding | 217 ? MHTMLArchive::EncodingPolicy::UseBinaryEncoding |
| 217 : MHTMLArchive::EncodingPolicy::UseDefaultEncoding; | 218 : MHTMLArchive::EncodingPolicy::UseDefaultEncoding; |
| 218 | 219 |
| 219 // Serialize. | 220 // Serialize. |
| 221 TRACE_EVENT_BEGIN0("page-serialization", "WebFrameSerializer::generateMHTMLP
arts serializing"); |
| 220 Vector<SerializedResource> resources; | 222 Vector<SerializedResource> resources; |
| 221 TRACE_EVENT_BEGIN0("page-serialization", "WebFrameSerializer::generateMHTMLP
arts serializing"); | 223 { |
| 222 MHTMLFrameSerializerDelegate coreDelegate(*webDelegate); | 224 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("PageSerialization.MhtmlGeneration.Seri
alizationTime.SingleFrame"); |
| 223 FrameSerializer serializer(resources, coreDelegate); | 225 MHTMLFrameSerializerDelegate coreDelegate(*webDelegate); |
| 224 serializer.serializeFrame(*frame); | 226 FrameSerializer serializer(resources, coreDelegate); |
| 227 serializer.serializeFrame(*frame); |
| 228 } |
| 225 TRACE_EVENT_END1("page-serialization", "WebFrameSerializer::generateMHTMLPar
ts serializing", | 229 TRACE_EVENT_END1("page-serialization", "WebFrameSerializer::generateMHTMLPar
ts serializing", |
| 226 "resource count", static_cast<unsigned long long>(resources.size())); | 230 "resource count", static_cast<unsigned long long>(resources.size())); |
| 227 | 231 |
| 228 // Get Content-ID for the frame being serialized. | 232 // Get Content-ID for the frame being serialized. |
| 229 String frameContentID = webDelegate->getContentID(webFrame); | 233 String frameContentID = webDelegate->getContentID(webFrame); |
| 230 | 234 |
| 231 // Encode serializer's output as MHTML. | 235 // Encode serializer's output as MHTML. |
| 232 RefPtr<SharedBuffer> output = SharedBuffer::create(); | 236 RefPtr<SharedBuffer> output = SharedBuffer::create(); |
| 233 bool isFirstResource = true; | 237 { |
| 234 for (const SerializedResource& resource : resources) { | 238 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("PageSerialization.MhtmlGeneration.Enco
dingTime.SingleFrame"); |
| 235 TRACE_EVENT0("page-serialization", "WebFrameSerializer::generateMHTMLPar
ts encoding"); | 239 bool isFirstResource = true; |
| 236 // Frame is the 1st resource (see FrameSerializer::serializeFrame doc | 240 for (const SerializedResource& resource : resources) { |
| 237 // comment). Frames get a Content-ID header. | 241 TRACE_EVENT0("page-serialization", "WebFrameSerializer::generateMHTM
LParts encoding"); |
| 238 String contentID = isFirstResource ? frameContentID : String(); | 242 // Frame is the 1st resource (see FrameSerializer::serializeFrame do
c |
| 243 // comment). Frames get a Content-ID header. |
| 244 String contentID = isFirstResource ? frameContentID : String(); |
| 239 | 245 |
| 240 MHTMLArchive::generateMHTMLPart( | 246 MHTMLArchive::generateMHTMLPart( |
| 241 boundary, contentID, encodingPolicy, resource, *output); | 247 boundary, contentID, encodingPolicy, resource, *output); |
| 242 | 248 |
| 243 isFirstResource = false; | 249 isFirstResource = false; |
| 250 } |
| 244 } | 251 } |
| 245 return output.release(); | 252 return output.release(); |
| 246 } | 253 } |
| 247 | 254 |
| 248 WebData WebFrameSerializer::generateMHTMLFooter(const WebString& boundary) | 255 WebData WebFrameSerializer::generateMHTMLFooter(const WebString& boundary) |
| 249 { | 256 { |
| 250 TRACE_EVENT0("page-serialization", "WebFrameSerializer::generateMHTMLFooter"
); | 257 TRACE_EVENT0("page-serialization", "WebFrameSerializer::generateMHTMLFooter"
); |
| 251 RefPtr<SharedBuffer> buffer = SharedBuffer::create(); | 258 RefPtr<SharedBuffer> buffer = SharedBuffer::create(); |
| 252 MHTMLArchive::generateMHTMLFooter(boundary, *buffer); | 259 MHTMLArchive::generateMHTMLFooter(boundary, *buffer); |
| 253 return buffer.release(); | 260 return buffer.release(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 281 WebString WebFrameSerializer::generateBaseTagDeclaration(const WebString& baseTa
rget) | 288 WebString WebFrameSerializer::generateBaseTagDeclaration(const WebString& baseTa
rget) |
| 282 { | 289 { |
| 283 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. | 290 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. |
| 284 if (baseTarget.isEmpty()) | 291 if (baseTarget.isEmpty()) |
| 285 return String("<base href=\".\">"); | 292 return String("<base href=\".\">"); |
| 286 String baseString = "<base href=\".\" target=\"" + static_cast<const String&
>(baseTarget) + "\">"; | 293 String baseString = "<base href=\".\" target=\"" + static_cast<const String&
>(baseTarget) + "\">"; |
| 287 return baseString; | 294 return baseString; |
| 288 } | 295 } |
| 289 | 296 |
| 290 } // namespace blink | 297 } // namespace blink |
| OLD | NEW |