| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // This file declares util functions for setup project. It also declares a | 5 // This file declares util functions for setup project. |
| 6 // few functions that the Chrome component updater uses for patching binary | |
| 7 // deltas. | |
| 8 | 6 |
| 9 #ifndef CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ | 7 #ifndef CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ |
| 10 #define CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ | 8 #define CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ |
| 11 | 9 |
| 12 #include <windows.h> | 10 #include <windows.h> |
| 13 | 11 |
| 14 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 15 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 16 #include "base/win/scoped_handle.h" | 14 #include "base/win/scoped_handle.h" |
| 17 #include "chrome/installer/util/browser_distribution.h" | 15 #include "chrome/installer/util/browser_distribution.h" |
| 18 #include "chrome/installer/util/util_constants.h" | 16 #include "chrome/installer/util/util_constants.h" |
| 19 | 17 |
| 20 class CommandLine; | 18 class CommandLine; |
| 21 | 19 |
| 22 namespace base { | 20 namespace base { |
| 23 class FilePath; | 21 class FilePath; |
| 24 class Version; | 22 class Version; |
| 25 } | 23 } |
| 26 | 24 |
| 27 namespace installer { | 25 namespace installer { |
| 28 | 26 |
| 29 class InstallationState; | 27 class InstallationState; |
| 30 class InstallerState; | 28 class InstallerState; |
| 31 class ProductState; | 29 class ProductState; |
| 32 | 30 |
| 33 // Apply a diff patch to source file. First tries to apply it using Courgette | 31 // Apply a diff patch to source file. First tries to apply it using courgette |
| 34 // since it checks for Courgette header and fails quickly. If that fails | 32 // since it checks for courgette header and fails quickly. If that fails |
| 35 // tries to apply the patch using regular bsdiff. Returns status code as | 33 // tries to apply the patch using regular bsdiff. Returns status code. |
| 36 // defined by the bsdiff code (see third_party/bspatch/mbspatch.h for the | |
| 37 // definitions of the codes). | |
| 38 // The installer stage is updated if |installer_state| is non-NULL. | 34 // The installer stage is updated if |installer_state| is non-NULL. |
| 39 int ApplyDiffPatch(const base::FilePath& src, | 35 int ApplyDiffPatch(const base::FilePath& src, |
| 40 const base::FilePath& patch, | 36 const base::FilePath& patch, |
| 41 const base::FilePath& dest, | 37 const base::FilePath& dest, |
| 42 const InstallerState* installer_state); | 38 const InstallerState* installer_state); |
| 43 | 39 |
| 44 // Applies a patch file to source file using Courgette. Returns 0 in case of | |
| 45 // success. In case of errors, it returns kCourgetteErrorOffset + a Courgette | |
| 46 // status code, as defined in courgette/courgette.h | |
| 47 int CourgettePatchFiles(const base::FilePath& src, | |
| 48 const base::FilePath& patch, | |
| 49 const base::FilePath& dest); | |
| 50 | |
| 51 // Applies a patch file to source file using bsdiff. This function uses | |
| 52 // Courgette's flavor of bsdiff. Returns 0 in case of success, or | |
| 53 // kBsdiffErrorOffset + a bsdiff status code in case of errors. | |
| 54 // See courgette/third_party/bsdiff.h for details. | |
| 55 int BsdiffPatchFiles(const base::FilePath& src, | |
| 56 const base::FilePath& patch, | |
| 57 const base::FilePath& dest); | |
| 58 | |
| 59 // Find the version of Chrome from an install source directory. | 40 // Find the version of Chrome from an install source directory. |
| 60 // Chrome_path should contain at least one version folder. | 41 // Chrome_path should contain at least one version folder. |
| 61 // Returns the maximum version found or NULL if no version is found. | 42 // Returns the maximum version found or NULL if no version is found. |
| 62 Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path); | 43 Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path); |
| 63 | 44 |
| 64 // Spawns a new process that waits for a specified amount of time before | 45 // Spawns a new process that waits for a specified amount of time before |
| 65 // attempting to delete |path|. This is useful for setup to delete the | 46 // attempting to delete |path|. This is useful for setup to delete the |
| 66 // currently running executable or a file that we cannot close right away but | 47 // currently running executable or a file that we cannot close right away but |
| 67 // estimate that it will be possible after some period of time. | 48 // estimate that it will be possible after some period of time. |
| 68 // Returns true if a new process was started, false otherwise. Note that | 49 // Returns true if a new process was started, false otherwise. Note that |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // The previous state of the privilege this object is responsible for. As set | 111 // The previous state of the privilege this object is responsible for. As set |
| 131 // by AdjustTokenPrivileges() upon construction. | 112 // by AdjustTokenPrivileges() upon construction. |
| 132 TOKEN_PRIVILEGES previous_privileges_; | 113 TOKEN_PRIVILEGES previous_privileges_; |
| 133 | 114 |
| 134 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedTokenPrivilege); | 115 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedTokenPrivilege); |
| 135 }; | 116 }; |
| 136 | 117 |
| 137 } // namespace installer | 118 } // namespace installer |
| 138 | 119 |
| 139 #endif // CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ | 120 #endif // CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ |
| OLD | NEW |