Replace IPC with Mojo Interface for MHTML Serialization
This change replaces the current usage of legacy IPC within the
context of MHTML Generation with Mojo to both update the interface as
well as prepare for the upcoming streaming of serialized MHTML data
back to the browser.
Changes made:
1.) A new Mojo interface is introduced in both the Browser and
Renderer processes, which uses a message pipe in lieu of IPC.
2.) The MHTMLGenerationManager will now create self-owning Jobs
that delete themselves. It no longer needs to keep track of
created Jobs via job_id_. Many of the manager's functions are
moved into the Job implementation.
3.) In absence of the std::set, an std::vector will be used within
the generation delegate instead, performing DCHECKs to ensure
it is sorted and unique.
4.) The file handle passed to the Renderer is no longer duplicated
via IPC::GetPlatformFileForTransit, but uses a similar
function File::Duplicate.
Bug: 915966
Change-Id: Id402c8540ee829b25a5a5839961cbbd5aad696cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1403518
Commit-Queue: Mark Lieu <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Charlie Reis <[email protected]>
Reviewed-by: Carlos Knippschild <[email protected]>
Reviewed-by: Ken Buchanan <[email protected]>
Reviewed-by: Min Qin <[email protected]>
Reviewed-by: Dan H <[email protected]>
Reviewed-by: Ćukasz Anforowicz <[email protected]>
Cr-Commit-Position: refs/heads/master@{#639297}
diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h
index 634e9d0..8f17a70 100644
--- a/content/renderer/render_frame_impl.h
+++ b/content/renderer/render_frame_impl.h
@@ -12,6 +12,7 @@
#include <memory>
#include <set>
#include <string>
+#include <unordered_set>
#include <utility>
#include <vector>
@@ -35,6 +36,7 @@
#include "content/common/frame_message_enums.h"
#include "content/common/host_zoom.mojom.h"
#include "content/common/media/renderer_audio_input_stream_factory.mojom.h"
+#include "content/common/mhtml_file_writer.mojom.h"
#include "content/common/possibly_associated_interface_ptr.h"
#include "content/common/renderer.mojom.h"
#include "content/common/unique_name_helper.h"
@@ -110,7 +112,6 @@
struct FrameMsg_MixedContentFound_Params;
struct FrameMsg_PostMessage_Params;
-struct FrameMsg_SerializeAsMHTML_Params;
struct FrameMsg_TextTrackSettings_Params;
namespace blink {
@@ -190,6 +191,7 @@
mojom::FullscreenVideoElementHandler,
mojom::HostZoom,
mojom::FrameBindingsControl,
+ mojom::MhtmlFileWriter,
public blink::WebLocalFrameClient,
public blink::WebFrameSerializerClient,
service_manager::mojom::InterfaceProvider {
@@ -638,6 +640,10 @@
// mojom::HostZoom implementation:
void SetHostZoomLevel(const GURL& url, double zoom_level) override;
+ // mojom::MhtmlFileWriter implementation:
+ void SerializeAsMHTML(const mojom::SerializeAsMHTMLParamsPtr params,
+ SerializeAsMHTMLCallback callback) override;
+
// blink::WebLocalFrameClient implementation:
blink::WebPlugin* CreatePlugin(const blink::WebPluginParams& params) override;
blink::WebMediaPlayer* CreateMediaPlayer(
@@ -857,6 +863,9 @@
void BindFullscreen(
mojom::FullscreenVideoElementHandlerAssociatedRequest request);
+ // Binds to the MHTML file generation service in the browser.
+ void BindMhtmlFileWriter(mojom::MhtmlFileWriterAssociatedRequest request);
+
// Binds to the autoplay configuration service in the browser.
void BindAutoplayConfiguration(
blink::mojom::AutoplayConfigurationClientAssociatedRequest request);
@@ -1119,7 +1128,6 @@
void OnGetSerializedHtmlWithLocalLinks(
const std::map<GURL, base::FilePath>& url_to_local_path,
const std::map<int, base::FilePath>& frame_routing_id_to_local_path);
- void OnSerializeAsMHTML(const FrameMsg_SerializeAsMHTML_Params& params);
void OnEnableViewSourceMode();
void OnSuppressFurtherDialogs();
void OnClearFocusedElement();
@@ -1142,11 +1150,11 @@
#endif
#endif
- // Callback scheduled from OnSerializeAsMHTML for when writing serialized
+ // Callback scheduled from SerializeAsMHTML for when writing serialized
// MHTML to file has been completed in the file thread.
void OnWriteMHTMLToDiskComplete(
- int job_id,
- std::set<std::string> serialized_resources_uri_digests,
+ SerializeAsMHTMLCallback callback,
+ std::unordered_set<std::string> serialized_resources_uri_digests,
base::TimeDelta main_thread_use_time,
MhtmlSaveStatus save_status);
@@ -1634,6 +1642,7 @@
frame_navigation_control_binding_;
mojo::AssociatedBinding<mojom::FullscreenVideoElementHandler>
fullscreen_binding_;
+ mojo::AssociatedBinding<mojom::MhtmlFileWriter> mhtml_file_writer_binding_;
// Only used when PerNavigationMojoInterface is enabled.
std::unique_ptr<NavigationClient> navigation_client_impl_;