| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/installer/setup/update_active_setup_version_work_item.h" | 5 #include "chrome/installer/setup/update_active_setup_version_work_item.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 HKEY_LOCAL_MACHINE, | 31 HKEY_LOCAL_MACHINE, |
| 32 active_setup_path, | 32 active_setup_path, |
| 33 WorkItem::kWow64Default, | 33 WorkItem::kWow64Default, |
| 34 L"Version", | 34 L"Version", |
| 35 base::Bind( | 35 base::Bind( |
| 36 &UpdateActiveSetupVersionWorkItem::GetUpdatedActiveSetupVersion, | 36 &UpdateActiveSetupVersionWorkItem::GetUpdatedActiveSetupVersion, |
| 37 base::Unretained(this))), | 37 base::Unretained(this))), |
| 38 operation_(operation) { | 38 operation_(operation) { |
| 39 } | 39 } |
| 40 | 40 |
| 41 bool UpdateActiveSetupVersionWorkItem::Do() { | 41 bool UpdateActiveSetupVersionWorkItem::DoImpl() { |
| 42 set_reg_value_work_item_.set_best_effort(best_effort()); |
| 43 set_reg_value_work_item_.set_rollback_enabled(rollback_enabled()); |
| 42 return set_reg_value_work_item_.Do(); | 44 return set_reg_value_work_item_.Do(); |
| 43 } | 45 } |
| 44 | 46 |
| 45 void UpdateActiveSetupVersionWorkItem::Rollback() { | 47 void UpdateActiveSetupVersionWorkItem::RollbackImpl() { |
| 46 set_reg_value_work_item_.Rollback(); | 48 set_reg_value_work_item_.Rollback(); |
| 47 } | 49 } |
| 48 | 50 |
| 49 base::string16 UpdateActiveSetupVersionWorkItem::GetUpdatedActiveSetupVersion( | 51 base::string16 UpdateActiveSetupVersionWorkItem::GetUpdatedActiveSetupVersion( |
| 50 const base::string16& existing_version) { | 52 const base::string16& existing_version) { |
| 51 std::vector<base::string16> version_components = base::SplitString( | 53 std::vector<base::string16> version_components = base::SplitString( |
| 52 existing_version, L",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 54 existing_version, L",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 53 | 55 |
| 54 // If |existing_version| was empty or otherwise corrupted, turn it into a | 56 // If |existing_version| was empty or otherwise corrupted, turn it into a |
| 55 // valid one. | 57 // valid one. |
| 56 if (version_components.size() != 4U) | 58 if (version_components.size() != 4U) |
| 57 version_components.assign(4U, L"0"); | 59 version_components.assign(4U, L"0"); |
| 58 | 60 |
| 59 // Unconditionally update the major version. | 61 // Unconditionally update the major version. |
| 60 version_components[MAJOR] = kActiveSetupMajorVersion; | 62 version_components[MAJOR] = kActiveSetupMajorVersion; |
| 61 | 63 |
| 62 if (operation_ == UPDATE_AND_BUMP_OS_UPGRADES_COMPONENT) { | 64 if (operation_ == UPDATE_AND_BUMP_OS_UPGRADES_COMPONENT) { |
| 63 uint32_t previous_value; | 65 uint32_t previous_value; |
| 64 if (!base::StringToUint(version_components[OS_UPGRADES], &previous_value)) { | 66 if (!base::StringToUint(version_components[OS_UPGRADES], &previous_value)) { |
| 65 LOG(WARNING) << "Couldn't process previous OS_UPGRADES Active Setup " | 67 LOG(WARNING) << "Couldn't process previous OS_UPGRADES Active Setup " |
| 66 "version component: " << version_components[OS_UPGRADES]; | 68 "version component: " << version_components[OS_UPGRADES]; |
| 67 previous_value = 0; | 69 previous_value = 0; |
| 68 } | 70 } |
| 69 version_components[OS_UPGRADES] = base::UintToString16(previous_value + 1); | 71 version_components[OS_UPGRADES] = base::UintToString16(previous_value + 1); |
| 70 } | 72 } |
| 71 | 73 |
| 72 return base::JoinString(version_components, L","); | 74 return base::JoinString(version_components, L","); |
| 73 } | 75 } |
| OLD | NEW |