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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 #if defined(OS_LINUX) | 95 #if defined(OS_LINUX) |
96 bool StartSandboxLinux(gpu::GpuWatchdogThread*); | 96 bool StartSandboxLinux(gpu::GpuWatchdogThread*); |
97 #elif defined(OS_WIN) | 97 #elif defined(OS_WIN) |
98 bool StartSandboxWindows(const sandbox::SandboxInterfaceInfo*); | 98 bool StartSandboxWindows(const sandbox::SandboxInterfaceInfo*); |
99 #endif | 99 #endif |
100 | 100 |
101 base::LazyInstance<GpuChildThread::DeferredMessages> deferred_messages = | 101 base::LazyInstance<GpuChildThread::DeferredMessages> deferred_messages = |
102 LAZY_INSTANCE_INITIALIZER; | 102 LAZY_INSTANCE_INITIALIZER; |
103 | 103 |
104 bool GpuProcessLogMessageHandler(int severity, | 104 class GpuMainLogMessageListener : logging::LogMessageListener { |
105 const char* file, int line, | 105 public: |
106 size_t message_start, | 106 void OnMessage(int severity, |
107 const std::string& str) { | 107 const char* file, |
| 108 int line, |
| 109 size_t message_start, |
| 110 const std::string& str) override; |
| 111 }; |
| 112 |
| 113 void GpuMainLogMessageListener::OnMessage(int severity, |
| 114 const char* file, |
| 115 int line, |
| 116 size_t message_start, |
| 117 const std::string& str) { |
108 std::string header = str.substr(0, message_start); | 118 std::string header = str.substr(0, message_start); |
109 std::string message = str.substr(message_start); | 119 std::string message = str.substr(message_start); |
110 deferred_messages.Get().push( | 120 deferred_messages.Get().push( |
111 new GpuHostMsg_OnLogMessage(severity, header, message)); | 121 new GpuHostMsg_OnLogMessage(severity, header, message)); |
112 return false; | |
113 } | 122 } |
114 | 123 |
115 class ContentSandboxHelper : public gpu::GpuSandboxHelper { | 124 class ContentSandboxHelper : public gpu::GpuSandboxHelper { |
116 public: | 125 public: |
117 ContentSandboxHelper() {} | 126 ContentSandboxHelper() {} |
118 ~ContentSandboxHelper() override {} | 127 ~ContentSandboxHelper() override {} |
119 | 128 |
120 #if defined(OS_WIN) | 129 #if defined(OS_WIN) |
121 void set_sandbox_info(const sandbox::SandboxInterfaceInfo* info) { | 130 void set_sandbox_info(const sandbox::SandboxInterfaceInfo* info) { |
122 sandbox_info_ = info; | 131 sandbox_info_ = info; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // able to load a DLL. | 193 // able to load a DLL. |
185 SetErrorMode( | 194 SetErrorMode( |
186 SEM_FAILCRITICALERRORS | | 195 SEM_FAILCRITICALERRORS | |
187 SEM_NOGPFAULTERRORBOX | | 196 SEM_NOGPFAULTERRORBOX | |
188 SEM_NOOPENFILEERRORBOX); | 197 SEM_NOOPENFILEERRORBOX); |
189 #elif defined(USE_X11) | 198 #elif defined(USE_X11) |
190 ui::SetDefaultX11ErrorHandlers(); | 199 ui::SetDefaultX11ErrorHandlers(); |
191 | 200 |
192 #endif | 201 #endif |
193 | 202 |
194 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 203 auto log_listener = base::MakeUnique<GpuMainLogMessageListener>(); |
195 | 204 |
196 #if defined(OS_WIN) | 205 #if defined(OS_WIN) |
197 // OK to use default non-UI message loop because all GPU windows run on | 206 // OK to use default non-UI message loop because all GPU windows run on |
198 // dedicated thread. | 207 // dedicated thread. |
199 base::MessageLoop main_message_loop(base::MessageLoop::TYPE_DEFAULT); | 208 base::MessageLoop main_message_loop(base::MessageLoop::TYPE_DEFAULT); |
200 #elif defined(USE_X11) | 209 #elif defined(USE_X11) |
201 // We need a UI loop so that we can grab the Expose events. See GLSurfaceGLX | 210 // We need a UI loop so that we can grab the Expose events. See GLSurfaceGLX |
202 // and https://crbug.com/326995. | 211 // and https://crbug.com/326995. |
203 base::MessageLoop main_message_loop(base::MessageLoop::TYPE_UI); | 212 base::MessageLoop main_message_loop(base::MessageLoop::TYPE_UI); |
204 std::unique_ptr<ui::PlatformEventSource> event_source = | 213 std::unique_ptr<ui::PlatformEventSource> event_source = |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 // to tear down this process. However, we can not do so safely until the IPC | 251 // to tear down this process. However, we can not do so safely until the IPC |
243 // channel is set up, because the detection of early return of a child process | 252 // channel is set up, because the detection of early return of a child process |
244 // is implemented using an IPC channel error. If the IPC channel is not fully | 253 // is implemented using an IPC channel error. If the IPC channel is not fully |
245 // set up between the browser and GPU process, and the GPU process crashes or | 254 // set up between the browser and GPU process, and the GPU process crashes or |
246 // exits early, the browser process will never detect it. For this reason we | 255 // exits early, the browser process will never detect it. For this reason we |
247 // defer tearing down the GPU process until receiving the GpuMsg_Initialize | 256 // defer tearing down the GPU process until receiving the GpuMsg_Initialize |
248 // message from the browser. | 257 // message from the browser. |
249 const bool init_success = gpu_init.InitializeAndStartSandbox(command_line); | 258 const bool init_success = gpu_init.InitializeAndStartSandbox(command_line); |
250 const bool dead_on_arrival = !init_success; | 259 const bool dead_on_arrival = !init_success; |
251 | 260 |
252 logging::SetLogMessageHandler(NULL); | 261 log_listener.reset(); |
253 GetContentClient()->SetGpuInfo(gpu_init.gpu_info()); | 262 GetContentClient()->SetGpuInfo(gpu_init.gpu_info()); |
254 | 263 |
255 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory; | 264 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory; |
256 if (init_success && | 265 if (init_success && |
257 gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) | 266 gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) |
258 gpu_memory_buffer_factory = gpu::GpuMemoryBufferFactory::CreateNativeType(); | 267 gpu_memory_buffer_factory = gpu::GpuMemoryBufferFactory::CreateNativeType(); |
259 | 268 |
260 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL; | 269 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL; |
261 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 270 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
262 io_thread_priority = base::ThreadPriority::DISPLAY; | 271 io_thread_priority = base::ThreadPriority::DISPLAY; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 return true; | 349 return true; |
341 } | 350 } |
342 | 351 |
343 return false; | 352 return false; |
344 } | 353 } |
345 #endif // defined(OS_WIN) | 354 #endif // defined(OS_WIN) |
346 | 355 |
347 } // namespace. | 356 } // namespace. |
348 | 357 |
349 } // namespace content | 358 } // namespace content |
OLD | NEW |