| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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. | |
| 4 | |
| 5 #include <stdlib.h> | |
| 6 | |
| 7 #if defined(OS_WIN) | |
| 8 #include <windows.h> | |
| 9 #endif | |
| 10 | |
| 11 #include "app/win/scoped_com_initializer.h" | |
| 12 #include "base/environment.h" | |
| 13 #include "base/message_loop.h" | |
| 14 #include "base/stringprintf.h" | |
| 15 #include "base/threading/platform_thread.h" | |
| 16 #include "build/build_config.h" | |
| 17 #include "content/common/content_switches.h" | |
| 18 #include "content/common/main_function_params.h" | |
| 19 #include "chrome/gpu/gpu_config.h" | |
| 20 #include "chrome/gpu/gpu_process.h" | |
| 21 #include "chrome/gpu/gpu_thread.h" | |
| 22 | |
| 23 #if defined(OS_MACOSX) | |
| 24 #include "content/common/chrome_application_mac.h" | |
| 25 #endif | |
| 26 | |
| 27 #if defined(USE_X11) | |
| 28 #include "ui/base/x/x11_util.h" | |
| 29 #endif | |
| 30 | |
| 31 // Main function for starting the Gpu process. | |
| 32 int GpuMain(const MainFunctionParams& parameters) { | |
| 33 base::Time start_time = base::Time::Now(); | |
| 34 | |
| 35 const CommandLine& command_line = parameters.command_line_; | |
| 36 if (command_line.HasSwitch(switches::kGpuStartupDialog)) { | |
| 37 ChildProcess::WaitForDebugger("Gpu"); | |
| 38 } | |
| 39 | |
| 40 #if defined(OS_MACOSX) | |
| 41 chrome_application_mac::RegisterCrApp(); | |
| 42 #endif | |
| 43 | |
| 44 MessageLoop main_message_loop(MessageLoop::TYPE_UI); | |
| 45 base::PlatformThread::SetName("CrGpuMain"); | |
| 46 | |
| 47 if (!command_line.HasSwitch(switches::kSingleProcess)) { | |
| 48 #if defined(OS_WIN) | |
| 49 // Prevent Windows from displaying a modal dialog on failures like not being | |
| 50 // able to load a DLL. | |
| 51 SetErrorMode( | |
| 52 SEM_FAILCRITICALERRORS | | |
| 53 SEM_NOGPFAULTERRORBOX | | |
| 54 SEM_NOOPENFILEERRORBOX); | |
| 55 #elif defined(USE_X11) | |
| 56 ui::SetDefaultX11ErrorHandlers(); | |
| 57 #endif | |
| 58 } | |
| 59 | |
| 60 app::win::ScopedCOMInitializer com_initializer; | |
| 61 | |
| 62 // We can not tolerate early returns from this code, because the | |
| 63 // detection of early return of a child process is implemented using | |
| 64 // an IPC channel error. If the IPC channel is not fully set up | |
| 65 // between the browser and GPU process, and the GPU process crashes | |
| 66 // or exits early, the browser process will never detect it. For | |
| 67 // this reason we defer all work related to the GPU until receiving | |
| 68 // the GpuMsg_Initialize message from the browser. | |
| 69 GpuProcess gpu_process; | |
| 70 | |
| 71 GpuThread* gpu_thread = | |
| 72 #if defined(OS_WIN) | |
| 73 new GpuThread(parameters.sandbox_info_.TargetServices()); | |
| 74 #else | |
| 75 new GpuThread; | |
| 76 #endif | |
| 77 | |
| 78 gpu_thread->Init(start_time); | |
| 79 | |
| 80 gpu_process.set_main_thread(gpu_thread); | |
| 81 | |
| 82 main_message_loop.Run(); | |
| 83 | |
| 84 gpu_thread->StopWatchdog(); | |
| 85 | |
| 86 return 0; | |
| 87 } | |
| OLD | NEW |