OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/util/set_reg_value_work_item.h" | 5 #include "chrome/installer/util/set_reg_value_work_item.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/registry.h" | 8 #include "base/win/registry.h" |
9 #include "chrome/installer/util/logging_installer.h" | 9 #include "chrome/installer/util/logging_installer.h" |
10 | 10 |
11 SetRegValueWorkItem::~SetRegValueWorkItem() { | 11 SetRegValueWorkItem::~SetRegValueWorkItem() { |
12 } | 12 } |
13 | 13 |
14 SetRegValueWorkItem::SetRegValueWorkItem(HKEY predefined_root, | 14 SetRegValueWorkItem::SetRegValueWorkItem(HKEY predefined_root, |
15 const std::wstring& key_path, | 15 const std::wstring& key_path, |
16 const std::wstring& value_name, | 16 const std::wstring& value_name, |
17 const std::wstring& value_data, | 17 const std::wstring& value_data, |
18 bool overwrite) | 18 bool overwrite) |
(...skipping 23 matching lines...) Expand all Loading... |
42 previous_value_dword_(0) { | 42 previous_value_dword_(0) { |
43 } | 43 } |
44 | 44 |
45 bool SetRegValueWorkItem::Do() { | 45 bool SetRegValueWorkItem::Do() { |
46 if (status_ != SET_VALUE) { | 46 if (status_ != SET_VALUE) { |
47 // we already did something. | 47 // we already did something. |
48 LOG(ERROR) << "multiple calls to Do()"; | 48 LOG(ERROR) << "multiple calls to Do()"; |
49 return false; | 49 return false; |
50 } | 50 } |
51 | 51 |
52 RegKey key; | 52 base::win::RegKey key; |
53 if (!key.Open(predefined_root_, key_path_.c_str(), | 53 if (!key.Open(predefined_root_, key_path_.c_str(), |
54 KEY_READ | KEY_SET_VALUE)) { | 54 KEY_READ | KEY_SET_VALUE)) { |
55 LOG(ERROR) << "can not open " << key_path_; | 55 LOG(ERROR) << "can not open " << key_path_; |
56 status_ = VALUE_UNCHANGED; | 56 status_ = VALUE_UNCHANGED; |
57 return false; | 57 return false; |
58 } | 58 } |
59 | 59 |
60 bool result = false; | 60 bool result = false; |
61 if (key.ValueExists(value_name_.c_str())) { | 61 if (key.ValueExists(value_name_.c_str())) { |
62 if (overwrite_) { | 62 if (overwrite_) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 void SetRegValueWorkItem::Rollback() { | 114 void SetRegValueWorkItem::Rollback() { |
115 if (status_ == SET_VALUE || status_ == VALUE_ROLL_BACK) | 115 if (status_ == SET_VALUE || status_ == VALUE_ROLL_BACK) |
116 return; | 116 return; |
117 | 117 |
118 if (status_ == VALUE_UNCHANGED) { | 118 if (status_ == VALUE_UNCHANGED) { |
119 status_ = VALUE_ROLL_BACK; | 119 status_ = VALUE_ROLL_BACK; |
120 LOG(INFO) << "rollback: setting unchanged, nothing to do"; | 120 LOG(INFO) << "rollback: setting unchanged, nothing to do"; |
121 return; | 121 return; |
122 } | 122 } |
123 | 123 |
124 RegKey key; | 124 base::win::RegKey key; |
125 if (!key.Open(predefined_root_, key_path_.c_str(), | 125 if (!key.Open(predefined_root_, key_path_.c_str(), |
126 KEY_READ | KEY_SET_VALUE)) { | 126 KEY_READ | KEY_SET_VALUE)) { |
127 status_ = VALUE_ROLL_BACK; | 127 status_ = VALUE_ROLL_BACK; |
128 LOG(INFO) << "rollback: can not open " << key_path_; | 128 LOG(INFO) << "rollback: can not open " << key_path_; |
129 return; | 129 return; |
130 } | 130 } |
131 | 131 |
132 std::wstring result_str(L" failed"); | 132 std::wstring result_str(L" failed"); |
133 if (status_ == NEW_VALUE_CREATED) { | 133 if (status_ == NEW_VALUE_CREATED) { |
134 if (key.DeleteValue(value_name_.c_str())) | 134 if (key.DeleteValue(value_name_.c_str())) |
(...skipping 12 matching lines...) Expand all Loading... |
147 result_str.assign(L" succeeded"); | 147 result_str.assign(L" succeeded"); |
148 LOG(INFO) << "rollback: restoring " << value_name_ << result_str; | 148 LOG(INFO) << "rollback: restoring " << value_name_ << result_str; |
149 } else { | 149 } else { |
150 // Not reached. | 150 // Not reached. |
151 } | 151 } |
152 | 152 |
153 status_ = VALUE_ROLL_BACK; | 153 status_ = VALUE_ROLL_BACK; |
154 key.Close(); | 154 key.Close(); |
155 return; | 155 return; |
156 } | 156 } |
OLD | NEW |