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

Side by Side 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: clean up, MockLog uses listener 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 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 "content/gpu/gpu_child_thread.h" 5 #include "content/gpu/gpu_child_thread.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 namespace content { 55 namespace content {
56 namespace { 56 namespace {
57 57
58 base::LazyInstance<base::ThreadLocalPointer<GpuChildThread>> g_lazy_tls = 58 base::LazyInstance<base::ThreadLocalPointer<GpuChildThread>> g_lazy_tls =
59 LAZY_INSTANCE_INITIALIZER; 59 LAZY_INSTANCE_INITIALIZER;
60 60
61 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > 61 static base::LazyInstance<scoped_refptr<ThreadSafeSender> >
62 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; 62 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER;
63 63
64 bool GpuProcessLogMessageHandler(int severity, 64 void GpuProcessLogMessageListener(int severity,
65 const char* file, int line, 65 const char* file, int line,
66 size_t message_start, 66 size_t message_start,
67 const std::string& str) { 67 const std::string& str) {
68 std::string header = str.substr(0, message_start); 68 std::string header = str.substr(0, message_start);
69 std::string message = str.substr(message_start); 69 std::string message = str.substr(message_start);
70 70
71 g_thread_safe_sender.Get()->Send( 71 g_thread_safe_sender.Get()->Send(
72 new GpuHostMsg_OnLogMessage(severity, header, message)); 72 new GpuHostMsg_OnLogMessage(severity, header, message));
73
74 return false;
75 } 73 }
76 74
77 // Message filter used to to handle GpuMsg_CreateGpuMemoryBuffer messages 75 // Message filter used to to handle GpuMsg_CreateGpuMemoryBuffer messages
78 // on the IO thread. This allows the UI thread in the browser process to remain 76 // on the IO thread. This allows the UI thread in the browser process to remain
79 // fast at all times. 77 // fast at all times.
80 class GpuMemoryBufferMessageFilter : public IPC::MessageFilter { 78 class GpuMemoryBufferMessageFilter : public IPC::MessageFilter {
81 public: 79 public:
82 explicit GpuMemoryBufferMessageFilter( 80 explicit GpuMemoryBufferMessageFilter(
83 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory) 81 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory)
84 : gpu_memory_buffer_factory_(gpu_memory_buffer_factory), 82 : gpu_memory_buffer_factory_(gpu_memory_buffer_factory),
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 GpuChildThread::~GpuChildThread() { 196 GpuChildThread::~GpuChildThread() {
199 while (!deferred_messages_.empty()) { 197 while (!deferred_messages_.empty()) {
200 delete deferred_messages_.front(); 198 delete deferred_messages_.front();
201 deferred_messages_.pop(); 199 deferred_messages_.pop();
202 } 200 }
203 g_lazy_tls.Pointer()->Set(nullptr); 201 g_lazy_tls.Pointer()->Set(nullptr);
204 } 202 }
205 203
206 void GpuChildThread::Shutdown() { 204 void GpuChildThread::Shutdown() {
207 ChildThreadImpl::Shutdown(); 205 ChildThreadImpl::Shutdown();
208 logging::SetLogMessageHandler(NULL); 206 if (!in_browser_process_)
207 logging::RemoveLogMessageListener(GpuProcessLogMessageListener);
209 } 208 }
210 209
211 void GpuChildThread::Init(const base::Time& process_start_time) { 210 void GpuChildThread::Init(const base::Time& process_start_time) {
212 process_start_time_ = process_start_time; 211 process_start_time_ = process_start_time;
213 212
214 #if defined(OS_ANDROID) 213 #if defined(OS_ANDROID)
215 // When running in in-process mode, this has been set in the browser at 214 // When running in in-process mode, this has been set in the browser at
216 // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun(). 215 // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun().
217 if (!in_browser_process_) 216 if (!in_browser_process_)
218 media::SetMediaClientAndroid(GetContentClient()->GetMediaClientAndroid()); 217 media::SetMediaClientAndroid(GetContentClient()->GetMediaClientAndroid());
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 387
389 if (dead_on_arrival_) { 388 if (dead_on_arrival_) {
390 LOG(ERROR) << "Exiting GPU process due to errors during initialization"; 389 LOG(ERROR) << "Exiting GPU process due to errors during initialization";
391 base::MessageLoop::current()->QuitWhenIdle(); 390 base::MessageLoop::current()->QuitWhenIdle();
392 return; 391 return;
393 } 392 }
394 393
395 // We don't need to pipe log messages if we are running the GPU thread in 394 // We don't need to pipe log messages if we are running the GPU thread in
396 // the browser process. 395 // the browser process.
397 if (!in_browser_process_) 396 if (!in_browser_process_)
398 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); 397 logging::AddLogMessageListener(GpuProcessLogMessageListener);
399 398
400 gpu::SyncPointManager* sync_point_manager = nullptr; 399 gpu::SyncPointManager* sync_point_manager = nullptr;
401 // Note SyncPointManager from ContentGpuClient cannot be owned by this. 400 // Note SyncPointManager from ContentGpuClient cannot be owned by this.
402 if (GetContentClient()->gpu()) 401 if (GetContentClient()->gpu())
403 sync_point_manager = GetContentClient()->gpu()->GetSyncPointManager(); 402 sync_point_manager = GetContentClient()->gpu()->GetSyncPointManager();
404 if (!sync_point_manager) { 403 if (!sync_point_manager) {
405 if (!owned_sync_point_manager_) { 404 if (!owned_sync_point_manager_) {
406 owned_sync_point_manager_.reset(new gpu::SyncPointManager(false)); 405 owned_sync_point_manager_.reset(new gpu::SyncPointManager(false));
407 } 406 }
408 sync_point_manager = owned_sync_point_manager_.get(); 407 sync_point_manager = owned_sync_point_manager_.get();
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 584
586 void GpuChildThread::BindProcessControlRequest( 585 void GpuChildThread::BindProcessControlRequest(
587 mojo::InterfaceRequest<mojom::ProcessControl> request) { 586 mojo::InterfaceRequest<mojom::ProcessControl> request) {
588 DVLOG(1) << "GPU: Binding ProcessControl request"; 587 DVLOG(1) << "GPU: Binding ProcessControl request";
589 DCHECK(process_control_); 588 DCHECK(process_control_);
590 process_control_bindings_.AddBinding(process_control_.get(), 589 process_control_bindings_.AddBinding(process_control_.get(),
591 std::move(request)); 590 std::move(request));
592 } 591 }
593 592
594 } // namespace content 593 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698