OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 <dwmapi.h> | 8 #include <dwmapi.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #endif | 10 #endif |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #endif | 44 #endif |
45 | 45 |
46 #if defined(USE_X11) | 46 #if defined(USE_X11) |
47 #include "ui/base/x/x11_util.h" | 47 #include "ui/base/x/x11_util.h" |
48 #endif | 48 #endif |
49 | 49 |
50 #if defined(OS_LINUX) | 50 #if defined(OS_LINUX) |
51 #include "content/public/common/sandbox_init.h" | 51 #include "content/public/common/sandbox_init.h" |
52 #endif | 52 #endif |
53 | 53 |
| 54 #if defined(OS_MACOSX) |
| 55 #include "base/message_loop/message_pump_mac.h" |
| 56 #endif |
| 57 |
54 const int kGpuTimeout = 10000; | 58 const int kGpuTimeout = 10000; |
55 | 59 |
56 namespace content { | 60 namespace content { |
57 | 61 |
58 namespace { | 62 namespace { |
59 | 63 |
60 bool WarmUpSandbox(const CommandLine& command_line); | 64 bool WarmUpSandbox(const CommandLine& command_line); |
61 #if defined(OS_LINUX) | 65 #if defined(OS_LINUX) |
62 bool StartSandboxLinux(const gpu::GPUInfo&, GpuWatchdogThread*, bool); | 66 bool StartSandboxLinux(const gpu::GPUInfo&, GpuWatchdogThread*, bool); |
63 #elif defined(OS_WIN) | 67 #elif defined(OS_WIN) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // will need to tear down this process. However, we can not do so | 126 // will need to tear down this process. However, we can not do so |
123 // safely until the IPC channel is set up, because the detection of | 127 // safely until the IPC channel is set up, because the detection of |
124 // early return of a child process is implemented using an IPC | 128 // early return of a child process is implemented using an IPC |
125 // channel error. If the IPC channel is not fully set up between the | 129 // channel error. If the IPC channel is not fully set up between the |
126 // browser and GPU process, and the GPU process crashes or exits | 130 // browser and GPU process, and the GPU process crashes or exits |
127 // early, the browser process will never detect it. For this reason | 131 // early, the browser process will never detect it. For this reason |
128 // we defer tearing down the GPU process until receiving the | 132 // we defer tearing down the GPU process until receiving the |
129 // GpuMsg_Initialize message from the browser. | 133 // GpuMsg_Initialize message from the browser. |
130 bool dead_on_arrival = false; | 134 bool dead_on_arrival = false; |
131 | 135 |
| 136 #if defined(OS_WIN) |
132 base::MessageLoop::Type message_loop_type = base::MessageLoop::TYPE_IO; | 137 base::MessageLoop::Type message_loop_type = base::MessageLoop::TYPE_IO; |
133 #if defined(OS_WIN) | |
134 // Unless we're running on desktop GL, we don't need a UI message | 138 // Unless we're running on desktop GL, we don't need a UI message |
135 // loop, so avoid its use to work around apparent problems with some | 139 // loop, so avoid its use to work around apparent problems with some |
136 // third-party software. | 140 // third-party software. |
137 if (command_line.HasSwitch(switches::kUseGL) && | 141 if (command_line.HasSwitch(switches::kUseGL) && |
138 command_line.GetSwitchValueASCII(switches::kUseGL) == | 142 command_line.GetSwitchValueASCII(switches::kUseGL) == |
139 gfx::kGLImplementationDesktopName) { | 143 gfx::kGLImplementationDesktopName) { |
140 message_loop_type = base::MessageLoop::TYPE_UI; | 144 message_loop_type = base::MessageLoop::TYPE_UI; |
141 } | 145 } |
| 146 base::MessageLoop main_message_loop(message_loop_type); |
142 #elif defined(OS_LINUX) | 147 #elif defined(OS_LINUX) |
143 message_loop_type = base::MessageLoop::TYPE_DEFAULT; | 148 base::MessageLoop main_message_loop(base::MessageLoop::TYPE_DEFAULT); |
| 149 #elif defined(OS_MACOSX) |
| 150 // This is necessary for CoreAnimation layers hosted in the GPU process to be |
| 151 // drawn. See http://crbug.com/312462. |
| 152 scoped_ptr<base::MessagePump> pump(new base::MessagePumpCFRunLoop()); |
| 153 base::MessageLoop main_message_loop(pump.Pass()); |
| 154 #else |
| 155 base::MessageLoop main_message_loop(base::MessageLoop::TYPE_IO); |
144 #endif | 156 #endif |
145 | 157 |
146 base::MessageLoop main_message_loop(message_loop_type); | |
147 base::PlatformThread::SetName("CrGpuMain"); | 158 base::PlatformThread::SetName("CrGpuMain"); |
148 | 159 |
149 // In addition to disabling the watchdog if the command line switch is | 160 // In addition to disabling the watchdog if the command line switch is |
150 // present, disable the watchdog on valgrind because the code is expected | 161 // present, disable the watchdog on valgrind because the code is expected |
151 // to run slowly in that case. | 162 // to run slowly in that case. |
152 bool enable_watchdog = | 163 bool enable_watchdog = |
153 !command_line.HasSwitch(switches::kDisableGpuWatchdog) && | 164 !command_line.HasSwitch(switches::kDisableGpuWatchdog) && |
154 !RunningOnValgrind(); | 165 !RunningOnValgrind(); |
155 | 166 |
156 // Disable the watchdog in debug builds because they tend to only be run by | 167 // Disable the watchdog in debug builds because they tend to only be run by |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 return true; | 461 return true; |
451 } | 462 } |
452 | 463 |
453 return false; | 464 return false; |
454 } | 465 } |
455 #endif // defined(OS_WIN) | 466 #endif // defined(OS_WIN) |
456 | 467 |
457 } // namespace. | 468 } // namespace. |
458 | 469 |
459 } // namespace content | 470 } // namespace content |
OLD | NEW |