| 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 | 95 |
| 96 #if defined(OS_LINUX) | 96 #if defined(OS_LINUX) |
| 97 bool StartSandboxLinux(gpu::GpuWatchdogThread*); | 97 bool StartSandboxLinux(gpu::GpuWatchdogThread*); |
| 98 #elif defined(OS_WIN) | 98 #elif defined(OS_WIN) |
| 99 bool StartSandboxWindows(const sandbox::SandboxInterfaceInfo*); | 99 bool StartSandboxWindows(const sandbox::SandboxInterfaceInfo*); |
| 100 #endif | 100 #endif |
| 101 | 101 |
| 102 base::LazyInstance<GpuChildThread::DeferredMessages> deferred_messages = | 102 base::LazyInstance<GpuChildThread::DeferredMessages> deferred_messages = |
| 103 LAZY_INSTANCE_INITIALIZER; | 103 LAZY_INSTANCE_INITIALIZER; |
| 104 | 104 |
| 105 bool GpuProcessLogMessageHandler(int severity, | 105 class GpuMainLogMessageListener : logging::LogMessageListener { |
| 106 const char* file, int line, | 106 public: |
| 107 size_t message_start, | 107 void OnMessage(int severity, |
| 108 const std::string& str) { | 108 const char* file, |
| 109 int line, |
| 110 size_t message_start, |
| 111 const std::string& str) override; |
| 112 }; |
| 113 |
| 114 void GpuMainLogMessageListener::OnMessage(int severity, |
| 115 const char* file, |
| 116 int line, |
| 117 size_t message_start, |
| 118 const std::string& str) { |
| 109 GpuChildThread::LogMessage log; | 119 GpuChildThread::LogMessage log; |
| 110 log.severity = severity; | 120 log.severity = severity; |
| 111 log.header = str.substr(0, message_start); | 121 log.header = str.substr(0, message_start); |
| 112 log.message = str.substr(message_start); | 122 log.message = str.substr(message_start); |
| 113 deferred_messages.Get().push(std::move(log)); | 123 deferred_messages.Get().push(std::move(log)); |
| 114 return false; | |
| 115 } | 124 } |
| 116 | 125 |
| 117 class ContentSandboxHelper : public gpu::GpuSandboxHelper { | 126 class ContentSandboxHelper : public gpu::GpuSandboxHelper { |
| 118 public: | 127 public: |
| 119 ContentSandboxHelper() {} | 128 ContentSandboxHelper() {} |
| 120 ~ContentSandboxHelper() override {} | 129 ~ContentSandboxHelper() override {} |
| 121 | 130 |
| 122 #if defined(OS_WIN) | 131 #if defined(OS_WIN) |
| 123 void set_sandbox_info(const sandbox::SandboxInterfaceInfo* info) { | 132 void set_sandbox_info(const sandbox::SandboxInterfaceInfo* info) { |
| 124 sandbox_info_ = info; | 133 sandbox_info_ = info; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // able to load a DLL. | 195 // able to load a DLL. |
| 187 SetErrorMode( | 196 SetErrorMode( |
| 188 SEM_FAILCRITICALERRORS | | 197 SEM_FAILCRITICALERRORS | |
| 189 SEM_NOGPFAULTERRORBOX | | 198 SEM_NOGPFAULTERRORBOX | |
| 190 SEM_NOOPENFILEERRORBOX); | 199 SEM_NOOPENFILEERRORBOX); |
| 191 #elif defined(USE_X11) | 200 #elif defined(USE_X11) |
| 192 ui::SetDefaultX11ErrorHandlers(); | 201 ui::SetDefaultX11ErrorHandlers(); |
| 193 | 202 |
| 194 #endif | 203 #endif |
| 195 | 204 |
| 196 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 205 auto log_listener = base::MakeUnique<GpuMainLogMessageListener>(); |
| 197 | 206 |
| 198 // We are experiencing what appear to be memory-stomp issues in the GPU | 207 // We are experiencing what appear to be memory-stomp issues in the GPU |
| 199 // process. These issues seem to be impacting the message loop and listeners | 208 // process. These issues seem to be impacting the message loop and listeners |
| 200 // registered to it. Create the message loop on the heap to guard against | 209 // registered to it. Create the message loop on the heap to guard against |
| 201 // this. | 210 // this. |
| 202 // TODO(ericrk): Revisit this once we assess its impact on crbug.com/662802 | 211 // TODO(ericrk): Revisit this once we assess its impact on crbug.com/662802 |
| 203 // and crbug.com/609252. | 212 // and crbug.com/609252. |
| 204 std::unique_ptr<base::MessageLoop> main_message_loop; | 213 std::unique_ptr<base::MessageLoop> main_message_loop; |
| 205 std::unique_ptr<ui::PlatformEventSource> event_source; | 214 std::unique_ptr<ui::PlatformEventSource> event_source; |
| 206 if (command_line.HasSwitch(switches::kHeadless)) { | 215 if (command_line.HasSwitch(switches::kHeadless)) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // to tear down this process. However, we can not do so safely until the IPC | 268 // to tear down this process. However, we can not do so safely until the IPC |
| 260 // channel is set up, because the detection of early return of a child process | 269 // channel is set up, because the detection of early return of a child process |
| 261 // is implemented using an IPC channel error. If the IPC channel is not fully | 270 // is implemented using an IPC channel error. If the IPC channel is not fully |
| 262 // set up between the browser and GPU process, and the GPU process crashes or | 271 // set up between the browser and GPU process, and the GPU process crashes or |
| 263 // exits early, the browser process will never detect it. For this reason we | 272 // exits early, the browser process will never detect it. For this reason we |
| 264 // defer tearing down the GPU process until receiving the GpuMsg_Initialize | 273 // defer tearing down the GPU process until receiving the GpuMsg_Initialize |
| 265 // message from the browser. | 274 // message from the browser. |
| 266 const bool init_success = gpu_init.InitializeAndStartSandbox(command_line); | 275 const bool init_success = gpu_init.InitializeAndStartSandbox(command_line); |
| 267 const bool dead_on_arrival = !init_success; | 276 const bool dead_on_arrival = !init_success; |
| 268 | 277 |
| 269 logging::SetLogMessageHandler(NULL); | 278 log_listener.reset(); |
| 270 GetContentClient()->SetGpuInfo(gpu_init.gpu_info()); | 279 GetContentClient()->SetGpuInfo(gpu_init.gpu_info()); |
| 271 | 280 |
| 272 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory; | 281 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory; |
| 273 if (init_success && | 282 if (init_success && |
| 274 gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) | 283 gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) |
| 275 gpu_memory_buffer_factory = gpu::GpuMemoryBufferFactory::CreateNativeType(); | 284 gpu_memory_buffer_factory = gpu::GpuMemoryBufferFactory::CreateNativeType(); |
| 276 | 285 |
| 277 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL; | 286 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL; |
| 278 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 287 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 279 io_thread_priority = base::ThreadPriority::DISPLAY; | 288 io_thread_priority = base::ThreadPriority::DISPLAY; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 return true; | 366 return true; |
| 358 } | 367 } |
| 359 | 368 |
| 360 return false; | 369 return false; |
| 361 } | 370 } |
| 362 #endif // defined(OS_WIN) | 371 #endif // defined(OS_WIN) |
| 363 | 372 |
| 364 } // namespace. | 373 } // namespace. |
| 365 | 374 |
| 366 } // namespace content | 375 } // namespace content |
| OLD | NEW |