| Index: sandbox/win/src/policy_target_test.cc
|
| diff --git a/sandbox/win/src/policy_target_test.cc b/sandbox/win/src/policy_target_test.cc
|
| index bb1f0b2ba38fd2fb94c780c26715a42c74975e2d..9736291042f7d0329e4b349aeeace4adb923d605 100644
|
| --- a/sandbox/win/src/policy_target_test.cc
|
| +++ b/sandbox/win/src/policy_target_test.cc
|
| @@ -2,6 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "base/memory/ref_counted.h"
|
| #include "base/memory/shared_memory.h"
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/strings/string_piece.h"
|
| @@ -225,9 +226,8 @@ TEST(PolicyTargetTest, DesktopPolicy) {
|
| BrokerServices* broker = GetBroker();
|
|
|
| // Precreate the desktop.
|
| - TargetPolicy* temp_policy = broker->CreatePolicy();
|
| + scoped_refptr<TargetPolicy> temp_policy = broker->CreatePolicy();
|
| temp_policy->CreateAlternateDesktop(false);
|
| - temp_policy->Release();
|
|
|
| ASSERT_TRUE(broker != NULL);
|
|
|
| @@ -243,14 +243,13 @@ TEST(PolicyTargetTest, DesktopPolicy) {
|
| ResultCode result = SBOX_ALL_OK;
|
| base::win::ScopedProcessInformation target;
|
|
|
| - TargetPolicy* policy = broker->CreatePolicy();
|
| + scoped_refptr<TargetPolicy> policy = broker->CreatePolicy();
|
| policy->SetAlternateDesktop(false);
|
| policy->SetTokenLevel(USER_INTERACTIVE, USER_LOCKDOWN);
|
| PROCESS_INFORMATION temp_process_info = {};
|
| result = broker->SpawnTarget(prog_name, arguments.c_str(), policy,
|
| &temp_process_info);
|
| base::string16 desktop_name = policy->GetAlternateDesktop();
|
| - policy->Release();
|
|
|
| EXPECT_EQ(SBOX_ALL_OK, result);
|
| if (result == SBOX_ALL_OK)
|
| @@ -271,9 +270,7 @@ TEST(PolicyTargetTest, DesktopPolicy) {
|
| ::WaitForSingleObject(target.process_handle(), INFINITE);
|
|
|
| // Close the desktop handle.
|
| - temp_policy = broker->CreatePolicy();
|
| temp_policy->DestroyAlternateDesktop();
|
| - temp_policy->Release();
|
|
|
| // Make sure the desktop does not exist anymore.
|
| desk = ::OpenDesktop(desktop_name.c_str(), 0, FALSE, DESKTOP_ENUMERATE);
|
| @@ -288,9 +285,8 @@ TEST(PolicyTargetTest, WinstaPolicy) {
|
| BrokerServices* broker = GetBroker();
|
|
|
| // Precreate the desktop.
|
| - TargetPolicy* temp_policy = broker->CreatePolicy();
|
| + scoped_refptr<TargetPolicy> temp_policy = broker->CreatePolicy();
|
| temp_policy->CreateAlternateDesktop(true);
|
| - temp_policy->Release();
|
|
|
| ASSERT_TRUE(broker != NULL);
|
|
|
| @@ -306,14 +302,13 @@ TEST(PolicyTargetTest, WinstaPolicy) {
|
| ResultCode result = SBOX_ALL_OK;
|
| base::win::ScopedProcessInformation target;
|
|
|
| - TargetPolicy* policy = broker->CreatePolicy();
|
| + scoped_refptr<TargetPolicy> policy = broker->CreatePolicy();
|
| policy->SetAlternateDesktop(true);
|
| policy->SetTokenLevel(USER_INTERACTIVE, USER_LOCKDOWN);
|
| PROCESS_INFORMATION temp_process_info = {};
|
| result = broker->SpawnTarget(prog_name, arguments.c_str(), policy,
|
| &temp_process_info);
|
| base::string16 desktop_name = policy->GetAlternateDesktop();
|
| - policy->Release();
|
|
|
| EXPECT_EQ(SBOX_ALL_OK, result);
|
| if (result == SBOX_ALL_OK)
|
| @@ -342,9 +337,7 @@ TEST(PolicyTargetTest, WinstaPolicy) {
|
| ::WaitForSingleObject(target.process_handle(), INFINITE);
|
|
|
| // Close the desktop handle.
|
| - temp_policy = broker->CreatePolicy();
|
| temp_policy->DestroyAlternateDesktop();
|
| - temp_policy->Release();
|
| }
|
|
|
| // Launches the app in the sandbox and share a handle with it. The app should
|
| @@ -375,7 +368,7 @@ TEST(PolicyTargetTest, ShareHandleTest) {
|
| wchar_t prog_name[MAX_PATH];
|
| GetModuleFileNameW(NULL, prog_name, MAX_PATH);
|
|
|
| - TargetPolicy* policy = broker->CreatePolicy();
|
| + scoped_refptr<TargetPolicy> policy = broker->CreatePolicy();
|
| void* shared_handle =
|
| policy->AddHandleToShare(read_only_view.handle().GetHandle());
|
|
|
| @@ -391,9 +384,8 @@ TEST(PolicyTargetTest, ShareHandleTest) {
|
|
|
| policy->SetTokenLevel(USER_INTERACTIVE, USER_LOCKDOWN);
|
| PROCESS_INFORMATION temp_process_info = {};
|
| - result = broker->SpawnTarget(prog_name, arguments.c_str(), policy,
|
| + result = broker->SpawnTarget(prog_name, arguments.c_str(), policy.Pass(),
|
| &temp_process_info);
|
| - policy->Release();
|
|
|
| EXPECT_EQ(SBOX_ALL_OK, result);
|
| if (result == SBOX_ALL_OK)
|
|
|