/src/mozilla-central/gfx/vr/ipc/VRGPUParent.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "VRGPUParent.h" |
8 | | |
9 | | #include "mozilla/ipc/ProcessChild.h" |
10 | | |
11 | | |
12 | | namespace mozilla { |
13 | | namespace gfx { |
14 | | |
15 | | using namespace ipc; |
16 | | |
17 | | |
18 | | VRGPUParent::VRGPUParent(ProcessId aChildProcessId) |
19 | 0 | { |
20 | 0 | MOZ_COUNT_CTOR(VRGPUParent); |
21 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
22 | 0 |
|
23 | 0 | SetOtherProcessId(aChildProcessId); |
24 | 0 | } |
25 | | |
26 | | void |
27 | | VRGPUParent::ActorDestroy(ActorDestroyReason aWhy) |
28 | 0 | { |
29 | 0 | #if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID)) |
30 | 0 | if (mVRService) { |
31 | 0 | mVRService->Stop(); |
32 | 0 | mVRService = nullptr; |
33 | 0 | } |
34 | 0 | #endif |
35 | 0 |
|
36 | 0 | MessageLoop::current()->PostTask( |
37 | 0 | NewRunnableMethod("gfx::VRGPUParent::DeferredDestroy", |
38 | 0 | this, |
39 | 0 | &VRGPUParent::DeferredDestroy)); |
40 | 0 | } |
41 | | |
42 | | void |
43 | | VRGPUParent::DeferredDestroy() |
44 | 0 | { |
45 | 0 | mSelfRef = nullptr; |
46 | 0 | } |
47 | | |
48 | | /* static */ RefPtr<VRGPUParent> |
49 | | VRGPUParent::CreateForGPU(Endpoint<PVRGPUParent>&& aEndpoint) |
50 | 0 | { |
51 | 0 | RefPtr<VRGPUParent> vcp = new VRGPUParent(aEndpoint.OtherPid()); |
52 | 0 | MessageLoop::current()->PostTask( |
53 | 0 | NewRunnableMethod<Endpoint<PVRGPUParent>&&>( |
54 | 0 | "gfx::VRGPUParent::Bind", |
55 | 0 | vcp, |
56 | 0 | &VRGPUParent::Bind, |
57 | 0 | std::move(aEndpoint))); |
58 | 0 |
|
59 | 0 | return vcp; |
60 | 0 | } |
61 | | |
62 | | void |
63 | | VRGPUParent::Bind(Endpoint<PVRGPUParent>&& aEndpoint) |
64 | 0 | { |
65 | 0 | if (!aEndpoint.Bind(this)) { |
66 | 0 | return; |
67 | 0 | } |
68 | 0 | |
69 | 0 | mSelfRef = this; |
70 | 0 | } |
71 | | |
72 | | mozilla::ipc::IPCResult |
73 | | VRGPUParent::RecvStartVRService() |
74 | 0 | { |
75 | 0 | #if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID)) |
76 | 0 | mVRService = VRService::Create(); |
77 | 0 | MOZ_ASSERT(mVRService); |
78 | 0 |
|
79 | 0 | mVRService->Start(); |
80 | 0 | #endif |
81 | 0 |
|
82 | 0 | return IPC_OK(); |
83 | 0 | } |
84 | | |
85 | | mozilla::ipc::IPCResult |
86 | | VRGPUParent::RecvStopVRService() |
87 | 0 | { |
88 | 0 | #if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID)) |
89 | 0 | if (mVRService) { |
90 | 0 | mVRService->Stop(); |
91 | 0 | mVRService = nullptr; |
92 | 0 | } |
93 | 0 | #endif |
94 | 0 |
|
95 | 0 | return IPC_OK(); |
96 | 0 | } |
97 | | |
98 | | } // namespace gfx |
99 | | } // namespace mozilla |