OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/test/test_reg_util_win.h" | 5 #include "base/test/test_reg_util_win.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 void DeleteStaleTestKeys(const base::Time& now, | 21 void DeleteStaleTestKeys(const base::Time& now, |
22 const base::string16& test_key_root) { | 22 const base::string16& test_key_root) { |
23 base::win::RegKey test_root_key; | 23 base::win::RegKey test_root_key; |
24 if (test_root_key.Open(HKEY_CURRENT_USER, | 24 if (test_root_key.Open(HKEY_CURRENT_USER, |
25 test_key_root.c_str(), | 25 test_key_root.c_str(), |
26 KEY_ALL_ACCESS) != ERROR_SUCCESS) { | 26 KEY_ALL_ACCESS) != ERROR_SUCCESS) { |
27 // This will occur on first-run, but is harmless. | 27 // This will occur on first-run, but is harmless. |
28 return; | 28 return; |
29 } | 29 } |
30 | 30 |
31 base::win::RegistryKeyIterator iterator_test_root_key(HKEY_CURRENT_USER, | 31 base::win::RegistryKeyIterator iterator_test_root_key( |
32 test_key_root.c_str()); | 32 HKEY_CURRENT_USER, test_key_root.c_str(), 0); |
33 for (; iterator_test_root_key.Valid(); ++iterator_test_root_key) { | 33 for (; iterator_test_root_key.Valid(); ++iterator_test_root_key) { |
34 base::string16 key_name = iterator_test_root_key.Name(); | 34 base::string16 key_name = iterator_test_root_key.Name(); |
35 std::vector<base::string16> tokens; | 35 std::vector<base::string16> tokens; |
36 if (!Tokenize(key_name, base::string16(kTimestampDelimiter), &tokens)) | 36 if (!Tokenize(key_name, base::string16(kTimestampDelimiter), &tokens)) |
37 continue; | 37 continue; |
38 int64 key_name_as_number = 0; | 38 int64 key_name_as_number = 0; |
39 | 39 |
40 if (!base::StringToInt64(tokens[0], &key_name_as_number)) { | 40 if (!base::StringToInt64(tokens[0], &key_name_as_number)) { |
41 test_root_key.DeleteKey(key_name.c_str()); | 41 test_root_key.DeleteKey(key_name.c_str()); |
42 continue; | 42 continue; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 base::string16 key_path = GenerateTempKeyPath(test_key_root_, timestamp_); | 96 base::string16 key_path = GenerateTempKeyPath(test_key_root_, timestamp_); |
97 overrides_.push_back(new ScopedRegistryKeyOverride(override, key_path)); | 97 overrides_.push_back(new ScopedRegistryKeyOverride(override, key_path)); |
98 } | 98 } |
99 | 99 |
100 base::string16 GenerateTempKeyPath() { | 100 base::string16 GenerateTempKeyPath() { |
101 return GenerateTempKeyPath(base::string16(kTempTestKeyPath), | 101 return GenerateTempKeyPath(base::string16(kTempTestKeyPath), |
102 base::Time::Now()); | 102 base::Time::Now()); |
103 } | 103 } |
104 | 104 |
105 } // namespace registry_util | 105 } // namespace registry_util |
OLD | NEW |