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