| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 bool GpuProcessLogMessageHandler(int severity, |
| 105 const char* file, int line, | 105 const std::string& file, |
| 106 size_t message_start, | 106 int line, |
| 107 const std::string& str) { | 107 const std::string& str) { |
| 108 std::string header = str.substr(0, message_start); | 108 std::string header = file + "(" + std::to_string(line) + "):"; |
| 109 std::string message = str.substr(message_start); | |
| 110 deferred_messages.Get().push( | 109 deferred_messages.Get().push( |
| 111 new GpuHostMsg_OnLogMessage(severity, header, message)); | 110 new GpuHostMsg_OnLogMessage(severity, header, str)); |
| 112 return false; | 111 return false; |
| 113 } | 112 } |
| 114 | 113 |
| 115 class ContentSandboxHelper : public gpu::GpuSandboxHelper { | 114 class ContentSandboxHelper : public gpu::GpuSandboxHelper { |
| 116 public: | 115 public: |
| 117 ContentSandboxHelper() {} | 116 ContentSandboxHelper() {} |
| 118 ~ContentSandboxHelper() override {} | 117 ~ContentSandboxHelper() override {} |
| 119 | 118 |
| 120 #if defined(OS_WIN) | 119 #if defined(OS_WIN) |
| 121 void set_sandbox_info(const sandbox::SandboxInterfaceInfo* info) { | 120 void set_sandbox_info(const sandbox::SandboxInterfaceInfo* info) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 // able to load a DLL. | 183 // able to load a DLL. |
| 185 SetErrorMode( | 184 SetErrorMode( |
| 186 SEM_FAILCRITICALERRORS | | 185 SEM_FAILCRITICALERRORS | |
| 187 SEM_NOGPFAULTERRORBOX | | 186 SEM_NOGPFAULTERRORBOX | |
| 188 SEM_NOOPENFILEERRORBOX); | 187 SEM_NOOPENFILEERRORBOX); |
| 189 #elif defined(USE_X11) | 188 #elif defined(USE_X11) |
| 190 ui::SetDefaultX11ErrorHandlers(); | 189 ui::SetDefaultX11ErrorHandlers(); |
| 191 | 190 |
| 192 #endif | 191 #endif |
| 193 | 192 |
| 194 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 193 logging::AddLogMessageHandler(GpuProcessLogMessageHandler); |
| 195 | 194 |
| 196 #if defined(OS_WIN) | 195 #if defined(OS_WIN) |
| 197 // OK to use default non-UI message loop because all GPU windows run on | 196 // OK to use default non-UI message loop because all GPU windows run on |
| 198 // dedicated thread. | 197 // dedicated thread. |
| 199 base::MessageLoop main_message_loop(base::MessageLoop::TYPE_DEFAULT); | 198 base::MessageLoop main_message_loop(base::MessageLoop::TYPE_DEFAULT); |
| 200 #elif defined(USE_X11) | 199 #elif defined(USE_X11) |
| 201 // We need a UI loop so that we can grab the Expose events. See GLSurfaceGLX | 200 // We need a UI loop so that we can grab the Expose events. See GLSurfaceGLX |
| 202 // and https://crbug.com/326995. | 201 // and https://crbug.com/326995. |
| 203 base::MessageLoop main_message_loop(base::MessageLoop::TYPE_UI); | 202 base::MessageLoop main_message_loop(base::MessageLoop::TYPE_UI); |
| 204 std::unique_ptr<ui::PlatformEventSource> event_source = | 203 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 | 241 // 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 | 242 // 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 | 243 // 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 | 244 // 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 | 245 // 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 | 246 // defer tearing down the GPU process until receiving the GpuMsg_Initialize |
| 248 // message from the browser. | 247 // message from the browser. |
| 249 const bool init_success = gpu_init.InitializeAndStartSandbox(command_line); | 248 const bool init_success = gpu_init.InitializeAndStartSandbox(command_line); |
| 250 const bool dead_on_arrival = !init_success; | 249 const bool dead_on_arrival = !init_success; |
| 251 | 250 |
| 252 logging::SetLogMessageHandler(NULL); | 251 logging::RemoveLogMessageHandler(GpuProcessLogMessageHandler); |
| 253 GetContentClient()->SetGpuInfo(gpu_init.gpu_info()); | 252 GetContentClient()->SetGpuInfo(gpu_init.gpu_info()); |
| 254 | 253 |
| 255 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory; | 254 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory; |
| 256 if (init_success && | 255 if (init_success && |
| 257 gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) | 256 gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) |
| 258 gpu_memory_buffer_factory = gpu::GpuMemoryBufferFactory::CreateNativeType(); | 257 gpu_memory_buffer_factory = gpu::GpuMemoryBufferFactory::CreateNativeType(); |
| 259 | 258 |
| 260 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL; | 259 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL; |
| 261 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 260 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 262 io_thread_priority = base::ThreadPriority::DISPLAY; | 261 io_thread_priority = base::ThreadPriority::DISPLAY; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 return true; | 339 return true; |
| 341 } | 340 } |
| 342 | 341 |
| 343 return false; | 342 return false; |
| 344 } | 343 } |
| 345 #endif // defined(OS_WIN) | 344 #endif // defined(OS_WIN) |
| 346 | 345 |
| 347 } // namespace. | 346 } // namespace. |
| 348 | 347 |
| 349 } // namespace content | 348 } // namespace content |
| OLD | NEW |