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

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

Issue 2723013004: gpu: Replace more chrome ipc with mojom API. (Closed)
Patch Set: tot merge Created 3 years, 9 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
« no previous file with comments | « content/gpu/gpu_child_thread.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "ui/gl/gl_switches.h" 44 #include "ui/gl/gl_switches.h"
45 #include "ui/gl/gpu_switching_manager.h" 45 #include "ui/gl/gpu_switching_manager.h"
46 #include "ui/gl/init/gl_factory.h" 46 #include "ui/gl/init/gl_factory.h"
47 #include "url/gurl.h" 47 #include "url/gurl.h"
48 48
49 #if defined(USE_OZONE) 49 #if defined(USE_OZONE)
50 #include "ui/ozone/public/ozone_platform.h" 50 #include "ui/ozone/public/ozone_platform.h"
51 #endif 51 #endif
52 52
53 #if defined(OS_ANDROID) 53 #if defined(OS_ANDROID)
54 #include "base/android/throw_uncaught_exception.h"
55 #include "media/base/android/media_client_android.h" 54 #include "media/base/android/media_client_android.h"
56 #endif 55 #endif
57 56
58 namespace content { 57 namespace content {
59 namespace { 58 namespace {
60 59
61 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > 60 static base::LazyInstance<scoped_refptr<ThreadSafeSender> >
62 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; 61 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER;
63 62
64 bool GpuProcessLogMessageHandler(int severity, 63 bool GpuProcessLogMessageHandler(int severity,
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 DCHECK(!msg->is_sync()); 241 DCHECK(!msg->is_sync());
243 242
244 return ChildThreadImpl::Send(msg); 243 return ChildThreadImpl::Send(msg);
245 } 244 }
246 245
247 bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) { 246 bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) {
248 bool handled = true; 247 bool handled = true;
249 IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg) 248 IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg)
250 IPC_MESSAGE_HANDLER(GpuMsg_Finalize, OnFinalize) 249 IPC_MESSAGE_HANDLER(GpuMsg_Finalize, OnFinalize)
251 IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo) 250 IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo)
252 IPC_MESSAGE_HANDLER(GpuMsg_Clean, OnClean)
253 IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash)
254 IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang)
255 #if defined(OS_ANDROID)
256 IPC_MESSAGE_HANDLER(GpuMsg_JavaCrash, OnJavaCrash)
257 #endif
258 IPC_MESSAGE_HANDLER(GpuMsg_GpuSwitched, OnGpuSwitched) 251 IPC_MESSAGE_HANDLER(GpuMsg_GpuSwitched, OnGpuSwitched)
259 IPC_MESSAGE_UNHANDLED(handled = false) 252 IPC_MESSAGE_UNHANDLED(handled = false)
260 IPC_END_MESSAGE_MAP() 253 IPC_END_MESSAGE_MAP()
261 254
262 return handled; 255 return handled;
263 } 256 }
264 257
265 bool GpuChildThread::OnMessageReceived(const IPC::Message& msg) { 258 bool GpuChildThread::OnMessageReceived(const IPC::Message& msg) {
266 if (ChildThreadImpl::OnMessageReceived(msg)) 259 if (ChildThreadImpl::OnMessageReceived(msg))
267 return true; 260 return true;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); 399 Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_));
407 400
408 #if defined(OS_WIN) 401 #if defined(OS_WIN)
409 if (!in_browser_process_) { 402 if (!in_browser_process_) {
410 // The unsandboxed GPU process fulfilled its duty. Rest in peace. 403 // The unsandboxed GPU process fulfilled its duty. Rest in peace.
411 base::MessageLoop::current()->QuitWhenIdle(); 404 base::MessageLoop::current()->QuitWhenIdle();
412 } 405 }
413 #endif // OS_WIN 406 #endif // OS_WIN
414 } 407 }
415 408
416 void GpuChildThread::OnClean() {
417 DVLOG(1) << "GPU: Removing all contexts";
418 if (gpu_channel_manager())
419 gpu_channel_manager()->DestroyAllChannels();
420 }
421
422 void GpuChildThread::OnCrash() {
423 DVLOG(1) << "GPU: Simulating GPU crash";
424 // Good bye, cruel world.
425 volatile int* it_s_the_end_of_the_world_as_we_know_it = NULL;
426 *it_s_the_end_of_the_world_as_we_know_it = 0xdead;
427 }
428
429 void GpuChildThread::OnHang() {
430 DVLOG(1) << "GPU: Simulating GPU hang";
431 for (;;) {
432 // Do not sleep here. The GPU watchdog timer tracks the amount of user
433 // time this thread is using and it doesn't use much while calling Sleep.
434 }
435 }
436
437 #if defined(OS_ANDROID)
438 void GpuChildThread::OnJavaCrash() {
439 base::android::ThrowUncaughtException();
440 }
441 #endif
442
443 void GpuChildThread::OnGpuSwitched() { 409 void GpuChildThread::OnGpuSwitched() {
444 DVLOG(1) << "GPU: GPU has switched"; 410 DVLOG(1) << "GPU: GPU has switched";
445 // Notify observers in the GPU process. 411 // Notify observers in the GPU process.
446 if (!in_browser_process_) 412 if (!in_browser_process_)
447 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); 413 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched();
448 } 414 }
449 415
450 void GpuChildThread::OnDestroyGpuMemoryBuffer( 416 void GpuChildThread::OnDestroyGpuMemoryBuffer(
451 gfx::GpuMemoryBufferId id, 417 gfx::GpuMemoryBufferId id,
452 int client_id, 418 int client_id,
453 const gpu::SyncToken& sync_token) { 419 const gpu::SyncToken& sync_token) {
454 if (gpu_channel_manager()) 420 if (gpu_channel_manager())
455 gpu_channel_manager()->DestroyGpuMemoryBuffer(id, client_id, sync_token); 421 gpu_channel_manager()->DestroyGpuMemoryBuffer(id, client_id, sync_token);
456 } 422 }
457 423
458 void GpuChildThread::BindServiceFactoryRequest( 424 void GpuChildThread::BindServiceFactoryRequest(
459 service_manager::mojom::ServiceFactoryRequest request) { 425 service_manager::mojom::ServiceFactoryRequest request) {
460 DVLOG(1) << "GPU: Binding service_manager::mojom::ServiceFactoryRequest"; 426 DVLOG(1) << "GPU: Binding service_manager::mojom::ServiceFactoryRequest";
461 DCHECK(service_factory_); 427 DCHECK(service_factory_);
462 service_factory_bindings_.AddBinding(service_factory_.get(), 428 service_factory_bindings_.AddBinding(service_factory_.get(),
463 std::move(request)); 429 std::move(request));
464 } 430 }
465 431
466 } // namespace content 432 } // namespace content
OLDNEW
« no previous file with comments | « content/gpu/gpu_child_thread.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698