Pass CreateDirectory errors up to IndexedDB.
[chromium-blink-merge.git] / content / utility / utility_main.cc
blobef4fd1e7d1b9b978aa7b6342897b560ff6306bed
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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "base/hi_res_timer_manager.h"
7 #include "base/message_loop.h"
8 #include "base/power_monitor/power_monitor.h"
9 #include "base/threading/platform_thread.h"
10 #include "content/child/child_process.h"
11 #include "content/common/sandbox_linux.h"
12 #include "content/public/common/content_switches.h"
13 #include "content/public/common/main_function_params.h"
14 #include "content/public/common/sandbox_init.h"
15 #include "content/utility/utility_thread_impl.h"
17 #if defined(OS_WIN)
18 #include "sandbox/win/src/sandbox.h"
19 #endif
21 namespace content {
23 // Mainline routine for running as the utility process.
24 int UtilityMain(const MainFunctionParams& parameters) {
25 // The main message loop of the utility process.
26 base::MessageLoop main_message_loop;
27 base::PlatformThread::SetName("CrUtilityMain");
29 base::PowerMonitor power_monitor;
30 HighResolutionTimerManager hi_res_timer_manager;
32 #if defined(OS_LINUX)
33 // Initialize the sandbox before any thread is created.
34 LinuxSandbox::InitializeSandbox();
35 #endif
37 ChildProcess utility_process;
38 utility_process.set_main_thread(new UtilityThreadImpl());
40 #if defined(OS_WIN)
41 bool no_sandbox = parameters.command_line.HasSwitch(switches::kNoSandbox);
42 if (!no_sandbox) {
43 sandbox::TargetServices* target_services =
44 parameters.sandbox_info->target_services;
45 if (!target_services)
46 return false;
47 target_services->LowerToken();
49 #endif
51 base::MessageLoop::current()->Run();
53 return 0;
56 } // namespace content