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

Unified 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: revert slow, try adding back handlers Created 3 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: content/gpu/gpu_main.cc
diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc
index 2d6ea76190b1a0e4bb21bfbfecb63ab88d19b193..eb674bbe3e19de089fd66481ba2b821998365c7e 100644
--- a/content/gpu/gpu_main.cc
+++ b/content/gpu/gpu_main.cc
@@ -102,15 +102,24 @@ bool StartSandboxWindows(const sandbox::SandboxInterfaceInfo*);
base::LazyInstance<GpuChildThread::DeferredMessages> deferred_messages =
LAZY_INSTANCE_INITIALIZER;
-bool GpuProcessLogMessageHandler(int severity,
- const char* file, int line,
- size_t message_start,
- const std::string& str) {
+class GpuMainLogMessageListener : logging::LogMessageListener {
+ public:
+ void OnMessage(int severity,
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& str) override;
+};
+
+void GpuMainLogMessageListener::OnMessage(int severity,
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& str) {
std::string header = str.substr(0, message_start);
std::string message = str.substr(message_start);
deferred_messages.Get().push(
new GpuHostMsg_OnLogMessage(severity, header, message));
- return false;
}
class ContentSandboxHelper : public gpu::GpuSandboxHelper {
@@ -192,7 +201,7 @@ int GpuMain(const MainFunctionParams& parameters) {
#endif
- logging::SetLogMessageHandler(GpuProcessLogMessageHandler);
+ auto log_listener = base::MakeUnique<GpuMainLogMessageListener>();
// We are experiencing what appear to be memory-stomp issues in the GPU
// process. These issues seem to be impacting the message loop and listeners
@@ -265,7 +274,7 @@ int GpuMain(const MainFunctionParams& parameters) {
const bool init_success = gpu_init.InitializeAndStartSandbox(command_line);
const bool dead_on_arrival = !init_success;
- logging::SetLogMessageHandler(NULL);
+ log_listener.reset();
GetContentClient()->SetGpuInfo(gpu_init.gpu_info());
std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory;

Powered by Google App Engine
This is Rietveld 408576698