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 "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 Loading... |
54 #include "media/gpu/avda_surface_tracker.h" | 54 #include "media/gpu/avda_surface_tracker.h" |
55 #endif | 55 #endif |
56 | 56 |
57 namespace content { | 57 namespace content { |
58 namespace { | 58 namespace { |
59 | 59 |
60 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > | 60 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > |
61 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; | 61 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; |
62 | 62 |
63 bool GpuProcessLogMessageHandler(int severity, | 63 bool GpuProcessLogMessageHandler(int severity, |
64 const char* file, int line, | 64 const std::string& file, |
65 size_t message_start, | 65 int line, |
66 const std::string& str) { | 66 const std::string& str) { |
67 std::string header = str.substr(0, message_start); | 67 std::string header = file + "(" + std::to_string(line) + "):"; |
68 std::string message = str.substr(message_start); | |
69 | |
70 g_thread_safe_sender.Get()->Send( | 68 g_thread_safe_sender.Get()->Send( |
71 new GpuHostMsg_OnLogMessage(severity, header, message)); | 69 new GpuHostMsg_OnLogMessage(severity, header, str)); |
72 | 70 |
73 return false; | 71 return false; |
74 } | 72 } |
75 | 73 |
76 // Message filter used to to handle GpuMsg_CreateGpuMemoryBuffer messages | 74 // Message filter used to to handle GpuMsg_CreateGpuMemoryBuffer messages |
77 // on the IO thread. This allows the UI thread in the browser process to remain | 75 // on the IO thread. This allows the UI thread in the browser process to remain |
78 // fast at all times. | 76 // fast at all times. |
79 class GpuMemoryBufferMessageFilter : public IPC::MessageFilter { | 77 class GpuMemoryBufferMessageFilter : public IPC::MessageFilter { |
80 public: | 78 public: |
81 explicit GpuMemoryBufferMessageFilter( | 79 explicit GpuMemoryBufferMessageFilter( |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 186 |
189 GpuChildThread::~GpuChildThread() { | 187 GpuChildThread::~GpuChildThread() { |
190 while (!deferred_messages_.empty()) { | 188 while (!deferred_messages_.empty()) { |
191 delete deferred_messages_.front(); | 189 delete deferred_messages_.front(); |
192 deferred_messages_.pop(); | 190 deferred_messages_.pop(); |
193 } | 191 } |
194 } | 192 } |
195 | 193 |
196 void GpuChildThread::Shutdown() { | 194 void GpuChildThread::Shutdown() { |
197 ChildThreadImpl::Shutdown(); | 195 ChildThreadImpl::Shutdown(); |
198 logging::SetLogMessageHandler(NULL); | 196 if (!in_browser_process_) |
| 197 logging::RemoveLogMessageHandler(GpuProcessLogMessageHandler); |
199 } | 198 } |
200 | 199 |
201 void GpuChildThread::Init(const base::Time& process_start_time) { | 200 void GpuChildThread::Init(const base::Time& process_start_time) { |
202 process_start_time_ = process_start_time; | 201 process_start_time_ = process_start_time; |
203 | 202 |
204 #if defined(OS_ANDROID) | 203 #if defined(OS_ANDROID) |
205 // When running in in-process mode, this has been set in the browser at | 204 // When running in in-process mode, this has been set in the browser at |
206 // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun(). | 205 // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun(). |
207 if (!in_browser_process_) | 206 if (!in_browser_process_) |
208 media::SetMediaClientAndroid(GetContentClient()->GetMediaClientAndroid()); | 207 media::SetMediaClientAndroid(GetContentClient()->GetMediaClientAndroid()); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 325 |
327 if (dead_on_arrival_) { | 326 if (dead_on_arrival_) { |
328 LOG(ERROR) << "Exiting GPU process due to errors during initialization"; | 327 LOG(ERROR) << "Exiting GPU process due to errors during initialization"; |
329 base::MessageLoop::current()->QuitWhenIdle(); | 328 base::MessageLoop::current()->QuitWhenIdle(); |
330 return; | 329 return; |
331 } | 330 } |
332 | 331 |
333 // We don't need to pipe log messages if we are running the GPU thread in | 332 // We don't need to pipe log messages if we are running the GPU thread in |
334 // the browser process. | 333 // the browser process. |
335 if (!in_browser_process_) | 334 if (!in_browser_process_) |
336 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 335 logging::AddLogMessageHandler(GpuProcessLogMessageHandler); |
337 | 336 |
338 gpu::SyncPointManager* sync_point_manager = nullptr; | 337 gpu::SyncPointManager* sync_point_manager = nullptr; |
339 // Note SyncPointManager from ContentGpuClient cannot be owned by this. | 338 // Note SyncPointManager from ContentGpuClient cannot be owned by this. |
340 if (GetContentClient()->gpu()) | 339 if (GetContentClient()->gpu()) |
341 sync_point_manager = GetContentClient()->gpu()->GetSyncPointManager(); | 340 sync_point_manager = GetContentClient()->gpu()->GetSyncPointManager(); |
342 if (!sync_point_manager) { | 341 if (!sync_point_manager) { |
343 if (!owned_sync_point_manager_) { | 342 if (!owned_sync_point_manager_) { |
344 owned_sync_point_manager_.reset(new gpu::SyncPointManager(false)); | 343 owned_sync_point_manager_.reset(new gpu::SyncPointManager(false)); |
345 } | 344 } |
346 sync_point_manager = owned_sync_point_manager_.get(); | 345 sync_point_manager = owned_sync_point_manager_.get(); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 | 523 |
525 void GpuChildThread::BindServiceFactoryRequest( | 524 void GpuChildThread::BindServiceFactoryRequest( |
526 service_manager::mojom::ServiceFactoryRequest request) { | 525 service_manager::mojom::ServiceFactoryRequest request) { |
527 DVLOG(1) << "GPU: Binding service_manager::mojom::ServiceFactoryRequest"; | 526 DVLOG(1) << "GPU: Binding service_manager::mojom::ServiceFactoryRequest"; |
528 DCHECK(service_factory_); | 527 DCHECK(service_factory_); |
529 service_factory_bindings_.AddBinding(service_factory_.get(), | 528 service_factory_bindings_.AddBinding(service_factory_.get(), |
530 std::move(request)); | 529 std::move(request)); |
531 } | 530 } |
532 | 531 |
533 } // namespace content | 532 } // namespace content |
OLD | NEW |