Fix crash on app list start page contents not existing.
[chromium-blink-merge.git] / content / ppapi_plugin / ppapi_broker_main.cc
blobb441d7a6b9f6451edef4ce75c92c72d391dded2c
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/message_loop/message_loop.h"
6 #include "base/threading/platform_thread.h"
7 #include "build/build_config.h"
8 #include "content/child/child_process.h"
9 #include "content/common/content_constants_internal.h"
10 #include "content/ppapi_plugin/ppapi_thread.h"
11 #include "content/public/common/content_switches.h"
12 #include "content/public/common/main_function_params.h"
14 namespace content {
16 // Main function for starting the PPAPI broker process.
17 int PpapiBrokerMain(const MainFunctionParams& parameters) {
18 const base::CommandLine& command_line = parameters.command_line;
19 if (command_line.HasSwitch(switches::kPpapiStartupDialog)) {
20 ChildProcess::WaitForDebugger("PpapiBroker");
23 base::MessageLoop main_message_loop;
24 base::PlatformThread::SetName("CrPPAPIBrokerMain");
25 base::trace_event::TraceLog::GetInstance()->SetProcessName(
26 "PPAPI Broker Process");
27 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex(
28 kTraceEventPpapiBrokerProcessSortIndex);
30 ChildProcess ppapi_broker_process;
31 ppapi_broker_process.set_main_thread(
32 new PpapiThread(parameters.command_line, true)); // Broker.
34 main_message_loop.Run();
35 DVLOG(1) << "PpapiBrokerMain exiting";
36 return 0;
39 } // namespace content