| 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 <shlwapi.h> | 5 #include <shlwapi.h> |
| 6 #include <stddef.h> | 6 #include <stddef.h> |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/win/registry.h" | 10 #include "base/win/registry.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 REGSAM wow64_access) | 39 REGSAM wow64_access) |
| 40 : predefined_root_(predefined_root), | 40 : predefined_root_(predefined_root), |
| 41 path_(path), | 41 path_(path), |
| 42 wow64_access_(wow64_access), | 42 wow64_access_(wow64_access), |
| 43 key_created_(false) { | 43 key_created_(false) { |
| 44 DCHECK(wow64_access == 0 || | 44 DCHECK(wow64_access == 0 || |
| 45 wow64_access == KEY_WOW64_32KEY || | 45 wow64_access == KEY_WOW64_32KEY || |
| 46 wow64_access == KEY_WOW64_64KEY); | 46 wow64_access == KEY_WOW64_64KEY); |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool CreateRegKeyWorkItem::Do() { | 49 bool CreateRegKeyWorkItem::DoImpl() { |
| 50 if (!InitKeyList()) { | 50 if (!InitKeyList()) { |
| 51 // Nothing needs to be done here. | 51 // Nothing needs to be done here. |
| 52 VLOG(1) << "no key to create"; | 52 VLOG(1) << "no key to create"; |
| 53 return true; | 53 return true; |
| 54 } | 54 } |
| 55 | 55 |
| 56 RegKey key; | 56 RegKey key; |
| 57 std::wstring key_path; | 57 std::wstring key_path; |
| 58 | 58 |
| 59 // To create keys, we iterate from back to front. | 59 // To create keys, we iterate from back to front. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 83 } | 83 } |
| 84 } else { | 84 } else { |
| 85 LOG(ERROR) << "Failed to create " << key_path; | 85 LOG(ERROR) << "Failed to create " << key_path; |
| 86 return false; | 86 return false; |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 return true; | 90 return true; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void CreateRegKeyWorkItem::Rollback() { | 93 void CreateRegKeyWorkItem::RollbackImpl() { |
| 94 if (!key_created_) | 94 if (!key_created_) |
| 95 return; | 95 return; |
| 96 | 96 |
| 97 std::wstring key_path; | 97 std::wstring key_path; |
| 98 // To delete keys, we iterate from front to back. | 98 // To delete keys, we iterate from front to back. |
| 99 std::vector<std::wstring>::iterator itr; | 99 std::vector<std::wstring>::iterator itr; |
| 100 for (itr = key_list_.begin(); itr != key_list_.end(); ++itr) { | 100 for (itr = key_list_.begin(); itr != key_list_.end(); ++itr) { |
| 101 key_path.assign(*itr); | 101 key_path.assign(*itr); |
| 102 RegKey key(predefined_root_, L"", KEY_WRITE | wow64_access_); | 102 RegKey key(predefined_root_, L"", KEY_WRITE | wow64_access_); |
| 103 if (key.DeleteEmptyKey(key_path.c_str()) == ERROR_SUCCESS) { | 103 if (key.DeleteEmptyKey(key_path.c_str()) == ERROR_SUCCESS) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 123 | 123 |
| 124 do { | 124 do { |
| 125 key_list_.push_back(key_path); | 125 key_list_.push_back(key_path); |
| 126 // This is pure string operation so it does not matter whether the | 126 // This is pure string operation so it does not matter whether the |
| 127 // path is file path or registry path. | 127 // path is file path or registry path. |
| 128 UpOneDirectoryOrEmpty(&key_path); | 128 UpOneDirectoryOrEmpty(&key_path); |
| 129 } while (!key_path.empty()); | 129 } while (!key_path.empty()); |
| 130 | 130 |
| 131 return true; | 131 return true; |
| 132 } | 132 } |
| OLD | NEW |