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

Unified Diff: chrome/browser/component_updater/component_patcher_win.cc

Issue 15908002: Differential updates for components. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: really removing the lzma files this time. Created 7 years, 6 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/browser/component_updater/component_patcher_win.cc
diff --git a/chrome/browser/component_updater/component_patcher_win.cc b/chrome/browser/component_updater/component_patcher_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1e28c891b9ecd423c0403066130f776a753239c3
--- /dev/null
+++ b/chrome/browser/component_updater/component_patcher_win.cc
@@ -0,0 +1,97 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/component_updater/component_patcher_win.h"
+
+#include <string>
+
+#include "base/base_paths.h"
+#include "base/command_line.h"
+#include "base/file_util.h"
+#include "base/path_service.h"
+#include "base/process_util.h"
+#include "base/string_util.h"
+#include "chrome/installer/util/util_constants.h"
+
+namespace {
+
+std::string PatchTypeToCommandLineSwitch(PatchType patch_type) {
+ if (patch_type == kPatchTypeCourgette)
+ return std::string(installer::switches::kCourgette);
+ else if (patch_type == kPatchTypeBsdiff)
+ return std::string(installer::switches::kBsdiff);
+ else
+ return std::string();
+}
+
+// Finds the path to the setup.exe. First, it looks for the program in the
+// "installer" directory. If the program is not found there, it tries to find it
+// in the directory where chrome.dll. Returns the path to the setup.exe, if the
cpu_(ooo_6.6-7.5) 2013/06/14 23:25:28 where chrome.dll lives?
waffles 2013/06/15 00:01:37 Done; will be in the next patchset.
+// path exists, otherwise it returns an an empty path.
+base::FilePath FindSetupProgram() {
+ base::FilePath exe_dir;
+ if (!PathService::Get(base::DIR_MODULE, &exe_dir))
+ return base::FilePath();
+
+ const std::string installer_dir(WideToASCII(installer::kInstallerDir));
+ const std::string setup_exe(WideToASCII(installer::kSetupExe));
+
+ base::FilePath setup_path = exe_dir;
+ setup_path = setup_path.AppendASCII(installer_dir);
+ setup_path = setup_path.AppendASCII(setup_exe);
+ if (file_util::PathExists(setup_path))
+ return setup_path;
+
+ setup_path = exe_dir;
+ setup_path = setup_path.AppendASCII(setup_exe);
+ if (file_util::PathExists(setup_path))
+ return setup_path;
+
+ return base::FilePath();
+}
+
+} // namespace
+
+// Applies the patch to the input file. Returns kNone if the pacth was
robertshield 2013/06/17 17:47:00 patch
Sorin Jianu 2013/06/17 22:21:09 Done.
+// successfully applied, kDeltaOperationFailure if the patch operation
+// encountered errors, and kDeltaPatchProcessFailure if there was an error
+// when running the patch code out of process. In the error case, detailed error
+// information could be returned in the error parameter.
+ComponentUnpacker::Error ComponentPatcherWin::Patch(
+ PatchType patch_type,
+ const base::FilePath& input_file,
+ const base::FilePath& patch_file,
+ const base::FilePath& output_file,
+ int* error) {
+ *error = 0;
+
+ const base::FilePath exe_path = FindSetupProgram();
+ if (exe_path.empty())
+ return ComponentUnpacker::kDeltaPatchProcessFailure;
+
+ const std::string patch_type_str(PatchTypeToCommandLineSwitch(patch_type));
+
+ CommandLine cl(CommandLine::NO_PROGRAM);
+ cl.AppendSwitchASCII(installer::switches::kPatch, patch_type_str.c_str());
+ cl.AppendSwitchPath(installer::switches::kInputFile, input_file);
+ cl.AppendSwitchPath(installer::switches::kPatchFile, patch_file);
+ cl.AppendSwitchPath(installer::switches::kOutputFile, output_file);
+
+ base::LaunchOptions launch_options;
+ launch_options.wait = true;
+ launch_options.start_hidden = true;
cpu_(ooo_6.6-7.5) 2013/06/14 23:25:28 setup does not launch other process while doing th
Sorin Jianu 2013/06/15 00:10:44 setup.exe is the only process we create here, no o
+ CommandLine setup_path(exe_path);
+ setup_path.AppendArguments(cl, false);
+
+ base::ProcessHandle ph;
+ int exit_code = 0;
+ if (!base::LaunchProcess(setup_path, launch_options, &ph) ||
+ !base::WaitForExitCode(ph, &exit_code))
+ return ComponentUnpacker::kDeltaPatchProcessFailure;
+
cpu_(ooo_6.6-7.5) 2013/06/14 23:25:28 when do we close this process handle |ph| ?
Sorin Jianu 2013/06/15 00:10:44 WaitForExitCode closes the handle.
+ *error = exit_code;
+ return *error ? ComponentUnpacker::kDeltaOperationFailure :
+ ComponentUnpacker::kNone;
+}
+

Powered by Google App Engine
This is Rietveld 408576698