OLD | NEW |
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 "content/child/child_process.h" | 10 #include "content/child/child_process.h" |
11 #include "content/common/sandbox_linux/sandbox_linux.h" | 11 #include "content/common/sandbox_linux/sandbox_linux.h" |
12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
13 #include "content/public/common/main_function_params.h" | 13 #include "content/public/common/main_function_params.h" |
14 #include "content/public/common/sandbox_init.h" | 14 #include "content/public/common/sandbox_init.h" |
15 #include "content/utility/utility_thread_impl.h" | 15 #include "content/utility/utility_thread_impl.h" |
16 | 16 |
17 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
| 18 #include "base/rand_util.h" |
18 #include "sandbox/win/src/sandbox.h" | 19 #include "sandbox/win/src/sandbox.h" |
19 #endif | 20 #endif |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
23 // Mainline routine for running as the utility process. | 24 // Mainline routine for running as the utility process. |
24 int UtilityMain(const MainFunctionParams& parameters) { | 25 int UtilityMain(const MainFunctionParams& parameters) { |
25 // The main message loop of the utility process. | 26 // The main message loop of the utility process. |
26 base::MessageLoop main_message_loop; | 27 base::MessageLoop main_message_loop; |
27 base::PlatformThread::SetName("CrUtilityMain"); | 28 base::PlatformThread::SetName("CrUtilityMain"); |
(...skipping 17 matching lines...) Expand all Loading... |
45 sandbox::TargetServices* target_services = | 46 sandbox::TargetServices* target_services = |
46 parameters.sandbox_info->target_services; | 47 parameters.sandbox_info->target_services; |
47 if (!target_services) | 48 if (!target_services) |
48 return false; | 49 return false; |
49 #if defined(ADDRESS_SANITIZER) | 50 #if defined(ADDRESS_SANITIZER) |
50 // Bind and leak dbghelp.dll before the token is lowered, otherwise | 51 // Bind and leak dbghelp.dll before the token is lowered, otherwise |
51 // AddressSanitizer will crash when trying to symbolize a report. | 52 // AddressSanitizer will crash when trying to symbolize a report. |
52 if (!LoadLibraryA("dbghelp.dll")) | 53 if (!LoadLibraryA("dbghelp.dll")) |
53 return false; | 54 return false; |
54 #endif | 55 #endif |
| 56 char buffer; |
| 57 // Ensure RtlGenRandom is warm before the token is lowered; otherwise, |
| 58 // base::RandBytes() will CHECK fail when v8 is initialized. |
| 59 base::RandBytes(&buffer, sizeof(buffer)); |
55 target_services->LowerToken(); | 60 target_services->LowerToken(); |
56 } | 61 } |
57 #endif | 62 #endif |
58 | 63 |
59 base::MessageLoop::current()->Run(); | 64 base::MessageLoop::current()->Run(); |
60 | 65 |
61 #if defined(LEAK_SANITIZER) | 66 #if defined(LEAK_SANITIZER) |
62 // Invoke LeakSanitizer before shutting down the utility thread, to avoid | 67 // Invoke LeakSanitizer before shutting down the utility thread, to avoid |
63 // reporting shutdown-only leaks. | 68 // reporting shutdown-only leaks. |
64 __lsan_do_leak_check(); | 69 __lsan_do_leak_check(); |
65 #endif | 70 #endif |
66 | 71 |
67 return 0; | 72 return 0; |
68 } | 73 } |
69 | 74 |
70 } // namespace content | 75 } // namespace content |
OLD | NEW |