Roll PDFium 6f34355..bca779d
[chromium-blink-merge.git] / chrome / service / service_main.cc
blob03b0bcb82019488f5fc0805ff76160ac40efd74c
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
3 // found in the LICENSE file.
5 #include "base/base_switches.h"
6 #include "base/debug/debugger.h"
7 #include "base/message_loop/message_loop.h"
8 #include "base/metrics/statistics_recorder.h"
9 #include "chrome/common/service_process_util.h"
10 #include "chrome/service/service_process.h"
11 #include "content/public/common/main_function_params.h"
12 #include "net/url_request/url_request.h"
14 // Mainline routine for running as the service process.
15 int ServiceProcessMain(const content::MainFunctionParams& parameters) {
16 // Chrome disallows cookies by default. All code paths that want to use
17 // cookies should go through the browser process.
18 net::URLRequest::SetDefaultCookiePolicyToBlock();
20 base::MessageLoopForUI main_message_loop;
21 main_message_loop.set_thread_name("MainThread");
22 if (parameters.command_line.HasSwitch(switches::kWaitForDebugger)) {
23 base::debug::WaitForDebugger(60, true);
26 VLOG(1) << "Service process launched: "
27 << parameters.command_line.GetCommandLineString();
29 base::PlatformThread::SetName("CrServiceMain");
30 base::StatisticsRecorder::Initialize();
32 // If there is already a service process running, quit now.
33 scoped_ptr<ServiceProcessState> state(new ServiceProcessState);
34 if (!state->Initialize())
35 return 0;
37 ServiceProcess service_process;
38 if (service_process.Initialize(&main_message_loop,
39 parameters.command_line,
40 state.release())) {
41 base::MessageLoop::current()->Run();
42 } else {
43 LOG(ERROR) << "Service process failed to initialize";
45 return 0;