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

Side by Side Diff: sandbox/win/src/policy_target_test.cc

Issue 1320783002: Make SharedMemoryHandle a class on windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ipc_global
Patch Set: Rebase. Created 5 years, 2 months 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/src/handle_inheritance_test.cc ('k') | sandbox/win/tests/common/controller.cc » ('j') | 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 "base/memory/shared_memory.h" 5 #include "base/memory/shared_memory.h"
6 #include "base/strings/string_number_conversions.h" 6 #include "base/strings/string_number_conversions.h"
7 #include "base/strings/string_piece.h" 7 #include "base/strings/string_piece.h"
8 #include "base/win/scoped_process_information.h" 8 #include "base/win/scoped_process_information.h"
9 #include "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
10 #include "sandbox/win/src/sandbox.h" 10 #include "sandbox/win/src/sandbox.h"
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 memcpy(writable_shmem.memory(), contents.data(), contents.size()); 369 memcpy(writable_shmem.memory(), contents.data(), contents.size());
370 370
371 base::SharedMemory read_only_view; 371 base::SharedMemory read_only_view;
372 ASSERT_TRUE(read_only_view.Open(name, true)); 372 ASSERT_TRUE(read_only_view.Open(name, true));
373 373
374 // Get the path to the sandboxed app. 374 // Get the path to the sandboxed app.
375 wchar_t prog_name[MAX_PATH]; 375 wchar_t prog_name[MAX_PATH];
376 GetModuleFileNameW(NULL, prog_name, MAX_PATH); 376 GetModuleFileNameW(NULL, prog_name, MAX_PATH);
377 377
378 TargetPolicy* policy = broker->CreatePolicy(); 378 TargetPolicy* policy = broker->CreatePolicy();
379 void* shared_handle = policy->AddHandleToShare( 379 void* shared_handle =
380 read_only_view.handle()); 380 policy->AddHandleToShare(read_only_view.handle().GetHandle());
381 381
382 base::string16 arguments(L"\""); 382 base::string16 arguments(L"\"");
383 arguments += prog_name; 383 arguments += prog_name;
384 arguments += L"\" -child 0 shared_memory_handle "; 384 arguments += L"\" -child 0 shared_memory_handle ";
385 arguments += base::UintToString16( 385 arguments += base::UintToString16(
386 reinterpret_cast<unsigned int>(shared_handle)); 386 reinterpret_cast<unsigned int>(shared_handle));
387 387
388 // Launch the app. 388 // Launch the app.
389 ResultCode result = SBOX_ALL_OK; 389 ResultCode result = SBOX_ALL_OK;
390 base::win::ScopedProcessInformation target; 390 base::win::ScopedProcessInformation target;
(...skipping 12 matching lines...) Expand all
403 403
404 EXPECT_EQ(WAIT_TIMEOUT, 404 EXPECT_EQ(WAIT_TIMEOUT,
405 ::WaitForSingleObject(target.process_handle(), 2000)); 405 ::WaitForSingleObject(target.process_handle(), 2000));
406 406
407 EXPECT_TRUE(::TerminateProcess(target.process_handle(), 0)); 407 EXPECT_TRUE(::TerminateProcess(target.process_handle(), 0));
408 408
409 ::WaitForSingleObject(target.process_handle(), INFINITE); 409 ::WaitForSingleObject(target.process_handle(), INFINITE);
410 } 410 }
411 411
412 } // namespace sandbox 412 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/handle_inheritance_test.cc ('k') | sandbox/win/tests/common/controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698