Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/clients/manager/ClientManagerChild.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 "ClientManagerChild.h"
8
9
#include "ClientHandleChild.h"
10
#include "ClientManagerOpChild.h"
11
#include "ClientNavigateOpChild.h"
12
#include "ClientSourceChild.h"
13
14
namespace mozilla {
15
namespace dom {
16
17
void
18
ClientManagerChild::ActorDestroy(ActorDestroyReason aReason)
19
0
{
20
0
  if (mWorkerHolderToken) {
21
0
    mWorkerHolderToken->RemoveListener(this);
22
0
    mWorkerHolderToken = nullptr;
23
0
24
0
  }
25
0
26
0
  if (mManager) {
27
0
    mManager->RevokeActor(this);
28
0
29
0
    // Revoking the actor link should automatically cause the owner
30
0
    // to call RevokeOwner() as well.
31
0
    MOZ_DIAGNOSTIC_ASSERT(!mManager);
32
0
  }
33
0
}
34
35
PClientHandleChild*
36
ClientManagerChild::AllocPClientHandleChild(const IPCClientInfo& aClientInfo)
37
0
{
38
0
  return new ClientHandleChild();
39
0
}
40
41
bool
42
ClientManagerChild::DeallocPClientHandleChild(PClientHandleChild* aActor)
43
0
{
44
0
  delete aActor;
45
0
  return true;
46
0
}
47
48
PClientManagerOpChild*
49
ClientManagerChild::AllocPClientManagerOpChild(const ClientOpConstructorArgs& aArgs)
50
0
{
51
0
  MOZ_ASSERT_UNREACHABLE("ClientManagerOpChild must be explicitly constructed.");
52
0
  return nullptr;
53
0
}
54
55
bool
56
ClientManagerChild::DeallocPClientManagerOpChild(PClientManagerOpChild* aActor)
57
0
{
58
0
  delete aActor;
59
0
  return true;
60
0
}
61
62
PClientNavigateOpChild*
63
ClientManagerChild::AllocPClientNavigateOpChild(const ClientNavigateOpConstructorArgs& aArgs)
64
0
{
65
0
  return new ClientNavigateOpChild();
66
0
}
67
68
bool
69
ClientManagerChild::DeallocPClientNavigateOpChild(PClientNavigateOpChild* aActor)
70
0
{
71
0
  delete aActor;
72
0
  return true;
73
0
}
74
75
mozilla::ipc::IPCResult
76
ClientManagerChild::RecvPClientNavigateOpConstructor(PClientNavigateOpChild* aActor,
77
                                                     const ClientNavigateOpConstructorArgs& aArgs)
78
0
{
79
0
  auto actor = static_cast<ClientNavigateOpChild*>(aActor);
80
0
  actor->Init(aArgs);
81
0
  return IPC_OK();
82
0
}
83
84
PClientSourceChild*
85
ClientManagerChild::AllocPClientSourceChild(const ClientSourceConstructorArgs& aArgs)
86
0
{
87
0
  return new ClientSourceChild(aArgs);
88
0
}
89
90
bool
91
ClientManagerChild::DeallocPClientSourceChild(PClientSourceChild* aActor)
92
0
{
93
0
  delete aActor;
94
0
  return true;
95
0
}
96
97
void
98
ClientManagerChild::WorkerShuttingDown()
99
0
{
100
0
  MaybeStartTeardown();
101
0
}
102
103
ClientManagerChild::ClientManagerChild(WorkerHolderToken* aWorkerHolderToken)
104
  : mManager(nullptr)
105
  , mWorkerHolderToken(aWorkerHolderToken)
106
  , mTeardownStarted(false)
107
0
{
108
0
  MOZ_ASSERT_IF(!NS_IsMainThread(), mWorkerHolderToken);
109
0
110
0
  if (mWorkerHolderToken) {
111
0
    mWorkerHolderToken->AddListener(this);
112
0
  }
113
0
}
114
115
void
116
ClientManagerChild::SetOwner(ClientThing<ClientManagerChild>* aThing)
117
0
{
118
0
  MOZ_DIAGNOSTIC_ASSERT(aThing);
119
0
  MOZ_DIAGNOSTIC_ASSERT(!mManager);
120
0
  mManager = aThing;
121
0
}
122
123
void
124
ClientManagerChild::RevokeOwner(ClientThing<ClientManagerChild>* aThing)
125
0
{
126
0
  MOZ_DIAGNOSTIC_ASSERT(mManager);
127
0
  MOZ_DIAGNOSTIC_ASSERT(mManager == aThing);
128
0
  mManager = nullptr;
129
0
}
130
131
void
132
ClientManagerChild::MaybeStartTeardown()
133
0
{
134
0
  if (mTeardownStarted) {
135
0
    return;
136
0
  }
137
0
  mTeardownStarted = true;
138
0
  SendTeardown();
139
0
}
140
141
WorkerPrivate*
142
ClientManagerChild::GetWorkerPrivate() const
143
0
{
144
0
  if (!mWorkerHolderToken) {
145
0
    return nullptr;
146
0
  }
147
0
  return mWorkerHolderToken->GetWorkerPrivate();
148
0
}
149
150
} // namespace dom
151
} // namespace mozilla