gecko-dev/gfx/vr/ipc/VRGPUChild.cpp
Ehsan Akhgari 06c3d29113 Bug 1521000 - Part 1: Reformat the tree to ensure everything is formatted correctly with clang-format r=sylvestre
Summary: # ignore-this-changeset

Reviewers: sylvestre

Reviewed By: sylvestre

Subscribers: reviewbot, emilio, jandem, bbouvier, karlt, jya

Bug #: 1521000

Differential Revision: https://phabricator.services.mozilla.com/D16936

--HG--
extra : histedit_source : 4add583bfa729ccc1aef934629ed45ff095189b0
2019-01-18 10:12:56 +01:00

57 lines
1.6 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "VRGPUChild.h"
namespace mozilla {
namespace gfx {
static StaticRefPtr<VRGPUChild> sVRGPUChildSingleton;
/* static */ bool VRGPUChild::InitForGPUProcess(
Endpoint<PVRGPUChild>&& aEndpoint) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!sVRGPUChildSingleton);
RefPtr<VRGPUChild> child(new VRGPUChild());
if (!aEndpoint.Bind(child)) {
return false;
}
sVRGPUChildSingleton = child;
RefPtr<Runnable> task =
NS_NewRunnableFunction("VRGPUChild::SendStartVRService", []() -> void {
VRGPUChild* vrGPUChild = VRGPUChild::Get();
vrGPUChild->SendStartVRService();
});
NS_DispatchToMainThread(task.forget());
return true;
}
/* static */ bool VRGPUChild::IsCreated() { return !!sVRGPUChildSingleton; }
/* static */ VRGPUChild* VRGPUChild::Get() {
MOZ_ASSERT(IsCreated(), "VRGPUChild haven't initialized yet.");
return sVRGPUChildSingleton;
}
/*static*/ void VRGPUChild::Shutdown() {
MOZ_ASSERT(NS_IsMainThread());
if (sVRGPUChildSingleton && !sVRGPUChildSingleton->IsClosed()) {
sVRGPUChildSingleton->Close();
}
sVRGPUChildSingleton = nullptr;
}
void VRGPUChild::ActorDestroy(ActorDestroyReason aWhy) { mClosed = true; }
bool VRGPUChild::IsClosed() { return mClosed; }
} // namespace gfx
} // namespace mozilla