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

Unified Diff: chrome/utility/chrome_content_utility_client.cc

Issue 2632143002: Convert utility process out-of-process file patching IPC to mojo (Closed)
Patch Set: Reupload to sync to tip. Try landing again. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/utility/chrome_content_utility_client.cc
diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc
index 1788cba228515869f7973cdb99f0fbbdf4629482..8fcd114315a27d1afb5b2fbcc241732938c23e0f 100644
--- a/chrome/utility/chrome_content_utility_client.cc
+++ b/chrome/utility/chrome_content_utility_client.cc
@@ -14,6 +14,7 @@
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/common/chrome_utility_messages.h"
+#include "chrome/common/file_patcher.mojom.h"
#include "chrome/common/safe_browsing/zip_analyzer.h"
#include "chrome/common/safe_browsing/zip_analyzer_results.h"
#include "chrome/utility/chrome_content_utility_ipc_whitelist.h"
@@ -64,6 +65,7 @@
namespace {
+#if defined(OS_CHROMEOS) || defined(FULL_SAFE_BROWSING)
bool Send(IPC::Message* message) {
return content::UtilityThread::Get()->Send(message);
}
@@ -71,6 +73,40 @@ bool Send(IPC::Message* message) {
void ReleaseProcessIfNeeded() {
content::UtilityThread::Get()->ReleaseProcessIfNeeded();
}
+#endif // defined(OS_CHROMEOS) || defined(FULL_SAFE_BROWSING)
+
+class FilePatcherImpl : public chrome::mojom::FilePatcher {
+ public:
+ FilePatcherImpl() = default;
+ ~FilePatcherImpl() override = default;
+
+ static void Create(chrome::mojom::FilePatcherRequest request) {
+ mojo::MakeStrongBinding(base::MakeUnique<FilePatcherImpl>(),
+ std::move(request));
+ }
+
+ private:
+ // chrome::mojom::FilePatcher:
+ void PatchFileBsdiff(base::File input_file,
+ base::File patch_file,
+ base::File output_file,
+ const PatchFileBsdiffCallback& callback) override {
+ const int patch_result_status = bsdiff::ApplyBinaryPatch(
+ std::move(input_file), std::move(patch_file), std::move(output_file));
+ callback.Run(patch_result_status);
+ }
+
+ void PatchFileCourgette(base::File input_file,
+ base::File patch_file,
+ base::File output_file,
+ const PatchFileCourgetteCallback& callback) override {
+ const int patch_result_status = courgette::ApplyEnsemblePatch(
+ std::move(input_file), std::move(patch_file), std::move(output_file));
+ callback.Run(patch_result_status);
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(FilePatcherImpl);
+};
#if !defined(OS_ANDROID)
void CreateProxyResolverFactory(
@@ -156,10 +192,6 @@ bool ChromeContentUtilityClient::OnMessageReceived(
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ChromeContentUtilityClient, message)
- IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileBsdiff,
- OnPatchFileBsdiff)
- IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileCourgette,
- OnPatchFileCourgette)
#if defined(FULL_SAFE_BROWSING)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection,
OnAnalyzeZipFileForDownloadProtection)
@@ -205,6 +237,7 @@ void ChromeContentUtilityClient::ExposeInterfacesToBrowser(
if (running_elevated)
return;
+ registry->AddInterface(base::Bind(&FilePatcherImpl::Create));
#if !defined(OS_ANDROID)
registry->AddInterface<net::interfaces::ProxyResolverFactory>(
base::Bind(CreateProxyResolverFactory));
@@ -269,30 +302,6 @@ void ChromeContentUtilityClient::OnCreateZipFile(
}
#endif // defined(OS_CHROMEOS)
-void ChromeContentUtilityClient::OnPatchFileBsdiff(
- const IPC::PlatformFileForTransit& input_file,
- const IPC::PlatformFileForTransit& patch_file,
- const IPC::PlatformFileForTransit& output_file) {
- const int patch_status = bsdiff::ApplyBinaryPatch(
- IPC::PlatformFileForTransitToFile(input_file),
- IPC::PlatformFileForTransitToFile(patch_file),
- IPC::PlatformFileForTransitToFile(output_file));
- Send(new ChromeUtilityHostMsg_PatchFile_Finished(patch_status));
- ReleaseProcessIfNeeded();
-}
-
-void ChromeContentUtilityClient::OnPatchFileCourgette(
- const IPC::PlatformFileForTransit& input_file,
- const IPC::PlatformFileForTransit& patch_file,
- const IPC::PlatformFileForTransit& output_file) {
- const int patch_status = courgette::ApplyEnsemblePatch(
- IPC::PlatformFileForTransitToFile(input_file),
- IPC::PlatformFileForTransitToFile(patch_file),
- IPC::PlatformFileForTransitToFile(output_file));
- Send(new ChromeUtilityHostMsg_PatchFile_Finished(patch_status));
- ReleaseProcessIfNeeded();
-}
-
#if defined(FULL_SAFE_BROWSING)
void ChromeContentUtilityClient::OnAnalyzeZipFileForDownloadProtection(
const IPC::PlatformFileForTransit& zip_file,
« no previous file with comments | « chrome/test/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698