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

Side by Side Diff: content/utility/utility_main.cc

Issue 1851213002: Remove sandbox on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nacl compile issues Created 4 years, 8 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 | « content/shell/browser/shell_content_browser_client.cc ('k') | sandbox/sandbox.gyp » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/debug/leak_annotations.h" 6 #include "base/debug/leak_annotations.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/threading/platform_thread.h" 8 #include "base/threading/platform_thread.h"
9 #include "base/timer/hi_res_timer_manager.h" 9 #include "base/timer/hi_res_timer_manager.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "content/child/child_process.h" 11 #include "content/child/child_process.h"
12 #include "content/common/sandbox_linux/sandbox_linux.h" 12 #include "content/common/sandbox_linux/sandbox_linux.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "content/public/common/main_function_params.h" 14 #include "content/public/common/main_function_params.h"
15 #include "content/public/common/sandbox_init.h" 15 #include "content/public/common/sandbox_init.h"
16 #include "content/utility/utility_thread_impl.h" 16 #include "content/utility/utility_thread_impl.h"
17 17
18 #if defined(OS_WIN) 18 #if defined(OS_WIN)
19 #include "base/rand_util.h" 19 #include "base/rand_util.h"
20 #include "sandbox/win/src/sandbox.h"
21 #endif 20 #endif
22 21
23 namespace content { 22 namespace content {
24 23
25 // Mainline routine for running as the utility process. 24 // Mainline routine for running as the utility process.
26 int UtilityMain(const MainFunctionParams& parameters) { 25 int UtilityMain(const MainFunctionParams& parameters) {
27 // The main message loop of the utility process. 26 // The main message loop of the utility process.
28 base::MessageLoop main_message_loop; 27 base::MessageLoop main_message_loop;
29 base::PlatformThread::SetName("CrUtilityMain"); 28 base::PlatformThread::SetName("CrUtilityMain");
30 29
31 #if defined(OS_LINUX) 30 #if defined(OS_LINUX)
32 // Initializes the sandbox before any threads are created. 31 // Initializes the sandbox before any threads are created.
33 // TODO(jorgelo): move this after GTK initialization when we enable a strict 32 // TODO(jorgelo): move this after GTK initialization when we enable a strict
34 // Seccomp-BPF policy. 33 // Seccomp-BPF policy.
35 if (parameters.zygote_child) 34 if (parameters.zygote_child)
36 LinuxSandbox::InitializeSandbox(); 35 LinuxSandbox::InitializeSandbox();
37 #endif 36 #endif
38 37
39 ChildProcess utility_process; 38 ChildProcess utility_process;
40 utility_process.set_main_thread(new UtilityThreadImpl()); 39 utility_process.set_main_thread(new UtilityThreadImpl());
41 40
42 base::HighResolutionTimerManager hi_res_timer_manager; 41 base::HighResolutionTimerManager hi_res_timer_manager;
43 42
44 #if defined(OS_WIN)
45 bool no_sandbox = parameters.command_line.HasSwitch(switches::kNoSandbox);
46 if (!no_sandbox) {
47 sandbox::TargetServices* target_services =
48 parameters.sandbox_info->target_services;
49 if (!target_services)
50 return false;
51 char buffer;
52 // Ensure RtlGenRandom is warm before the token is lowered; otherwise,
53 // base::RandBytes() will CHECK fail when v8 is initialized.
54 base::RandBytes(&buffer, sizeof(buffer));
55 target_services->LowerToken();
56 }
57 #endif
58
59 base::MessageLoop::current()->Run(); 43 base::MessageLoop::current()->Run();
60 44
61 #if defined(LEAK_SANITIZER) 45 #if defined(LEAK_SANITIZER)
62 // Invoke LeakSanitizer before shutting down the utility thread, to avoid 46 // Invoke LeakSanitizer before shutting down the utility thread, to avoid
63 // reporting shutdown-only leaks. 47 // reporting shutdown-only leaks.
64 __lsan_do_leak_check(); 48 __lsan_do_leak_check();
65 #endif 49 #endif
66 50
67 return 0; 51 return 0;
68 } 52 }
69 53
70 } // namespace content 54 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/shell_content_browser_client.cc ('k') | sandbox/sandbox.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698