summaryrefslogtreecommitdiffstats
path: root/sandbox/tests
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-07 22:15:34 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-07 22:15:34 +0000
commitf4812211951630ac47b96a1b7b78f3a3dcc2b9b9 (patch)
tree68db135c222a25e8a158bdff620624aa1d75ec34 /sandbox/tests
parent42e5c865f8702de0cd9e24726fe9bf69cb5cae9c (diff)
downloadchromium_src-f4812211951630ac47b96a1b7b78f3a3dcc2b9b9.zip
chromium_src-f4812211951630ac47b96a1b7b78f3a3dcc2b9b9.tar.gz
chromium_src-f4812211951630ac47b96a1b7b78f3a3dcc2b9b9.tar.bz2
Make the windows_version.h functions threadsafe by using a singleton. Add accessors to the singleton for more values that various code wants, then convert almost everyone using OSVERSIONINFO or SYSTEM_INFO structs to calling these accessors. Declare an AtExitManager in the out-of-process test runner since it didn't have one and that breaks singleton-using code in the test executable (as opposed to in chrome.dll).
A few other minor cleanups along the way (binding of "*", shorter code, etc.). Because I ran into problems with it while modifying gcapi.cc, I cleaned up our usage of strsafe.h a bit, so that files that don't need it don't include it and files that do use STRSAFE_NO_DEPRECATE instead of a modified #include order. BUG=none TEST=none Review URL: http://codereview.chromium.org/6816027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80851 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox/tests')
-rw-r--r--sandbox/tests/common/controller.cc10
-rw-r--r--sandbox/tests/integration_tests/integration_tests.cc6
-rw-r--r--sandbox/tests/unit_tests/unit_tests.cc6
-rw-r--r--sandbox/tests/validation_tests/unit_tests.cc6
4 files changed, 21 insertions, 7 deletions
diff --git a/sandbox/tests/common/controller.cc b/sandbox/tests/common/controller.cc
index 7efd374..b618069 100644
--- a/sandbox/tests/common/controller.cc
+++ b/sandbox/tests/common/controller.cc
@@ -55,9 +55,10 @@ std::wstring MakePathToSysWow64(const wchar_t* name, bool is_obj_man_path) {
namespace sandbox {
std::wstring MakePathToSys(const wchar_t* name, bool is_obj_man_path) {
- if (base::win::GetWOW64Status() == base::win::WOW64_ENABLED)
- return MakePathToSysWow64(name, is_obj_man_path);
- return MakePathToSys32(name, is_obj_man_path);
+ return (base::win::OSInfo::GetInstance()->wow64_status() ==
+ base::win::OSInfo::WOW64_ENABLED) ?
+ MakePathToSysWow64(name, is_obj_man_path) :
+ MakePathToSys32(name, is_obj_man_path);
}
BrokerServices* GetBroker() {
@@ -138,7 +139,8 @@ bool TestRunner::AddRuleSys32(TargetPolicy::Semantics semantics,
if (!AddRule(TargetPolicy::SUBSYS_FILES, semantics, win32_path.c_str()))
return false;
- if (base::win::GetWOW64Status() != base::win::WOW64_ENABLED)
+ if (base::win::OSInfo::GetInstance()->wow64_status() !=
+ base::win::OSInfo::WOW64_ENABLED)
return true;
win32_path = MakePathToSysWow64(pattern, false);
diff --git a/sandbox/tests/integration_tests/integration_tests.cc b/sandbox/tests/integration_tests/integration_tests.cc
index f7cbd15..5330ae9 100644
--- a/sandbox/tests/integration_tests/integration_tests.cc
+++ b/sandbox/tests/integration_tests/integration_tests.cc
@@ -1,11 +1,15 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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/at_exit.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "sandbox/tests/common/controller.h"
int wmain(int argc, wchar_t **argv) {
+ // The exit manager is in charge of calling the dtors of singleton objects.
+ base::AtExitManager exit_manager;
+
if (argc >= 2) {
if (0 == _wcsicmp(argv[1], L"-child"))
// This instance is a child, not the test.
diff --git a/sandbox/tests/unit_tests/unit_tests.cc b/sandbox/tests/unit_tests/unit_tests.cc
index 521be42..1614612 100644
--- a/sandbox/tests/unit_tests/unit_tests.cc
+++ b/sandbox/tests/unit_tests/unit_tests.cc
@@ -1,10 +1,14 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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/at_exit.h"
#include "testing/gtest/include/gtest/gtest.h"
int wmain(int argc, wchar_t **argv) {
+ // The exit manager is in charge of calling the dtors of singleton objects.
+ base::AtExitManager exit_manager;
+
if (argc >= 2) {
if (0 == _wcsicmp(argv[1], L"-child"))
// This instance is a child, not the test.
diff --git a/sandbox/tests/validation_tests/unit_tests.cc b/sandbox/tests/validation_tests/unit_tests.cc
index 4cd36ce..c5bc5cd 100644
--- a/sandbox/tests/validation_tests/unit_tests.cc
+++ b/sandbox/tests/validation_tests/unit_tests.cc
@@ -1,11 +1,15 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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/at_exit.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "sandbox/tests/common/controller.h"
int wmain(int argc, wchar_t **argv) {
+ // The exit manager is in charge of calling the dtors of singleton objects.
+ base::AtExitManager exit_manager;
+
if (argc >= 2) {
if (0 == _wcsicmp(argv[1], L"-child"))
return sandbox::DispatchCall(argc, argv);