Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: content/gpu/gpu_main.cc

Issue 2034393004: Allow multiple logging::LogMessage{Handler,Listener}s Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use ReadWriteLock, add comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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,
126 const std::string& str) { 126 const char* file,
127 int line,
128 size_t message_start,
129 const std::string& str) override;
130 };
131
132 void GpuMainLogMessageListener::OnMessage(int severity,
133 const char* file,
134 int line,
135 size_t message_start,
136 const std::string& str) {
127 std::string header = str.substr(0, message_start); 137 std::string header = str.substr(0, message_start);
128 std::string message = str.substr(message_start); 138 std::string message = str.substr(message_start);
129 deferred_messages.Get().push( 139 deferred_messages.Get().push(
130 new GpuHostMsg_OnLogMessage(severity, header, message)); 140 new GpuHostMsg_OnLogMessage(severity, header, message));
131 return false;
132 } 141 }
133 142
134 } // namespace anonymous 143 } // namespace anonymous
135 144
136 // Main function for starting the Gpu process. 145 // Main function for starting the Gpu process.
137 int GpuMain(const MainFunctionParams& parameters) { 146 int GpuMain(const MainFunctionParams& parameters) {
138 TRACE_EVENT0("gpu", "GpuMain"); 147 TRACE_EVENT0("gpu", "GpuMain");
139 base::trace_event::TraceLog::GetInstance()->SetProcessName("GPU Process"); 148 base::trace_event::TraceLog::GetInstance()->SetProcessName("GPU Process");
140 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( 149 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex(
141 kTraceEventGpuProcessSortIndex); 150 kTraceEventGpuProcessSortIndex);
(...skipping 17 matching lines...) Expand all
159 168
160 #if !defined(OS_CHROMEOS) 169 #if !defined(OS_CHROMEOS)
161 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 170 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
162 switches::kWindowDepth)); 171 switches::kWindowDepth));
163 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 172 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
164 switches::kX11VisualID)); 173 switches::kX11VisualID));
165 #endif 174 #endif
166 175
167 #endif 176 #endif
168 177
169 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); 178 auto log_listener = base::MakeUnique<GpuMainLogMessageListener>();
170 179
171 if (command_line.HasSwitch(switches::kSupportsDualGpus)) { 180 if (command_line.HasSwitch(switches::kSupportsDualGpus)) {
172 std::string types = command_line.GetSwitchValueASCII( 181 std::string types = command_line.GetSwitchValueASCII(
173 switches::kGpuDriverBugWorkarounds); 182 switches::kGpuDriverBugWorkarounds);
174 std::set<int> workarounds; 183 std::set<int> workarounds;
175 gpu::StringToFeatureSet(types, &workarounds); 184 gpu::StringToFeatureSet(types, &workarounds);
176 if (workarounds.count(gpu::FORCE_DISCRETE_GPU) == 1) 185 if (workarounds.count(gpu::FORCE_DISCRETE_GPU) == 1)
177 ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); 186 ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu();
178 else if (workarounds.count(gpu::FORCE_INTEGRATED_GPU) == 1) 187 else if (workarounds.count(gpu::FORCE_INTEGRATED_GPU) == 1)
179 ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu(); 188 ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu();
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 } 387 }
379 #elif defined(OS_WIN) 388 #elif defined(OS_WIN)
380 gpu_info.sandboxed = StartSandboxWindows(parameters.sandbox_info); 389 gpu_info.sandboxed = StartSandboxWindows(parameters.sandbox_info);
381 #elif defined(OS_MACOSX) 390 #elif defined(OS_MACOSX)
382 gpu_info.sandboxed = Sandbox::SandboxIsCurrentlyActive(); 391 gpu_info.sandboxed = Sandbox::SandboxIsCurrentlyActive();
383 #endif 392 #endif
384 } else { 393 } else {
385 dead_on_arrival = true; 394 dead_on_arrival = true;
386 } 395 }
387 396
388 logging::SetLogMessageHandler(NULL); 397 log_listener.reset();
389 398
390 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory; 399 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory;
391 if (gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) 400 if (gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER)
392 gpu_memory_buffer_factory = gpu::GpuMemoryBufferFactory::CreateNativeType(); 401 gpu_memory_buffer_factory = gpu::GpuMemoryBufferFactory::CreateNativeType();
393 402
394 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL; 403 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL;
395 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 404 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
396 io_thread_priority = base::ThreadPriority::DISPLAY; 405 io_thread_priority = base::ThreadPriority::DISPLAY;
397 #endif 406 #endif
398 407
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 return true; 630 return true;
622 } 631 }
623 632
624 return false; 633 return false;
625 } 634 }
626 #endif // defined(OS_WIN) 635 #endif // defined(OS_WIN)
627 636
628 } // namespace. 637 } // namespace.
629 638
630 } // namespace content 639 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698