Chromium Code Reviews| 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 utility functions for the installer. The original reason | 5 // This file declares utility functions for the installer. The original reason |
| 6 // for putting these functions in installer\util library is so that we can | 6 // for putting these functions in installer\util library is so that we can |
| 7 // separate out the critical logic and write unit tests for it. | 7 // separate out the critical logic and write unit tests for it. |
| 8 | 8 |
| 9 #ifndef CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ | 9 #ifndef CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ |
| 10 #define CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ | 10 #define CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 static void ComposeCommandLine(const base::string16& program, | 179 static void ComposeCommandLine(const base::string16& program, |
| 180 const base::string16& arguments, | 180 const base::string16& arguments, |
| 181 base::CommandLine* command_line); | 181 base::CommandLine* command_line); |
| 182 | 182 |
| 183 // Returns a string in the form YYYYMMDD of the current date. | 183 // Returns a string in the form YYYYMMDD of the current date. |
| 184 static base::string16 GetCurrentDate(); | 184 static base::string16 GetCurrentDate(); |
| 185 | 185 |
| 186 // A predicate that compares the program portion of a command line with a | 186 // A predicate that compares the program portion of a command line with a |
| 187 // given file path. First, the file paths are compared directly. If they do | 187 // given file path. First, the file paths are compared directly. If they do |
| 188 // not match, the filesystem is consulted to determine if the paths reference | 188 // not match, the filesystem is consulted to determine if the paths reference |
| 189 // the same file. | 189 // the same file. |
|
gab
2016/03/21 19:28:13
This class' functionality is no longer specific to
| |
| 190 class ProgramCompare : public RegistryValuePredicate { | 190 class ProgramCompare : public RegistryValuePredicate { |
| 191 public: | 191 public: |
| 192 enum class ComparisonType { | |
| 193 // Evaluation compares existing files. | |
| 194 FILE, | |
| 195 // Evaluation compares existing files or directories. | |
| 196 FILE_OR_DIRECTORY, | |
| 197 }; | |
| 198 | |
| 199 // Constructs a ProgramCompare with FILE as ComparisonType. | |
| 192 explicit ProgramCompare(const base::FilePath& path_to_match); | 200 explicit ProgramCompare(const base::FilePath& path_to_match); |
| 201 | |
| 202 // Constructs a ProgramCompare with |comparison_type| as ComparisonType. | |
| 203 ProgramCompare(const base::FilePath& path_to_match, | |
| 204 ComparisonType comparison_type); | |
| 205 | |
| 193 ~ProgramCompare() override; | 206 ~ProgramCompare() override; |
| 194 bool Evaluate(const base::string16& value) const override; | 207 bool Evaluate(const base::string16& value) const override; |
| 195 bool EvaluatePath(const base::FilePath& path) const; | 208 bool EvaluatePath(const base::FilePath& path) const; |
| 196 | 209 |
| 197 protected: | 210 protected: |
| 198 static bool OpenForInfo(const base::FilePath& path, base::File* file); | 211 static bool OpenForInfo(const base::FilePath& path, |
| 212 base::File* file, | |
| 213 ComparisonType comparison_type); | |
| 199 static bool GetInfo(const base::File& file, | 214 static bool GetInfo(const base::File& file, |
| 200 BY_HANDLE_FILE_INFORMATION* info); | 215 BY_HANDLE_FILE_INFORMATION* info); |
| 201 | 216 |
| 202 base::FilePath path_to_match_; | 217 base::FilePath path_to_match_; |
| 203 base::File file_; | 218 base::File file_; |
| 204 BY_HANDLE_FILE_INFORMATION file_info_; | 219 BY_HANDLE_FILE_INFORMATION file_info_; |
| 220 ComparisonType comparison_type_; | |
| 205 | 221 |
| 206 private: | 222 private: |
| 207 DISALLOW_COPY_AND_ASSIGN(ProgramCompare); | 223 DISALLOW_COPY_AND_ASSIGN(ProgramCompare); |
| 208 }; // class ProgramCompare | 224 }; // class ProgramCompare |
| 209 | 225 |
| 210 private: | 226 private: |
| 211 DISALLOW_COPY_AND_ASSIGN(InstallUtil); | 227 DISALLOW_COPY_AND_ASSIGN(InstallUtil); |
| 212 }; | 228 }; |
| 213 | 229 |
| 214 | 230 |
| 215 #endif // CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ | 231 #endif // CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ |
| OLD | NEW |