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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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. |
| 190 class ProgramCompare : public RegistryValuePredicate { | 190 class ProgramCompare : public RegistryValuePredicate { |
| 191 public: | 191 public: |
| 192 explicit ProgramCompare(const base::FilePath& path_to_match); | 192 explicit ProgramCompare(const base::FilePath& path_to_match); |
| 193 ProgramCompare(const base::FilePath& path_to_match, | |
|
gab
2016/03/21 15:27:04
Add tests for new form.
fdoray
2016/03/21 15:44:29
Done.
| |
| 194 bool support_directories); | |
|
gab
2016/03/21 15:27:04
Prefer enum to bool (bool makes callsites obscure)
fdoray
2016/03/21 15:44:29
Done.
| |
| 195 | |
| 193 ~ProgramCompare() override; | 196 ~ProgramCompare() override; |
| 194 bool Evaluate(const base::string16& value) const override; | 197 bool Evaluate(const base::string16& value) const override; |
| 195 bool EvaluatePath(const base::FilePath& path) const; | 198 bool EvaluatePath(const base::FilePath& path) const; |
| 196 | 199 |
| 197 protected: | 200 protected: |
| 198 static bool OpenForInfo(const base::FilePath& path, base::File* file); | 201 static bool OpenForInfo(const base::FilePath& path, |
| 202 base::File* file, | |
| 203 bool support_directories); | |
| 199 static bool GetInfo(const base::File& file, | 204 static bool GetInfo(const base::File& file, |
| 200 BY_HANDLE_FILE_INFORMATION* info); | 205 BY_HANDLE_FILE_INFORMATION* info); |
| 201 | 206 |
| 202 base::FilePath path_to_match_; | 207 base::FilePath path_to_match_; |
| 203 base::File file_; | 208 base::File file_; |
| 204 BY_HANDLE_FILE_INFORMATION file_info_; | 209 BY_HANDLE_FILE_INFORMATION file_info_; |
| 210 bool support_directories_; | |
| 205 | 211 |
| 206 private: | 212 private: |
| 207 DISALLOW_COPY_AND_ASSIGN(ProgramCompare); | 213 DISALLOW_COPY_AND_ASSIGN(ProgramCompare); |
| 208 }; // class ProgramCompare | 214 }; // class ProgramCompare |
| 209 | 215 |
| 210 private: | 216 private: |
| 211 DISALLOW_COPY_AND_ASSIGN(InstallUtil); | 217 DISALLOW_COPY_AND_ASSIGN(InstallUtil); |
| 212 }; | 218 }; |
| 213 | 219 |
| 214 | 220 |
| 215 #endif // CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ | 221 #endif // CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ |
| OLD | NEW |