Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/clients/manager/ClientHandleParent.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 "ClientHandleParent.h"
8
9
#include "ClientHandleOpParent.h"
10
#include "ClientManagerService.h"
11
#include "ClientSourceParent.h"
12
#include "mozilla/dom/ClientIPCTypes.h"
13
#include "mozilla/Unused.h"
14
15
namespace mozilla {
16
namespace dom {
17
18
using mozilla::ipc::IPCResult;
19
20
IPCResult
21
ClientHandleParent::RecvTeardown()
22
0
{
23
0
  Unused << Send__delete__(this);
24
0
  return IPC_OK();
25
0
}
26
27
void
28
ClientHandleParent::ActorDestroy(ActorDestroyReason aReason)
29
0
{
30
0
  if (mSource) {
31
0
    mSource->DetachHandle(this);
32
0
    mSource = nullptr;
33
0
  }
34
0
}
35
36
PClientHandleOpParent*
37
ClientHandleParent::AllocPClientHandleOpParent(const ClientOpConstructorArgs& aArgs)
38
0
{
39
0
  return new ClientHandleOpParent();
40
0
}
41
42
bool
43
ClientHandleParent::DeallocPClientHandleOpParent(PClientHandleOpParent* aActor)
44
0
{
45
0
  delete aActor;
46
0
  return true;
47
0
}
48
49
IPCResult
50
ClientHandleParent::RecvPClientHandleOpConstructor(PClientHandleOpParent* aActor,
51
                                                   const ClientOpConstructorArgs& aArgs)
52
0
{
53
0
  auto actor = static_cast<ClientHandleOpParent*>(aActor);
54
0
  actor->Init(aArgs);
55
0
  return IPC_OK();
56
0
}
57
58
ClientHandleParent::ClientHandleParent()
59
  : mService(ClientManagerService::GetOrCreateInstance())
60
  , mSource(nullptr)
61
0
{
62
0
}
63
64
ClientHandleParent::~ClientHandleParent()
65
0
{
66
0
  MOZ_DIAGNOSTIC_ASSERT(!mSource);
67
0
}
68
69
void
70
ClientHandleParent::Init(const IPCClientInfo& aClientInfo)
71
0
{
72
0
  mSource = mService->FindSource(aClientInfo.id(), aClientInfo.principalInfo());
73
0
  if (!mSource) {
74
0
    Unused << Send__delete__(this);
75
0
    return;
76
0
  }
77
0
78
0
  mSource->AttachHandle(this);
79
0
}
80
81
ClientSourceParent*
82
ClientHandleParent::GetSource() const
83
0
{
84
0
  return mSource;
85
0
}
86
87
} // namespace dom
88
} // namespace mozilla