| OLD | NEW |
| 1 // Copyright (c) 2011 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. | 5 // This file declares util functions for setup project. |
| 6 | 6 |
| 7 #ifndef CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ | 7 #ifndef CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ |
| 8 #define CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ | 8 #define CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ |
| 9 #pragma once | 9 #pragma once |
| 10 | 10 |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/version.h" | 12 #include "base/version.h" |
| 13 #include "base/win/scoped_handle.h" | |
| 14 #include "chrome/installer/util/install_util.h" | |
| 15 | 13 |
| 16 namespace installer { | 14 namespace installer { |
| 17 | 15 |
| 18 class InstallerState; | 16 class InstallerState; |
| 19 | 17 |
| 20 // Apply a diff patch to source file. First tries to apply it using courgette | 18 // Apply a diff patch to source file. First tries to apply it using courgette |
| 21 // since it checks for courgette header and fails quickly. If that fails | 19 // since it checks for courgette header and fails quickly. If that fails |
| 22 // tries to apply the patch using regular bsdiff. Returns status code. | 20 // tries to apply the patch using regular bsdiff. Returns status code. |
| 23 // The installer stage is updated if |installer_state| is non-NULL. | 21 // The installer stage is updated if |installer_state| is non-NULL. |
| 24 int ApplyDiffPatch(const FilePath& src, | 22 int ApplyDiffPatch(const FilePath& src, |
| 25 const FilePath& patch, | 23 const FilePath& patch, |
| 26 const FilePath& dest, | 24 const FilePath& dest, |
| 27 const InstallerState* installer_state); | 25 const InstallerState* installer_state); |
| 28 | 26 |
| 29 // Find the version of Chrome from an install source directory. | 27 // Find the version of Chrome from an install source directory. |
| 30 // Chrome_path should contain at least one version folder. | 28 // Chrome_path should contain at least one version folder. |
| 31 // Returns the maximum version found or NULL if no version is found. | 29 // Returns the maximum version found or NULL if no version is found. |
| 32 Version* GetMaxVersionFromArchiveDir(const FilePath& chrome_path); | 30 Version* GetMaxVersionFromArchiveDir(const FilePath& chrome_path); |
| 33 | 31 |
| 34 // Spawns a new process that waits for a specified amount of time before | 32 // Spawns a new process that waits for a specified amount of time before |
| 35 // attempting to delete |path|. This is useful for setup to delete the | 33 // attempting to delete |path|. This is useful for setup to delete the |
| 36 // currently running executable or a file that we cannot close right away but | 34 // currently running executable or a file that we cannot close right away but |
| 37 // estimate that it will be possible after some period of time. | 35 // estimate that it will be possible after some period of time. |
| 38 // Returns true if a new process was started, false otherwise. Note that | 36 // Returns true if a new process was started, false otherwise. Note that |
| 39 // given the nature of this function, it is not possible to know if the | 37 // given the nature of this function, it is not possible to know if the |
| 40 // delete operation itself succeeded. | 38 // delete operation itself succeeded. |
| 41 bool DeleteFileFromTempProcess(const FilePath& path, | 39 bool DeleteFileFromTempProcess(const FilePath& path, |
| 42 uint32 delay_before_delete_ms); | 40 uint32 delay_before_delete_ms); |
| 43 | 41 |
| 44 // A predicate that compares the program portion of a command line with a given | |
| 45 // file path. First, the file paths are compared directly. If they do not | |
| 46 // match, the filesystem is consulted to determine if the paths reference the | |
| 47 // same file. | |
| 48 class ProgramCompare : public InstallUtil::RegistryValuePredicate { | |
| 49 public: | |
| 50 explicit ProgramCompare(const FilePath& path_to_match); | |
| 51 virtual ~ProgramCompare(); | |
| 52 virtual bool Evaluate(const std::wstring& value) const OVERRIDE; | |
| 53 | |
| 54 protected: | |
| 55 static bool OpenForInfo(const FilePath& path, | |
| 56 base::win::ScopedHandle* handle); | |
| 57 static bool GetInfo(const base::win::ScopedHandle& handle, | |
| 58 BY_HANDLE_FILE_INFORMATION* info); | |
| 59 | |
| 60 FilePath path_to_match_; | |
| 61 base::win::ScopedHandle file_handle_; | |
| 62 BY_HANDLE_FILE_INFORMATION file_info_; | |
| 63 | |
| 64 private: | |
| 65 DISALLOW_COPY_AND_ASSIGN(ProgramCompare); | |
| 66 }; // class ProgramCompare | |
| 67 | |
| 68 } // namespace installer | 42 } // namespace installer |
| 69 | 43 |
| 70 #endif // CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ | 44 #endif // CHROME_INSTALLER_SETUP_SETUP_UTIL_H_ |
| OLD | NEW |