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

Unified Diff: chrome/utility/chrome_content_utility_client.cc

Issue 25909005: Use UtilityProcessHost to patch files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nonblocking
Patch Set: Rebase to LKGR/248226 Created 6 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
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 9c883f5161fb9b962c82f314a635035691fdaf93..0c6854a5cf3493db661afcbe53fe670965a80ee7 100644
--- a/chrome/utility/chrome_content_utility_client.cc
+++ b/chrome/utility/chrome_content_utility_client.cc
@@ -28,6 +28,8 @@
#include "content/public/child/image_decoder_utils.h"
#include "content/public/common/content_paths.h"
#include "content/public/utility/utility_thread.h"
+#include "courgette/courgette.h"
+#include "courgette/third_party/bsdiff.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest.h"
#include "media/base/media.h"
@@ -348,6 +350,10 @@ bool ChromeContentUtilityClient::OnMessageReceived(
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults,
OnGetPrinterCapsAndDefaults)
+ IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileBsdiff,
+ OnPatchFileBsdiff)
+ IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileCourgette,
+ OnPatchFileCourgette)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection,
OnAnalyzeZipFileForDownloadProtection)
@@ -747,6 +753,43 @@ void ChromeContentUtilityClient::OnGetPrinterCapsAndDefaults(
ReleaseProcessIfNeeded();
}
+void ChromeContentUtilityClient::OnPatchFileBsdiff(
+ const base::FilePath& input_file,
+ const base::FilePath& patch_file,
+ const base::FilePath& output_file) {
+ if (input_file.empty() || patch_file.empty() || output_file.empty()) {
+ Send(new ChromeUtilityHostMsg_PatchFile_Failed(-1));
+ } else {
+ const int patch_status = courgette::ApplyBinaryPatch(input_file,
+ patch_file,
+ output_file);
+ if (patch_status != courgette::OK)
+ Send(new ChromeUtilityHostMsg_PatchFile_Failed(patch_status));
+ else
+ Send(new ChromeUtilityHostMsg_PatchFile_Succeeded());
+ }
+ ReleaseProcessIfNeeded();
+}
+
+void ChromeContentUtilityClient::OnPatchFileCourgette(
+ const base::FilePath& input_file,
+ const base::FilePath& patch_file,
+ const base::FilePath& output_file) {
+ if (input_file.empty() || patch_file.empty() || output_file.empty()) {
+ Send(new ChromeUtilityHostMsg_PatchFile_Failed(-1));
+ } else {
+ const int patch_status = courgette::ApplyEnsemblePatch(
+ input_file.value().c_str(),
+ patch_file.value().c_str(),
+ output_file.value().c_str());
+ if (patch_status != courgette::C_OK)
+ Send(new ChromeUtilityHostMsg_PatchFile_Failed(patch_status));
+ else
+ Send(new ChromeUtilityHostMsg_PatchFile_Succeeded());
+ }
+ ReleaseProcessIfNeeded();
+}
+
void ChromeContentUtilityClient::OnStartupPing() {
Send(new ChromeUtilityHostMsg_ProcessStarted);
// Don't release the process, we assume further messages are on the way.

Powered by Google App Engine
This is Rietveld 408576698