alternate_version_generator.h revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
18d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// Copyright (c) 2011 The Chromium Authors. All rights reserved.
28d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// Use of this source code is governed by a BSD-style license that can be
3391c59f0632df8db1c325da1d31d479b2eedce45Dmitry Shmidt// found in the LICENSE file.
48d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt//
5c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt// This file exposes the public interface to the mini_installer re-versioner.
6c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt
78d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifndef CHROME_INSTALLER_TEST_ALTERNATE_VERSION_GENERATOR_H_
88d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#define CHROME_INSTALLER_TEST_ALTERNATE_VERSION_GENERATOR_H_
98d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include <string>
118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtnamespace base {
138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtclass FilePath;
148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtclass Version;
158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
16f86232838cf712377867cb42417c1613ab5dc425Dmitry Shmidt
178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtnamespace upgrade_test {
188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtenum Direction {
2061d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt  PREVIOUS_VERSION,
218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt  NEXT_VERSION
228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt};
238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// Generates an alternate mini_installer.exe using the one indicated by
258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// |original_installer_path|, giving the new one a lower or higher version than
268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// the original and placing it in |target_path|.  Any previous file at
278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// |target_path| is clobbered.  Returns true on success.  |original_version| and
288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// |new_version|, when non-NULL, are given the original and new version numbers
298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// on success.
308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtbool GenerateAlternateVersion(const base::FilePath& original_installer_path,
3104949598a23f501be6eec21697465fd46a28840aDmitry Shmidt                              const base::FilePath& target_path,
32051af73b8f8014eff33330aead0f36944b3403e6Dmitry Shmidt                              Direction direction,
338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt                              std::wstring* original_version,
348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt                              std::wstring* new_version);
358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
361f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt// Given a path to a PEImage in |original_file|, copy that file to
378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// |target_file|, modifying the version of the copy according to |direction|.
388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// Any previous file at |target_file| is clobbered. Returns true on success.
398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// Note that |target_file| may still be mutated on failure.
408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtbool GenerateAlternatePEFileVersion(const base::FilePath& original_file,
411f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt                                    const base::FilePath& target_file,
421f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt                                    Direction direction);
4361d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt
4461d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt// Given a path to a PEImage in |original_file|, copy that file to
4561d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt// |target_file|, modifying the version of the copy according to |version|.
4661d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt// Any previous file at |target_file| is clobbered. Returns true on success.
471f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt// Note that |target_file| may still be mutated on failure.
4861d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidtbool GenerateSpecificPEFileVersion(const base::FilePath& original_file,
49391c59f0632df8db1c325da1d31d479b2eedce45Dmitry Shmidt                                   const base::FilePath& target_file,
508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt                                   const base::Version& version);
518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}  // namespace upgrade_test
538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif  // CHROME_INSTALLER_TEST_ALTERNATE_VERSION_GENERATOR_H_
558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt