diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-07 22:23:58 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-07 22:23:58 +0000 |
commit | 7d34040372aacc714b5958b6251fdfe1446e5cce (patch) | |
tree | 9d30431e9f588b17be26aca0f04a172b59c08073 /sandbox | |
parent | b888dfe092bc8ea3e485b606ecc23b73955c2d51 (diff) | |
download | chromium_src-7d34040372aacc714b5958b6251fdfe1446e5cce.zip chromium_src-7d34040372aacc714b5958b6251fdfe1446e5cce.tar.gz chromium_src-7d34040372aacc714b5958b6251fdfe1446e5cce.tar.bz2 |
Remove base/scoped_handle_win.h stub and fix up all callers to use the new location and namespace.
BUG=None
TEST=trybots
Review URL: http://codereview.chromium.org/6126002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70795 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/src/file_policy_test.cc | 22 | ||||
-rw-r--r-- | sandbox/src/filesystem_policy.cc | 6 | ||||
-rw-r--r-- | sandbox/src/process_policy_test.cc | 14 | ||||
-rw-r--r-- | sandbox/src/registry_dispatcher.cc | 8 | ||||
-rw-r--r-- | sandbox/src/restricted_token_utils.cc | 15 | ||||
-rw-r--r-- | sandbox/src/sync_policy_test.cc | 23 | ||||
-rw-r--r-- | sandbox/src/unload_dll_test.cc | 11 | ||||
-rw-r--r-- | sandbox/src/win_utils_unittest.cc | 9 |
8 files changed, 56 insertions, 52 deletions
diff --git a/sandbox/src/file_policy_test.cc b/sandbox/src/file_policy_test.cc index 2abf6e2..df1e903 100644 --- a/sandbox/src/file_policy_test.cc +++ b/sandbox/src/file_policy_test.cc @@ -1,13 +1,14 @@ -// Copyright (c) 2010 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 <algorithm> #include <cctype> #include <windows.h> #include <winioctl.h> -#include "base/scoped_handle_win.h" +#include "base/win/scoped_handle.h" #include "sandbox/src/nt_internals.h" #include "sandbox/src/sandbox.h" #include "sandbox/src/sandbox_factory.h" @@ -35,19 +36,20 @@ SBOX_TESTS_COMMAND int File_Create(int argc, wchar_t **argv) { bool read = (_wcsicmp(argv[0], L"Read") == 0); if (read) { - ScopedHandle file1(CreateFile(argv[1], GENERIC_READ, kSharing, NULL, - OPEN_EXISTING, 0, NULL)); - ScopedHandle file2(CreateFile(argv[1], FILE_EXECUTE, kSharing, NULL, - OPEN_EXISTING, 0, NULL)); + base::win::ScopedHandle file1(CreateFile( + argv[1], GENERIC_READ, kSharing, NULL, OPEN_EXISTING, 0, NULL)); + base::win::ScopedHandle file2(CreateFile( + argv[1], FILE_EXECUTE, kSharing, NULL, OPEN_EXISTING, 0, NULL)); if (file1.Get() && file2.Get()) return SBOX_TEST_SUCCEEDED; return SBOX_TEST_DENIED; } else { - ScopedHandle file1(CreateFile(argv[1], GENERIC_ALL, kSharing, NULL, - OPEN_EXISTING, 0, NULL)); - ScopedHandle file2(CreateFile(argv[1], GENERIC_READ | FILE_WRITE_DATA, - kSharing, NULL, OPEN_EXISTING, 0, NULL)); + base::win::ScopedHandle file1(CreateFile( + argv[1], GENERIC_ALL, kSharing, NULL, OPEN_EXISTING, 0, NULL)); + base::win::ScopedHandle file2(CreateFile( + argv[1], GENERIC_READ | FILE_WRITE_DATA, kSharing, NULL, OPEN_EXISTING, + 0, NULL)); if (file1.Get() && file2.Get()) return SBOX_TEST_SUCCEEDED; diff --git a/sandbox/src/filesystem_policy.cc b/sandbox/src/filesystem_policy.cc index 2a15555..385f4ae 100644 --- a/sandbox/src/filesystem_policy.cc +++ b/sandbox/src/filesystem_policy.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2010 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. @@ -7,7 +7,7 @@ #include "sandbox/src/filesystem_policy.h" #include "base/logging.h" -#include "base/scoped_handle_win.h" +#include "base/win/scoped_handle.h" #include "sandbox/src/ipc_tags.h" #include "sandbox/src/policy_engine_opcodes.h" #include "sandbox/src/policy_params.h" @@ -363,7 +363,7 @@ bool FileSystemPolicy::SetInformationFileAction( return true; } - ScopedHandle handle(local_handle); + base::win::ScopedHandle handle(local_handle); FILE_INFORMATION_CLASS file_info_class = static_cast<FILE_INFORMATION_CLASS>(info_class); diff --git a/sandbox/src/process_policy_test.cc b/sandbox/src/process_policy_test.cc index 0fbf204..8681671 100644 --- a/sandbox/src/process_policy_test.cc +++ b/sandbox/src/process_policy_test.cc @@ -1,17 +1,17 @@ -// 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 <string> #include <memory> +#include <string> -#include "base/scoped_handle_win.h" -#include "testing/gtest/include/gtest/gtest.h" +#include "base/win/scoped_handle.h" #include "sandbox/src/sandbox.h" #include "sandbox/src/sandbox_policy.h" #include "sandbox/src/sandbox_factory.h" #include "sandbox/src/sandbox_utils.h" #include "sandbox/tests/common/controller.h" +#include "testing/gtest/include/gtest/gtest.h" namespace { @@ -178,14 +178,14 @@ SBOX_TESTS_COMMAND int Process_GetChildProcessToken(int argc, wchar_t **argv) { return SBOX_TEST_FAILED; } - ScopedHandle process(pi.hProcess); - ScopedHandle thread(pi.hThread); + base::win::ScopedHandle process(pi.hProcess); + base::win::ScopedHandle thread(pi.hThread); HANDLE token = NULL; BOOL result = ::OpenProcessToken(process.Get(), TOKEN_IMPERSONATE, &token); DWORD error = ::GetLastError(); - ScopedHandle token_handle(token); + base::win::ScopedHandle token_handle(token); if (!::TerminateProcess(process.Get(), 0)) return SBOX_TEST_FAILED; diff --git a/sandbox/src/registry_dispatcher.cc b/sandbox/src/registry_dispatcher.cc index 5f53770..f86c76a 100644 --- a/sandbox/src/registry_dispatcher.cc +++ b/sandbox/src/registry_dispatcher.cc @@ -1,10 +1,10 @@ -// Copyright (c) 2010 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 "sandbox/src/registry_dispatcher.h" -#include "base/scoped_handle_win.h" +#include "base/win/scoped_handle.h" #include "base/win/windows_version.h" #include "sandbox/src/crosscall_client.h" #include "sandbox/src/interception.h" @@ -74,7 +74,7 @@ bool RegistryDispatcher::SetupService(InterceptionManager* manager, bool RegistryDispatcher::NtCreateKey( IPCInfo* ipc, std::wstring* name, DWORD attributes, HANDLE root, DWORD desired_access, DWORD title_index, DWORD create_options) { - ScopedHandle root_handle; + base::win::ScopedHandle root_handle; std::wstring real_path = *name; // If there is a root directory, we need to duplicate the handle to make @@ -120,7 +120,7 @@ bool RegistryDispatcher::NtCreateKey( bool RegistryDispatcher::NtOpenKey(IPCInfo* ipc, std::wstring* name, DWORD attributes, HANDLE root, DWORD desired_access) { - ScopedHandle root_handle; + base::win::ScopedHandle root_handle; std::wstring real_path = *name; // If there is a root directory, we need to duplicate the handle to make diff --git a/sandbox/src/restricted_token_utils.cc b/sandbox/src/restricted_token_utils.cc index 8842865..b036e51 100644 --- a/sandbox/src/restricted_token_utils.cc +++ b/sandbox/src/restricted_token_utils.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 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. @@ -9,7 +9,7 @@ #include "sandbox/src/restricted_token_utils.h" #include "base/logging.h" -#include "base/scoped_handle_win.h" +#include "base/win/scoped_handle.h" #include "base/win/windows_version.h" #include "sandbox/src/job.h" #include "sandbox/src/restricted_token.h" @@ -166,7 +166,7 @@ DWORD StartRestrictedProcessInJob(wchar_t *command_line, if (ERROR_SUCCESS != err_code) { return err_code; } - ScopedHandle primary_token(primary_token_handle); + base::win::ScopedHandle primary_token(primary_token_handle); // Create the impersonation token (restricted) to be able to start the // process. @@ -178,7 +178,7 @@ DWORD StartRestrictedProcessInJob(wchar_t *command_line, if (ERROR_SUCCESS != err_code) { return err_code; } - ScopedHandle impersonation_token(impersonation_token_handle); + base::win::ScopedHandle impersonation_token(impersonation_token_handle); // Start the process STARTUPINFO startup_info = {0}; @@ -198,8 +198,8 @@ DWORD StartRestrictedProcessInJob(wchar_t *command_line, return ::GetLastError(); } - ScopedHandle thread_handle(process_info.hThread); - ScopedHandle process_handle(process_info.hProcess); + base::win::ScopedHandle thread_handle(process_info.hThread); + base::win::ScopedHandle process_handle(process_info.hProcess); // Change the token of the main thread of the new process for the // impersonation token with more rights. @@ -335,10 +335,9 @@ DWORD SetProcessIntegrityLevel(IntegrityLevel integrity_level) { &token_handle)) return ::GetLastError(); - ScopedHandle token(token_handle); + base::win::ScopedHandle token(token_handle); return SetTokenIntegrityLevel(token.Get(), integrity_level); } - } // namespace sandbox diff --git a/sandbox/src/sync_policy_test.cc b/sandbox/src/sync_policy_test.cc index 835a578..3c87243 100644 --- a/sandbox/src/sync_policy_test.cc +++ b/sandbox/src/sync_policy_test.cc @@ -1,14 +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/scoped_handle_win.h" -#include "testing/gtest/include/gtest/gtest.h" +#include "base/win/scoped_handle.h" #include "sandbox/src/sandbox.h" #include "sandbox/src/sandbox_policy.h" #include "sandbox/src/sandbox_factory.h" #include "sandbox/src/nt_internals.h" #include "sandbox/tests/common/controller.h" +#include "testing/gtest/include/gtest/gtest.h" namespace sandbox { @@ -20,7 +20,8 @@ SBOX_TESTS_COMMAND int Event_Open(int argc, wchar_t **argv) { if (L'f' == argv[0][0]) desired_access = EVENT_ALL_ACCESS; - ScopedHandle event_open(::OpenEvent(desired_access, FALSE, argv[1])); + base::win::ScopedHandle event_open(::OpenEvent( + desired_access, FALSE, argv[1])); DWORD error_open = ::GetLastError(); if (event_open.Get()) @@ -48,10 +49,10 @@ SBOX_TESTS_COMMAND int Event_CreateOpen(int argc, wchar_t **argv) { if (L't' == argv[1][0]) initial_state = TRUE; - ScopedHandle event_create(::CreateEvent(NULL, manual_reset, initial_state, - event_name)); + base::win::ScopedHandle event_create(::CreateEvent( + NULL, manual_reset, initial_state, event_name)); DWORD error_create = ::GetLastError(); - ScopedHandle event_open; + base::win::ScopedHandle event_open; if (event_name) event_open.Set(::OpenEvent(EVENT_ALL_ACCESS, FALSE, event_name)); @@ -124,10 +125,10 @@ TEST(SyncPolicyTest, TestEventReadOnly) { TargetPolicy::EVENTS_ALLOW_READONLY, L"test6")); - ScopedHandle handle1(::CreateEvent(NULL, FALSE, FALSE, L"test1")); - ScopedHandle handle2(::CreateEvent(NULL, FALSE, FALSE, L"test2")); - ScopedHandle handle3(::CreateEvent(NULL, FALSE, FALSE, L"test3")); - ScopedHandle handle4(::CreateEvent(NULL, FALSE, FALSE, L"test4")); + base::win::ScopedHandle handle1(::CreateEvent(NULL, FALSE, FALSE, L"test1")); + base::win::ScopedHandle handle2(::CreateEvent(NULL, FALSE, FALSE, L"test2")); + base::win::ScopedHandle handle3(::CreateEvent(NULL, FALSE, FALSE, L"test3")); + base::win::ScopedHandle handle4(::CreateEvent(NULL, FALSE, FALSE, L"test4")); EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"Event_CreateOpen f f")); EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"Event_CreateOpen t f")); diff --git a/sandbox/src/unload_dll_test.cc b/sandbox/src/unload_dll_test.cc index 063f43f..a50f1aa 100644 --- a/sandbox/src/unload_dll_test.cc +++ b/sandbox/src/unload_dll_test.cc @@ -1,13 +1,13 @@ -// Copyright (c) 2010 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/scoped_handle_win.h" -#include "testing/gtest/include/gtest/gtest.h" +#include "base/win/scoped_handle.h" #include "sandbox/src/sandbox.h" #include "sandbox/src/sandbox_factory.h" #include "sandbox/src/target_services.h" #include "sandbox/tests/common/controller.h" +#include "testing/gtest/include/gtest/gtest.h" namespace sandbox { @@ -36,7 +36,7 @@ SBOX_TESTS_COMMAND int SimpleOpenEvent(int argc, wchar_t **argv) { if (argc != 1) return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; - ScopedHandle event_open(::OpenEvent(SYNCHRONIZE, FALSE, argv[0])); + base::win::ScopedHandle event_open(::OpenEvent(SYNCHRONIZE, FALSE, argv[0])); return event_open.Get() ? SBOX_TEST_SUCCEEDED : SBOX_TEST_FAILED; } @@ -73,7 +73,8 @@ TEST(UnloadDllTest, FLAKY_UnloadAviCapDllWithPatching) { sandbox::TargetPolicy* policy = runner.GetPolicy(); policy->AddDllToUnload(L"avicap32.dll"); - ScopedHandle handle1(::CreateEvent(NULL, FALSE, FALSE, L"tst0001")); + base::win::ScopedHandle handle1(::CreateEvent( + NULL, FALSE, FALSE, L"tst0001")); // Add a couple of rules that ensures that the interception agent add EAT // patching on the client which makes sure that the unload dll record does diff --git a/sandbox/src/win_utils_unittest.cc b/sandbox/src/win_utils_unittest.cc index 99ce7e2..0f445ef 100644 --- a/sandbox/src/win_utils_unittest.cc +++ b/sandbox/src/win_utils_unittest.cc @@ -1,10 +1,10 @@ -// Copyright (c) 2010 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 <windows.h> -#include "base/scoped_handle_win.h" +#include "base/win/scoped_handle.h" #include "sandbox/src/win_utils.h" #include "sandbox/tests/common/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" @@ -67,8 +67,9 @@ TEST(WinUtils, SameObject) { std::wstring folder(my_folder); std::wstring file_name = folder + L"\\foo.txt"; const ULONG kSharing = FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE; - ScopedHandle file(CreateFile(file_name.c_str(), GENERIC_WRITE, kSharing, NULL, - CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL)); + base::win::ScopedHandle file(CreateFile( + file_name.c_str(), GENERIC_WRITE, kSharing, NULL, CREATE_ALWAYS, + FILE_FLAG_DELETE_ON_CLOSE, NULL)); EXPECT_TRUE(file.IsValid()); std::wstring file_name_nt1 = std::wstring(L"\\??\\") + file_name; |