| 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 <stdlib.h> | 5 #include <stdlib.h> |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 // Main function for starting the Gpu process. | 35 // Main function for starting the Gpu process. |
| 36 int GpuMain(const MainFunctionParams& parameters) { | 36 int GpuMain(const MainFunctionParams& parameters) { |
| 37 base::Time start_time = base::Time::Now(); | 37 base::Time start_time = base::Time::Now(); |
| 38 | 38 |
| 39 const CommandLine& command_line = parameters.command_line_; | 39 const CommandLine& command_line = parameters.command_line_; |
| 40 if (command_line.HasSwitch(switches::kGpuStartupDialog)) { | 40 if (command_line.HasSwitch(switches::kGpuStartupDialog)) { |
| 41 ChildProcess::WaitForDebugger("Gpu"); | 41 ChildProcess::WaitForDebugger("Gpu"); |
| 42 } | 42 } |
| 43 | 43 |
| 44 if (!command_line.HasSwitch(switches::kSingleProcess)) { |
| 45 #if defined(OS_WIN) |
| 46 // Prevent Windows from displaying a modal dialog on failures like not being |
| 47 // able to load a DLL. |
| 48 SetErrorMode( |
| 49 SEM_FAILCRITICALERRORS | |
| 50 SEM_NOGPFAULTERRORBOX | |
| 51 SEM_NOOPENFILEERRORBOX); |
| 52 #elif defined(USE_X11) |
| 53 ui::SetDefaultX11ErrorHandlers(); |
| 54 #endif |
| 55 } |
| 56 |
| 44 // Initialization of the OpenGL bindings may fail, in which case we | 57 // Initialization of the OpenGL bindings may fail, in which case we |
| 45 // will need to tear down this process. However, we can not do so | 58 // will need to tear down this process. However, we can not do so |
| 46 // safely until the IPC channel is set up, because the detection of | 59 // safely until the IPC channel is set up, because the detection of |
| 47 // early return of a child process is implemented using an IPC | 60 // early return of a child process is implemented using an IPC |
| 48 // channel error. If the IPC channel is not fully set up between the | 61 // channel error. If the IPC channel is not fully set up between the |
| 49 // browser and GPU process, and the GPU process crashes or exits | 62 // browser and GPU process, and the GPU process crashes or exits |
| 50 // early, the browser process will never detect it. For this reason | 63 // early, the browser process will never detect it. For this reason |
| 51 // we defer tearing down the GPU process until receiving the | 64 // we defer tearing down the GPU process until receiving the |
| 52 // GpuMsg_Initialize message from the browser. | 65 // GpuMsg_Initialize message from the browser. |
| 53 bool dead_on_arrival = false; | 66 bool dead_on_arrival = false; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 if (command_line.HasSwitch(switches::kUseGL) && | 98 if (command_line.HasSwitch(switches::kUseGL) && |
| 86 command_line.GetSwitchValueASCII(switches::kUseGL) == | 99 command_line.GetSwitchValueASCII(switches::kUseGL) == |
| 87 gfx::kGLImplementationDesktopName) { | 100 gfx::kGLImplementationDesktopName) { |
| 88 message_loop_type = MessageLoop::TYPE_UI; | 101 message_loop_type = MessageLoop::TYPE_UI; |
| 89 } | 102 } |
| 90 #endif | 103 #endif |
| 91 | 104 |
| 92 MessageLoop main_message_loop(message_loop_type); | 105 MessageLoop main_message_loop(message_loop_type); |
| 93 base::PlatformThread::SetName("CrGpuMain"); | 106 base::PlatformThread::SetName("CrGpuMain"); |
| 94 | 107 |
| 95 if (!command_line.HasSwitch(switches::kSingleProcess)) { | |
| 96 #if defined(OS_WIN) | |
| 97 // Prevent Windows from displaying a modal dialog on failures like not being | |
| 98 // able to load a DLL. | |
| 99 SetErrorMode( | |
| 100 SEM_FAILCRITICALERRORS | | |
| 101 SEM_NOGPFAULTERRORBOX | | |
| 102 SEM_NOOPENFILEERRORBOX); | |
| 103 #elif defined(USE_X11) | |
| 104 ui::SetDefaultX11ErrorHandlers(); | |
| 105 #endif | |
| 106 } | |
| 107 | |
| 108 GpuProcess gpu_process; | 108 GpuProcess gpu_process; |
| 109 | 109 |
| 110 GpuChildThread* child_thread = new GpuChildThread(dead_on_arrival); | 110 GpuChildThread* child_thread = new GpuChildThread(dead_on_arrival); |
| 111 | 111 |
| 112 child_thread->Init(start_time); | 112 child_thread->Init(start_time); |
| 113 | 113 |
| 114 gpu_process.set_main_thread(child_thread); | 114 gpu_process.set_main_thread(child_thread); |
| 115 | 115 |
| 116 main_message_loop.Run(); | 116 main_message_loop.Run(); |
| 117 | 117 |
| 118 child_thread->StopWatchdog(); | 118 child_thread->StopWatchdog(); |
| 119 | 119 |
| 120 return 0; | 120 return 0; |
| 121 } | 121 } |
| OLD | NEW |