Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/ipc/VsyncBridgeParent.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
#include "VsyncBridgeParent.h"
7
#include "mozilla/layers/CompositorThread.h"
8
9
namespace mozilla {
10
namespace gfx {
11
12
RefPtr<VsyncBridgeParent>
13
VsyncBridgeParent::Start(Endpoint<PVsyncBridgeParent>&& aEndpoint)
14
0
{
15
0
  RefPtr<VsyncBridgeParent> parent = new VsyncBridgeParent();
16
0
17
0
  RefPtr<Runnable> task = NewRunnableMethod<Endpoint<PVsyncBridgeParent>&&>(
18
0
    "gfx::VsyncBridgeParent::Open",
19
0
    parent,
20
0
    &VsyncBridgeParent::Open,
21
0
    std::move(aEndpoint));
22
0
  CompositorThreadHolder::Loop()->PostTask(task.forget());
23
0
24
0
  return parent;
25
0
}
26
27
VsyncBridgeParent::VsyncBridgeParent()
28
 : mOpen(false)
29
0
{
30
0
  MOZ_COUNT_CTOR(VsyncBridgeParent);
31
0
  mCompositorThreadRef = CompositorThreadHolder::GetSingleton();
32
0
}
33
34
VsyncBridgeParent::~VsyncBridgeParent()
35
0
{
36
0
  MOZ_COUNT_DTOR(VsyncBridgeParent);
37
0
}
38
39
void
40
VsyncBridgeParent::Open(Endpoint<PVsyncBridgeParent>&& aEndpoint)
41
0
{
42
0
  if (!aEndpoint.Bind(this)) {
43
0
    // We can't recover from this.
44
0
    MOZ_CRASH("Failed to bind VsyncBridgeParent to endpoint");
45
0
  }
46
0
  AddRef();
47
0
  mOpen = true;
48
0
}
49
50
mozilla::ipc::IPCResult
51
VsyncBridgeParent::RecvNotifyVsync(const TimeStamp& aTimeStamp, const LayersId& aLayersId)
52
0
{
53
0
  CompositorBridgeParent::NotifyVsync(aTimeStamp, aLayersId);
54
0
  return IPC_OK();
55
0
}
56
57
void
58
VsyncBridgeParent::Shutdown()
59
0
{
60
0
  MessageLoop* ccloop = CompositorThreadHolder::Loop();
61
0
  if (MessageLoop::current() != ccloop) {
62
0
    ccloop->PostTask(NewRunnableMethod("gfx::VsyncBridgeParent::ShutdownImpl",
63
0
                                       this,
64
0
                                       &VsyncBridgeParent::ShutdownImpl));
65
0
    return;
66
0
  }
67
0
68
0
  ShutdownImpl();
69
0
}
70
71
void
72
VsyncBridgeParent::ShutdownImpl()
73
0
{
74
0
  if (mOpen) {
75
0
    Close();
76
0
    mOpen = false;
77
0
  }
78
0
}
79
80
void
81
VsyncBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
82
0
{
83
0
  mOpen = false;
84
0
  mCompositorThreadRef = nullptr;
85
0
}
86
87
void
88
VsyncBridgeParent::DeallocPVsyncBridgeParent()
89
0
{
90
0
  Release();
91
0
}
92
93
} // namespace gfx
94
} // namespace mozilla