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

Unified Diff: content/gpu/gpu_child_thread.cc

Issue 2034393004: Allow multiple logging::LogMessage{Handler,Listener}s Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: only keep scoped API Created 4 years, 5 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_child_thread.cc
diff --git a/content/gpu/gpu_child_thread.cc b/content/gpu/gpu_child_thread.cc
index d6720d4a8e703f1ad8c5a57735ead354af6c9b5a..fa91a6f35901a1e71f612ed403110d76cb584dea 100644
--- a/content/gpu/gpu_child_thread.cc
+++ b/content/gpu/gpu_child_thread.cc
@@ -63,19 +63,6 @@ base::LazyInstance<base::ThreadLocalPointer<GpuChildThread>> g_lazy_tls =
static base::LazyInstance<scoped_refptr<ThreadSafeSender> >
g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER;
-bool GpuProcessLogMessageHandler(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);
-
- g_thread_safe_sender.Get()->Send(
- new GpuHostMsg_OnLogMessage(severity, header, message));
-
- return false;
-}
-
// Message filter used to to handle GpuMsg_CreateGpuMemoryBuffer messages
// on the IO thread. This allows the UI thread in the browser process to remain
// fast at all times.
@@ -144,6 +131,15 @@ ChildThreadImpl::Options GetOptions(
} // namespace
+void GpuProcessLogMessageListener::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);
+
+ g_thread_safe_sender.Get()->Send(
+ new GpuHostMsg_OnLogMessage(severity, header, message));
+}
+
// static
GpuChildThread* GpuChildThread::current() {
return g_lazy_tls.Pointer()->Get();
@@ -208,7 +204,8 @@ GpuChildThread::~GpuChildThread() {
void GpuChildThread::Shutdown() {
ChildThreadImpl::Shutdown();
- logging::SetLogMessageHandler(NULL);
+ if (!in_browser_process_)
+ log_listener_.reset();
}
void GpuChildThread::Init(const base::Time& process_start_time) {
@@ -378,7 +375,7 @@ void GpuChildThread::OnInitialize(const gpu::GpuPreferences& gpu_preferences) {
// We don't need to pipe log messages if we are running the GPU thread in
// the browser process.
if (!in_browser_process_)
- logging::SetLogMessageHandler(GpuProcessLogMessageHandler);
+ log_listener_ = base::MakeUnique<GpuProcessLogMessageListener>();
gpu::SyncPointManager* sync_point_manager = nullptr;
// Note SyncPointManager from ContentGpuClient cannot be owned by this.

Powered by Google App Engine
This is Rietveld 408576698