Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Side by Side Diff: base/test/test_reg_util_win.cc

Issue 1197243004: Replace some Tokenize calls with SplitString. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/strings/string_util.h ('k') | base/trace_event/trace_event_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_split.h"
10 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace registry_util { 15 namespace registry_util {
15 16
16 namespace { 17 namespace {
17 18
18 const wchar_t kTimestampDelimiter[] = L"$"; 19 const wchar_t kTimestampDelimiter[] = L"$";
19 const wchar_t kTempTestKeyPath[] = L"Software\\Chromium\\TempTestKeys"; 20 const wchar_t kTempTestKeyPath[] = L"Software\\Chromium\\TempTestKeys";
20 21
21 void DeleteStaleTestKeys(const base::Time& now, 22 void DeleteStaleTestKeys(const base::Time& now,
22 const base::string16& test_key_root) { 23 const base::string16& test_key_root) {
23 base::win::RegKey test_root_key; 24 base::win::RegKey test_root_key;
24 if (test_root_key.Open(HKEY_CURRENT_USER, 25 if (test_root_key.Open(HKEY_CURRENT_USER,
25 test_key_root.c_str(), 26 test_key_root.c_str(),
26 KEY_ALL_ACCESS) != ERROR_SUCCESS) { 27 KEY_ALL_ACCESS) != ERROR_SUCCESS) {
27 // This will occur on first-run, but is harmless. 28 // This will occur on first-run, but is harmless.
28 return; 29 return;
29 } 30 }
30 31
31 base::win::RegistryKeyIterator iterator_test_root_key(HKEY_CURRENT_USER, 32 base::win::RegistryKeyIterator iterator_test_root_key(HKEY_CURRENT_USER,
32 test_key_root.c_str()); 33 test_key_root.c_str());
33 for (; iterator_test_root_key.Valid(); ++iterator_test_root_key) { 34 for (; iterator_test_root_key.Valid(); ++iterator_test_root_key) {
34 base::string16 key_name = iterator_test_root_key.Name(); 35 base::string16 key_name = iterator_test_root_key.Name();
35 std::vector<base::string16> tokens; 36 std::vector<base::string16> tokens = base::SplitString(
36 if (!Tokenize(key_name, base::string16(kTimestampDelimiter), &tokens)) 37 key_name, kTimestampDelimiter, base::KEEP_WHITESPACE,
38 base::SPLIT_WANT_NONEMPTY);
39 if (tokens.empty())
37 continue; 40 continue;
38 int64 key_name_as_number = 0; 41 int64 key_name_as_number = 0;
39 42
40 if (!base::StringToInt64(tokens[0], &key_name_as_number)) { 43 if (!base::StringToInt64(tokens[0], &key_name_as_number)) {
41 test_root_key.DeleteKey(key_name.c_str()); 44 test_root_key.DeleteKey(key_name.c_str());
42 continue; 45 continue;
43 } 46 }
44 47
45 base::Time key_time = base::Time::FromInternalValue(key_name_as_number); 48 base::Time key_time = base::Time::FromInternalValue(key_name_as_number);
46 base::TimeDelta age = now - key_time; 49 base::TimeDelta age = now - key_time;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 base::string16 key_path = GenerateTempKeyPath(test_key_root_, timestamp_); 99 base::string16 key_path = GenerateTempKeyPath(test_key_root_, timestamp_);
97 overrides_.push_back(new ScopedRegistryKeyOverride(override, key_path)); 100 overrides_.push_back(new ScopedRegistryKeyOverride(override, key_path));
98 } 101 }
99 102
100 base::string16 GenerateTempKeyPath() { 103 base::string16 GenerateTempKeyPath() {
101 return GenerateTempKeyPath(base::string16(kTempTestKeyPath), 104 return GenerateTempKeyPath(base::string16(kTempTestKeyPath),
102 base::Time::Now()); 105 base::Time::Now());
103 } 106 }
104 107
105 } // namespace registry_util 108 } // namespace registry_util
OLDNEW
« no previous file with comments | « base/strings/string_util.h ('k') | base/trace_event/trace_event_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698