| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "components/update_client/test_installer.h" | 5 #include "components/update_client/test_installer.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 55 } |
| 56 | 56 |
| 57 VersionedTestInstaller::~VersionedTestInstaller() { | 57 VersionedTestInstaller::~VersionedTestInstaller() { |
| 58 base::DeleteFile(install_directory_, true); | 58 base::DeleteFile(install_directory_, true); |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool VersionedTestInstaller::Install(const base::DictionaryValue& manifest, | 61 bool VersionedTestInstaller::Install(const base::DictionaryValue& manifest, |
| 62 const base::FilePath& unpack_path) { | 62 const base::FilePath& unpack_path) { |
| 63 std::string version_string; | 63 std::string version_string; |
| 64 manifest.GetStringASCII("version", &version_string); | 64 manifest.GetStringASCII("version", &version_string); |
| 65 Version version(version_string.c_str()); | 65 base::Version version(version_string.c_str()); |
| 66 | 66 |
| 67 base::FilePath path; | 67 base::FilePath path; |
| 68 path = install_directory_.AppendASCII(version.GetString()); | 68 path = install_directory_.AppendASCII(version.GetString()); |
| 69 base::CreateDirectory(path.DirName()); | 69 base::CreateDirectory(path.DirName()); |
| 70 if (!base::Move(unpack_path, path)) | 70 if (!base::Move(unpack_path, path)) |
| 71 return false; | 71 return false; |
| 72 current_version_ = version; | 72 current_version_ = version; |
| 73 ++install_count_; | 73 ++install_count_; |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 | 76 |
| 77 bool VersionedTestInstaller::GetInstalledFile(const std::string& file, | 77 bool VersionedTestInstaller::GetInstalledFile(const std::string& file, |
| 78 base::FilePath* installed_file) { | 78 base::FilePath* installed_file) { |
| 79 base::FilePath path; | 79 base::FilePath path; |
| 80 path = install_directory_.AppendASCII(current_version_.GetString()); | 80 path = install_directory_.AppendASCII(current_version_.GetString()); |
| 81 *installed_file = path.Append(base::FilePath::FromUTF8Unsafe(file)); | 81 *installed_file = path.Append(base::FilePath::FromUTF8Unsafe(file)); |
| 82 return true; | 82 return true; |
| 83 } | 83 } |
| 84 | 84 |
| 85 } // namespace update_client | 85 } // namespace update_client |
| OLD | NEW |