| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "base/memory/shared_memory.h" | 23 #include "base/memory/shared_memory.h" |
| 24 #include "base/memory/weak_ptr.h" | 24 #include "base/memory/weak_ptr.h" |
| 25 #include "base/metrics/field_trial.h" | 25 #include "base/metrics/field_trial.h" |
| 26 #include "base/metrics/histogram_macros.h" | 26 #include "base/metrics/histogram_macros.h" |
| 27 #include "base/process/process.h" | 27 #include "base/process/process.h" |
| 28 #include "base/stl_util.h" | 28 #include "base/stl_util.h" |
| 29 #include "base/strings/string16.h" | 29 #include "base/strings/string16.h" |
| 30 #include "base/strings/utf_string_conversions.h" | 30 #include "base/strings/utf_string_conversions.h" |
| 31 #include "base/threading/thread_task_runner_handle.h" | 31 #include "base/threading/thread_task_runner_handle.h" |
| 32 #include "base/time/time.h" | 32 #include "base/time/time.h" |
| 33 #include "base/trace_event/trace_event_argument.h" | 33 #include "base/trace_event/trace_event.h" |
| 34 #include "build/build_config.h" | 34 #include "build/build_config.h" |
| 35 #include "cc/base/switches.h" | 35 #include "cc/base/switches.h" |
| 36 #include "content/child/appcache/appcache_dispatcher.h" | 36 #include "content/child/appcache/appcache_dispatcher.h" |
| 37 #include "content/child/quota_dispatcher.h" | 37 #include "content/child/quota_dispatcher.h" |
| 38 #include "content/child/request_extra_data.h" | 38 #include "content/child/request_extra_data.h" |
| 39 #include "content/child/service_worker/service_worker_handle_reference.h" | 39 #include "content/child/service_worker/service_worker_handle_reference.h" |
| 40 #include "content/child/service_worker/service_worker_network_provider.h" | 40 #include "content/child/service_worker/service_worker_network_provider.h" |
| 41 #include "content/child/service_worker/service_worker_provider_context.h" | 41 #include "content/child/service_worker/service_worker_provider_context.h" |
| 42 #include "content/child/service_worker/web_service_worker_provider_impl.h" | 42 #include "content/child/service_worker/web_service_worker_provider_impl.h" |
| 43 #include "content/child/v8_value_converter_impl.h" | 43 #include "content/child/v8_value_converter_impl.h" |
| (...skipping 5125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5169 frame_routing_id_to_local_path); | 5169 frame_routing_id_to_local_path); |
| 5170 | 5170 |
| 5171 // Serialize the frame (without recursing into subframes). | 5171 // Serialize the frame (without recursing into subframes). |
| 5172 WebFrameSerializer::serialize(GetWebFrame(), | 5172 WebFrameSerializer::serialize(GetWebFrame(), |
| 5173 this, // WebFrameSerializerClient. | 5173 this, // WebFrameSerializerClient. |
| 5174 &delegate); | 5174 &delegate); |
| 5175 } | 5175 } |
| 5176 | 5176 |
| 5177 void RenderFrameImpl::OnSerializeAsMHTML( | 5177 void RenderFrameImpl::OnSerializeAsMHTML( |
| 5178 const FrameMsg_SerializeAsMHTML_Params& params) { | 5178 const FrameMsg_SerializeAsMHTML_Params& params) { |
| 5179 TRACE_EVENT0("page-serialization", "RenderFrameImpl::OnSerializeAsMHTML"); |
| 5179 // Unpack IPC payload. | 5180 // Unpack IPC payload. |
| 5180 base::File file = IPC::PlatformFileForTransitToFile(params.destination_file); | 5181 base::File file = IPC::PlatformFileForTransitToFile(params.destination_file); |
| 5181 const WebString mhtml_boundary = | 5182 const WebString mhtml_boundary = |
| 5182 WebString::fromUTF8(params.mhtml_boundary_marker); | 5183 WebString::fromUTF8(params.mhtml_boundary_marker); |
| 5183 DCHECK(!mhtml_boundary.isEmpty()); | 5184 DCHECK(!mhtml_boundary.isEmpty()); |
| 5184 | 5185 |
| 5185 WebData data; | 5186 WebData data; |
| 5186 std::set<std::string> digests_of_uris_of_serialized_resources; | 5187 std::set<std::string> digests_of_uris_of_serialized_resources; |
| 5187 MHTMLPartsGenerationDelegate delegate( | 5188 MHTMLPartsGenerationDelegate delegate( |
| 5188 params, &digests_of_uris_of_serialized_resources); | 5189 params, &digests_of_uris_of_serialized_resources); |
| 5189 | 5190 |
| 5190 bool success = true; | 5191 bool success = true; |
| 5191 | 5192 |
| 5192 // Generate MHTML header if needed. | 5193 // Generate MHTML header if needed. |
| 5193 if (IsMainFrame()) { | 5194 if (IsMainFrame()) { |
| 5195 TRACE_EVENT0("page-serialization", |
| 5196 "RenderFrameImpl::OnSerializeAsMHTML header"); |
| 5194 // |data| can be empty if the main frame should be skipped. If the main | 5197 // |data| can be empty if the main frame should be skipped. If the main |
| 5195 // frame is | 5198 // frame is skipped, then the whole archive is bad, so bail to the error |
| 5196 // skipped, then the whole archive is bad, so bail to the error condition. | 5199 // condition. |
| 5197 WebData data = WebFrameSerializer::generateMHTMLHeader( | 5200 WebData data = WebFrameSerializer::generateMHTMLHeader( |
| 5198 mhtml_boundary, GetWebFrame(), &delegate); | 5201 mhtml_boundary, GetWebFrame(), &delegate); |
| 5199 if (data.isEmpty() || | 5202 if (data.isEmpty() || |
| 5200 file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 5203 file.WriteAtCurrentPos(data.data(), data.size()) < 0) { |
| 5201 success = false; | 5204 success = false; |
| 5202 } | 5205 } |
| 5203 } | 5206 } |
| 5204 | 5207 |
| 5205 // Generate MHTML parts. Note that if this is not the main frame, then even | 5208 // Generate MHTML parts. Note that if this is not the main frame, then even |
| 5206 // skipping the whole parts generation step is not an error - it simply | 5209 // skipping the whole parts generation step is not an error - it simply |
| 5207 // results in an omitted resource in the final file. | 5210 // results in an omitted resource in the final file. |
| 5208 if (success) { | 5211 if (success) { |
| 5212 TRACE_EVENT0("page-serialization", |
| 5213 "RenderFrameImpl::OnSerializeAsMHTML parts serialization"); |
| 5209 // |data| can be empty if the frame should be skipped, but this is OK. | 5214 // |data| can be empty if the frame should be skipped, but this is OK. |
| 5210 data = WebFrameSerializer::generateMHTMLParts(mhtml_boundary, GetWebFrame(), | 5215 data = WebFrameSerializer::generateMHTMLParts(mhtml_boundary, GetWebFrame(), |
| 5211 &delegate); | 5216 &delegate); |
| 5212 // TODO(jcivelli): write the chunks in deferred tasks to give a chance to | 5217 // TODO(jcivelli): write the chunks in deferred tasks to give a chance to |
| 5213 // the message loop to process other events. | 5218 // the message loop to process other events. |
| 5219 TRACE_EVENT0("page-serialization", |
| 5220 "RenderFrameImpl::OnSerializeAsMHTML parts file writing"); |
| 5214 if (!data.isEmpty() && | 5221 if (!data.isEmpty() && |
| 5215 file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 5222 file.WriteAtCurrentPos(data.data(), data.size()) < 0) { |
| 5216 success = false; | 5223 success = false; |
| 5217 } | 5224 } |
| 5218 } | 5225 } |
| 5219 | 5226 |
| 5220 // Generate MHTML footer if needed. | 5227 // Generate MHTML footer if needed. |
| 5221 if (success && params.is_last_frame) { | 5228 if (success && params.is_last_frame) { |
| 5229 TRACE_EVENT0("page-serialization", |
| 5230 "RenderFrameImpl::OnSerializeAsMHTML footer"); |
| 5222 data = WebFrameSerializer::generateMHTMLFooter(mhtml_boundary); | 5231 data = WebFrameSerializer::generateMHTMLFooter(mhtml_boundary); |
| 5223 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 5232 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { |
| 5224 success = false; | 5233 success = false; |
| 5225 } | 5234 } |
| 5226 } | 5235 } |
| 5227 | 5236 |
| 5228 // Cleanup and notify the browser process about completion. | 5237 // Cleanup and notify the browser process about completion. |
| 5229 file.Close(); // Need to flush file contents before sending IPC response. | 5238 file.Close(); // Need to flush file contents before sending IPC response. |
| 5230 Send(new FrameHostMsg_SerializeAsMHTMLResponse( | 5239 Send(new FrameHostMsg_SerializeAsMHTMLResponse( |
| 5231 routing_id_, params.job_id, success, | 5240 routing_id_, params.job_id, success, |
| (...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6398 // event target. Potentially a Pepper plugin will receive the event. | 6407 // event target. Potentially a Pepper plugin will receive the event. |
| 6399 // In order to tell whether a plugin gets the last mouse event and which it | 6408 // In order to tell whether a plugin gets the last mouse event and which it |
| 6400 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6409 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6401 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6410 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6402 // |pepper_last_mouse_event_target_|. | 6411 // |pepper_last_mouse_event_target_|. |
| 6403 pepper_last_mouse_event_target_ = nullptr; | 6412 pepper_last_mouse_event_target_ = nullptr; |
| 6404 #endif | 6413 #endif |
| 6405 } | 6414 } |
| 6406 | 6415 |
| 6407 } // namespace content | 6416 } // namespace content |
| OLD | NEW |