| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 bool CanAccessNvidiaDeviceFile(); | 112 bool CanAccessNvidiaDeviceFile(); |
| 113 #endif | 113 #endif |
| 114 bool StartSandboxLinux(const gpu::GPUInfo&, GpuWatchdogThread*, bool); | 114 bool StartSandboxLinux(const gpu::GPUInfo&, GpuWatchdogThread*, bool); |
| 115 #elif defined(OS_WIN) | 115 #elif defined(OS_WIN) |
| 116 bool StartSandboxWindows(const sandbox::SandboxInterfaceInfo*); | 116 bool StartSandboxWindows(const sandbox::SandboxInterfaceInfo*); |
| 117 #endif | 117 #endif |
| 118 | 118 |
| 119 base::LazyInstance<GpuChildThread::DeferredMessages> deferred_messages = | 119 base::LazyInstance<GpuChildThread::DeferredMessages> deferred_messages = |
| 120 LAZY_INSTANCE_INITIALIZER; | 120 LAZY_INSTANCE_INITIALIZER; |
| 121 | 121 |
| 122 bool GpuProcessLogMessageHandler(int severity, | 122 class GpuMainLogMessageListener : logging::LogMessageListener { |
| 123 const char* file, int line, | 123 public: |
| 124 size_t message_start, | 124 void OnMessage(int severity, const char* file, int line, |
| 125 const std::string& str) { | 125 size_t message_start, const std::string& str) override; |
| 126 }; |
| 127 |
| 128 void GpuMainLogMessageListener::OnMessage(int severity, const char* file, |
| 129 int line, size_t message_start, const std::string& str) { |
| 126 std::string header = str.substr(0, message_start); | 130 std::string header = str.substr(0, message_start); |
| 127 std::string message = str.substr(message_start); | 131 std::string message = str.substr(message_start); |
| 128 deferred_messages.Get().push( | 132 deferred_messages.Get().push( |
| 129 new GpuHostMsg_OnLogMessage(severity, header, message)); | 133 new GpuHostMsg_OnLogMessage(severity, header, message)); |
| 130 return false; | |
| 131 } | 134 } |
| 132 | 135 |
| 133 } // namespace anonymous | 136 } // namespace anonymous |
| 134 | 137 |
| 135 // Main function for starting the Gpu process. | 138 // Main function for starting the Gpu process. |
| 136 int GpuMain(const MainFunctionParams& parameters) { | 139 int GpuMain(const MainFunctionParams& parameters) { |
| 137 TRACE_EVENT0("gpu", "GpuMain"); | 140 TRACE_EVENT0("gpu", "GpuMain"); |
| 138 base::trace_event::TraceLog::GetInstance()->SetProcessName("GPU Process"); | 141 base::trace_event::TraceLog::GetInstance()->SetProcessName("GPU Process"); |
| 139 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( | 142 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( |
| 140 kTraceEventGpuProcessSortIndex); | 143 kTraceEventGpuProcessSortIndex); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 158 | 161 |
| 159 #if !defined(OS_CHROMEOS) | 162 #if !defined(OS_CHROMEOS) |
| 160 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 163 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 161 switches::kWindowDepth)); | 164 switches::kWindowDepth)); |
| 162 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 165 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 163 switches::kX11VisualID)); | 166 switches::kX11VisualID)); |
| 164 #endif | 167 #endif |
| 165 | 168 |
| 166 #endif | 169 #endif |
| 167 | 170 |
| 168 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 171 auto log_listener = base::MakeUnique<GpuMainLogMessageListener>(); |
| 169 | 172 |
| 170 if (command_line.HasSwitch(switches::kSupportsDualGpus)) { | 173 if (command_line.HasSwitch(switches::kSupportsDualGpus)) { |
| 171 std::string types = command_line.GetSwitchValueASCII( | 174 std::string types = command_line.GetSwitchValueASCII( |
| 172 switches::kGpuDriverBugWorkarounds); | 175 switches::kGpuDriverBugWorkarounds); |
| 173 std::set<int> workarounds; | 176 std::set<int> workarounds; |
| 174 gpu::StringToFeatureSet(types, &workarounds); | 177 gpu::StringToFeatureSet(types, &workarounds); |
| 175 if (workarounds.count(gpu::FORCE_DISCRETE_GPU) == 1) | 178 if (workarounds.count(gpu::FORCE_DISCRETE_GPU) == 1) |
| 176 ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); | 179 ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); |
| 177 else if (workarounds.count(gpu::FORCE_INTEGRATED_GPU) == 1) | 180 else if (workarounds.count(gpu::FORCE_INTEGRATED_GPU) == 1) |
| 178 ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu(); | 181 ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu(); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 } | 380 } |
| 378 #elif defined(OS_WIN) | 381 #elif defined(OS_WIN) |
| 379 gpu_info.sandboxed = StartSandboxWindows(parameters.sandbox_info); | 382 gpu_info.sandboxed = StartSandboxWindows(parameters.sandbox_info); |
| 380 #elif defined(OS_MACOSX) | 383 #elif defined(OS_MACOSX) |
| 381 gpu_info.sandboxed = Sandbox::SandboxIsCurrentlyActive(); | 384 gpu_info.sandboxed = Sandbox::SandboxIsCurrentlyActive(); |
| 382 #endif | 385 #endif |
| 383 } else { | 386 } else { |
| 384 dead_on_arrival = true; | 387 dead_on_arrival = true; |
| 385 } | 388 } |
| 386 | 389 |
| 387 logging::SetLogMessageHandler(NULL); | 390 log_listener.reset(); |
| 388 | 391 |
| 389 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory; | 392 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory; |
| 390 if (gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) | 393 if (gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) |
| 391 gpu_memory_buffer_factory = gpu::GpuMemoryBufferFactory::CreateNativeType(); | 394 gpu_memory_buffer_factory = gpu::GpuMemoryBufferFactory::CreateNativeType(); |
| 392 | 395 |
| 393 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL; | 396 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL; |
| 394 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 397 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 395 io_thread_priority = base::ThreadPriority::DISPLAY; | 398 io_thread_priority = base::ThreadPriority::DISPLAY; |
| 396 #endif | 399 #endif |
| 397 | 400 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 return true; | 622 return true; |
| 620 } | 623 } |
| 621 | 624 |
| 622 return false; | 625 return false; |
| 623 } | 626 } |
| 624 #endif // defined(OS_WIN) | 627 #endif // defined(OS_WIN) |
| 625 | 628 |
| 626 } // namespace. | 629 } // namespace. |
| 627 | 630 |
| 628 } // namespace content | 631 } // namespace content |
| OLD | NEW |