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::DoImpl() { | 41 bool UpdateActiveSetupVersionWorkItem::Do() { |
42 set_reg_value_work_item_.set_best_effort(best_effort()); | |
43 set_reg_value_work_item_.set_rollback_enabled(rollback_enabled()); | |
44 return set_reg_value_work_item_.Do(); | 42 return set_reg_value_work_item_.Do(); |
45 } | 43 } |
46 | 44 |
47 void UpdateActiveSetupVersionWorkItem::RollbackImpl() { | 45 void UpdateActiveSetupVersionWorkItem::Rollback() { |
48 set_reg_value_work_item_.Rollback(); | 46 set_reg_value_work_item_.Rollback(); |
49 } | 47 } |
50 | 48 |
51 base::string16 UpdateActiveSetupVersionWorkItem::GetUpdatedActiveSetupVersion( | 49 base::string16 UpdateActiveSetupVersionWorkItem::GetUpdatedActiveSetupVersion( |
52 const base::string16& existing_version) { | 50 const base::string16& existing_version) { |
53 std::vector<base::string16> version_components = base::SplitString( | 51 std::vector<base::string16> version_components = base::SplitString( |
54 existing_version, L",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 52 existing_version, L",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
55 | 53 |
56 // If |existing_version| was empty or otherwise corrupted, turn it into a | 54 // If |existing_version| was empty or otherwise corrupted, turn it into a |
57 // valid one. | 55 // valid one. |
58 if (version_components.size() != 4U) | 56 if (version_components.size() != 4U) |
59 version_components.assign(4U, L"0"); | 57 version_components.assign(4U, L"0"); |
60 | 58 |
61 // Unconditionally update the major version. | 59 // Unconditionally update the major version. |
62 version_components[MAJOR] = kActiveSetupMajorVersion; | 60 version_components[MAJOR] = kActiveSetupMajorVersion; |
63 | 61 |
64 if (operation_ == UPDATE_AND_BUMP_OS_UPGRADES_COMPONENT) { | 62 if (operation_ == UPDATE_AND_BUMP_OS_UPGRADES_COMPONENT) { |
65 uint32_t previous_value; | 63 uint32_t previous_value; |
66 if (!base::StringToUint(version_components[OS_UPGRADES], &previous_value)) { | 64 if (!base::StringToUint(version_components[OS_UPGRADES], &previous_value)) { |
67 LOG(WARNING) << "Couldn't process previous OS_UPGRADES Active Setup " | 65 LOG(WARNING) << "Couldn't process previous OS_UPGRADES Active Setup " |
68 "version component: " << version_components[OS_UPGRADES]; | 66 "version component: " << version_components[OS_UPGRADES]; |
69 previous_value = 0; | 67 previous_value = 0; |
70 } | 68 } |
71 version_components[OS_UPGRADES] = base::UintToString16(previous_value + 1); | 69 version_components[OS_UPGRADES] = base::UintToString16(previous_value + 1); |
72 } | 70 } |
73 | 71 |
74 return base::JoinString(version_components, L","); | 72 return base::JoinString(version_components, L","); |
75 } | 73 } |
OLD | NEW |