Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/layers/ipc/VideoBridgeChild.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 "VideoBridgeChild.h"
8
#include "VideoBridgeParent.h"
9
#include "CompositorThread.h"
10
11
namespace mozilla {
12
namespace layers {
13
14
StaticRefPtr<VideoBridgeChild> sVideoBridgeChildSingleton;
15
16
/* static */ void
17
VideoBridgeChild::Startup()
18
0
{
19
0
  sVideoBridgeChildSingleton = new VideoBridgeChild();
20
0
  RefPtr<VideoBridgeParent> parent = new VideoBridgeParent();
21
0
22
0
  MessageLoop* loop = CompositorThreadHolder::Loop();
23
0
24
0
  sVideoBridgeChildSingleton->Open(parent->GetIPCChannel(),
25
0
                                   loop,
26
0
                                   ipc::ChildSide);
27
0
  sVideoBridgeChildSingleton->mIPDLSelfRef = sVideoBridgeChildSingleton;
28
0
  parent->SetOtherProcessId(base::GetCurrentProcId());
29
0
}
30
31
/* static */ void
32
VideoBridgeChild::Shutdown()
33
0
{
34
0
  if (sVideoBridgeChildSingleton) {
35
0
    sVideoBridgeChildSingleton->Close();
36
0
    sVideoBridgeChildSingleton = nullptr;
37
0
  }
38
0
}
39
40
VideoBridgeChild::VideoBridgeChild()
41
  : mMessageLoop(MessageLoop::current())
42
  , mCanSend(true)
43
0
{
44
0
}
45
46
VideoBridgeChild::~VideoBridgeChild()
47
0
{
48
0
}
49
50
VideoBridgeChild*
51
VideoBridgeChild::GetSingleton()
52
0
{
53
0
  return sVideoBridgeChildSingleton;
54
0
}
55
56
bool
57
VideoBridgeChild::AllocUnsafeShmem(size_t aSize,
58
                                   ipc::SharedMemory::SharedMemoryType aType,
59
                                   ipc::Shmem* aShmem)
60
0
{
61
0
  return PVideoBridgeChild::AllocUnsafeShmem(aSize, aType, aShmem);
62
0
}
63
64
bool
65
VideoBridgeChild::AllocShmem(size_t aSize,
66
                             ipc::SharedMemory::SharedMemoryType aType,
67
                             ipc::Shmem* aShmem)
68
0
{
69
0
  MOZ_ASSERT(CanSend());
70
0
  return PVideoBridgeChild::AllocShmem(aSize, aType, aShmem);
71
0
}
72
73
bool
74
VideoBridgeChild::DeallocShmem(ipc::Shmem& aShmem)
75
0
{
76
0
  return PVideoBridgeChild::DeallocShmem(aShmem);
77
0
}
78
79
PTextureChild*
80
VideoBridgeChild::AllocPTextureChild(const SurfaceDescriptor&,
81
                                     const ReadLockDescriptor&,
82
                                     const LayersBackend&,
83
                                     const TextureFlags&,
84
                                     const uint64_t& aSerial)
85
0
{
86
0
  MOZ_ASSERT(CanSend());
87
0
  return TextureClient::CreateIPDLActor();
88
0
}
89
90
bool
91
VideoBridgeChild::DeallocPTextureChild(PTextureChild* actor)
92
0
{
93
0
  return TextureClient::DestroyIPDLActor(actor);
94
0
}
95
96
void
97
VideoBridgeChild::ActorDestroy(ActorDestroyReason aWhy)
98
0
{
99
0
  mCanSend = false;
100
0
}
101
102
void
103
VideoBridgeChild::DeallocPVideoBridgeChild()
104
0
{
105
0
  mIPDLSelfRef = nullptr;
106
0
}
107
108
PTextureChild*
109
VideoBridgeChild::CreateTexture(const SurfaceDescriptor& aSharedData,
110
                                const ReadLockDescriptor& aReadLock,
111
                                LayersBackend aLayersBackend,
112
                                TextureFlags aFlags,
113
                                uint64_t aSerial,
114
                                wr::MaybeExternalImageId& aExternalImageId,
115
                                nsIEventTarget* aTarget)
116
0
{
117
0
  MOZ_ASSERT(CanSend());
118
0
  return SendPTextureConstructor(aSharedData, aReadLock, aLayersBackend, aFlags, aSerial);
119
0
}
120
121
bool VideoBridgeChild::IsSameProcess() const
122
0
{
123
0
  return OtherPid() == base::GetCurrentProcId();
124
0
}
125
126
} // namespace layers
127
} // namespace mozilla