diff options
author | waffles@chromium.org <waffles@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-28 19:41:55 +0000 |
---|---|---|
committer | waffles@chromium.org <waffles@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-28 19:41:55 +0000 |
commit | 94a481bf851cd8d2cc6d473ad924bfdfb9ed803d (patch) | |
tree | 6e9f3a3b6e5c78323e46bd358ce60f78a675950c /chrome/utility/chrome_content_utility_client.cc | |
parent | 3a4309fe2196fed76503ad71f6407f5b984eee58 (diff) | |
download | chromium_src-94a481bf851cd8d2cc6d473ad924bfdfb9ed803d.zip chromium_src-94a481bf851cd8d2cc6d473ad924bfdfb9ed803d.tar.gz chromium_src-94a481bf851cd8d2cc6d473ad924bfdfb9ed803d.tar.bz2 |
Use UtilityProcessHost to patch files.
Second part of a 2-part changelist.
The first part is https://codereview.chromium.org/25883006/
BUG=304879
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=259726
Review URL: https://codereview.chromium.org/25909005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260243 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/utility/chrome_content_utility_client.cc')
-rw-r--r-- | chrome/utility/chrome_content_utility_client.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc index bac49a3..f7274ed 100644 --- a/chrome/utility/chrome_content_utility_client.cc +++ b/chrome/utility/chrome_content_utility_client.cc @@ -31,6 +31,8 @@ #include "content/public/common/content_paths.h" #include "content/public/common/content_switches.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" @@ -371,6 +373,10 @@ bool ChromeContentUtilityClient::OnMessageReceived( OnGetPrinterCapsAndDefaults) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults, OnGetPrinterSemanticCapsAndDefaults) + IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileBsdiff, + OnPatchFileBsdiff) + IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileCourgette, + OnPatchFileCourgette) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, OnAnalyzeZipFileForDownloadProtection) @@ -814,6 +820,43 @@ void ChromeContentUtilityClient::OnGetPrinterSemanticCapsAndDefaults( 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. |