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

Unified Diff: base/test/test_reg_util_win.cc

Issue 1446363003: Deleted OS_WIN and all Windows specific files from base. (Closed) Base URL: https://github.com/domokit/mojo.git@base_tests
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/test/test_reg_util_win.h ('k') | base/test/test_reg_util_win_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/test_reg_util_win.cc
diff --git a/base/test/test_reg_util_win.cc b/base/test/test_reg_util_win.cc
deleted file mode 100644
index e3b1ffc90b048d641b177a2ca63993aa408f5354..0000000000000000000000000000000000000000
--- a/base/test/test_reg_util_win.cc
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/test/test_reg_util_win.h"
-
-#include "base/guid.h"
-#include "base/logging.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace registry_util {
-
-namespace {
-
-const wchar_t kTimestampDelimiter[] = L"$";
-const wchar_t kTempTestKeyPath[] = L"Software\\Chromium\\TempTestKeys";
-
-void DeleteStaleTestKeys(const base::Time& now,
- const base::string16& test_key_root) {
- base::win::RegKey test_root_key;
- if (test_root_key.Open(HKEY_CURRENT_USER,
- test_key_root.c_str(),
- KEY_ALL_ACCESS) != ERROR_SUCCESS) {
- // This will occur on first-run, but is harmless.
- return;
- }
-
- base::win::RegistryKeyIterator iterator_test_root_key(HKEY_CURRENT_USER,
- test_key_root.c_str());
- for (; iterator_test_root_key.Valid(); ++iterator_test_root_key) {
- base::string16 key_name = iterator_test_root_key.Name();
- std::vector<base::string16> tokens;
- if (!Tokenize(key_name, base::string16(kTimestampDelimiter), &tokens))
- continue;
- int64 key_name_as_number = 0;
-
- if (!base::StringToInt64(tokens[0], &key_name_as_number)) {
- test_root_key.DeleteKey(key_name.c_str());
- continue;
- }
-
- base::Time key_time = base::Time::FromInternalValue(key_name_as_number);
- base::TimeDelta age = now - key_time;
-
- if (age > base::TimeDelta::FromHours(24))
- test_root_key.DeleteKey(key_name.c_str());
- }
-}
-
-base::string16 GenerateTempKeyPath(const base::string16& test_key_root,
- const base::Time& timestamp) {
- base::string16 key_path = test_key_root;
- key_path += L"\\" + base::Int64ToString16(timestamp.ToInternalValue());
- key_path += kTimestampDelimiter + base::ASCIIToUTF16(base::GenerateGUID());
-
- return key_path;
-}
-
-} // namespace
-
-RegistryOverrideManager::ScopedRegistryKeyOverride::ScopedRegistryKeyOverride(
- HKEY override,
- const base::string16& key_path)
- : override_(override) {
- EXPECT_EQ(
- ERROR_SUCCESS,
- temp_key_.Create(HKEY_CURRENT_USER, key_path.c_str(), KEY_ALL_ACCESS));
- EXPECT_EQ(ERROR_SUCCESS,
- ::RegOverridePredefKey(override_, temp_key_.Handle()));
-}
-
-RegistryOverrideManager::
- ScopedRegistryKeyOverride::~ScopedRegistryKeyOverride() {
- ::RegOverridePredefKey(override_, NULL);
- temp_key_.DeleteKey(L"");
-}
-
-RegistryOverrideManager::RegistryOverrideManager()
- : timestamp_(base::Time::Now()), test_key_root_(kTempTestKeyPath) {
- DeleteStaleTestKeys(timestamp_, test_key_root_);
-}
-
-RegistryOverrideManager::RegistryOverrideManager(
- const base::Time& timestamp,
- const base::string16& test_key_root)
- : timestamp_(timestamp), test_key_root_(test_key_root) {
- DeleteStaleTestKeys(timestamp_, test_key_root_);
-}
-
-RegistryOverrideManager::~RegistryOverrideManager() {}
-
-void RegistryOverrideManager::OverrideRegistry(HKEY override) {
- base::string16 key_path = GenerateTempKeyPath(test_key_root_, timestamp_);
- overrides_.push_back(new ScopedRegistryKeyOverride(override, key_path));
-}
-
-base::string16 GenerateTempKeyPath() {
- return GenerateTempKeyPath(base::string16(kTempTestKeyPath),
- base::Time::Now());
-}
-
-} // namespace registry_util
« no previous file with comments | « base/test/test_reg_util_win.h ('k') | base/test/test_reg_util_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698