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

Side by Side Diff: sandbox/win/tests/common/controller.cc

Issue 1378523002: Use scoped_refptr and RefCountedThreadSafe for TargetPolicy. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated patchset dependency Created 5 years 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 | « sandbox/win/tests/common/controller.h ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "sandbox/win/tests/common/controller.h" 5 #include "sandbox/win/tests/common/controller.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/ref_counted.h"
9 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
10 #include "base/process/process.h" 11 #include "base/process/process.h"
11 #include "base/process/process_handle.h" 12 #include "base/process/process_handle.h"
12 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
14 #include "base/win/windows_version.h" 15 #include "base/win/windows_version.h"
15 #include "sandbox/win/src/sandbox_factory.h" 16 #include "sandbox/win/src/sandbox_factory.h"
16 17
17 namespace { 18 namespace {
18 19
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 127
127 // Close all ALPC ports. 128 // Close all ALPC ports.
128 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { 129 if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
129 policy_->AddKernelObjectToClose(L"ALPC Port", NULL); 130 policy_->AddKernelObjectToClose(L"ALPC Port", NULL);
130 } 131 }
131 132
132 is_init_ = true; 133 is_init_ = true;
133 } 134 }
134 135
135 TargetPolicy* TestRunner::GetPolicy() { 136 TargetPolicy* TestRunner::GetPolicy() {
136 return policy_; 137 return policy_.get();
137 } 138 }
138 139
139 TestRunner::~TestRunner() { 140 TestRunner::~TestRunner() {
140 if (target_process_.IsValid() && kill_on_destruction_) 141 if (target_process_.IsValid() && kill_on_destruction_)
141 ::TerminateProcess(target_process_.Get(), 0); 142 ::TerminateProcess(target_process_.Get(), 0);
142
143 if (policy_)
144 policy_->Release();
145 } 143 }
146 144
147 bool TestRunner::AddRule(TargetPolicy::SubSystem subsystem, 145 bool TestRunner::AddRule(TargetPolicy::SubSystem subsystem,
148 TargetPolicy::Semantics semantics, 146 TargetPolicy::Semantics semantics,
149 const wchar_t* pattern) { 147 const wchar_t* pattern) {
150 if (!is_init_) 148 if (!is_init_)
151 return false; 149 return false;
152 150
153 return (SBOX_ALL_OK == policy_->AddRule(subsystem, semantics, pattern)); 151 return (SBOX_ALL_OK == policy_->AddRule(subsystem, semantics, pattern));
154 } 152 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 359
362 target->LowerToken(); 360 target->LowerToken();
363 } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) { 361 } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) {
364 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 362 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
365 } 363 }
366 364
367 return command(argc - 4, argv + 4); 365 return command(argc - 4, argv + 4);
368 } 366 }
369 367
370 } // namespace sandbox 368 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/tests/common/controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698