Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/cache/CacheParent.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 "mozilla/dom/cache/CacheParent.h"
8
9
#include "mozilla/dom/cache/CacheOpParent.h"
10
#include "nsCOMPtr.h"
11
12
namespace mozilla {
13
namespace dom {
14
namespace cache {
15
16
// Declared in ActorUtils.h
17
void
18
DeallocPCacheParent(PCacheParent* aActor)
19
0
{
20
0
  delete aActor;
21
0
}
22
23
CacheParent::CacheParent(cache::Manager* aManager, CacheId aCacheId)
24
  : mManager(aManager)
25
  , mCacheId(aCacheId)
26
0
{
27
0
  MOZ_COUNT_CTOR(cache::CacheParent);
28
0
  MOZ_DIAGNOSTIC_ASSERT(mManager);
29
0
  mManager->AddRefCacheId(mCacheId);
30
0
}
31
32
CacheParent::~CacheParent()
33
0
{
34
0
  MOZ_COUNT_DTOR(cache::CacheParent);
35
0
  MOZ_DIAGNOSTIC_ASSERT(!mManager);
36
0
}
37
38
void
39
CacheParent::ActorDestroy(ActorDestroyReason aReason)
40
0
{
41
0
  MOZ_DIAGNOSTIC_ASSERT(mManager);
42
0
  mManager->ReleaseCacheId(mCacheId);
43
0
  mManager = nullptr;
44
0
}
45
46
PCacheOpParent*
47
CacheParent::AllocPCacheOpParent(const CacheOpArgs& aOpArgs)
48
0
{
49
0
  if (aOpArgs.type() != CacheOpArgs::TCacheMatchArgs &&
50
0
      aOpArgs.type() != CacheOpArgs::TCacheMatchAllArgs &&
51
0
      aOpArgs.type() != CacheOpArgs::TCachePutAllArgs &&
52
0
      aOpArgs.type() != CacheOpArgs::TCacheDeleteArgs &&
53
0
      aOpArgs.type() != CacheOpArgs::TCacheKeysArgs)
54
0
  {
55
0
    MOZ_CRASH("Invalid operation sent to Cache actor!");
56
0
  }
57
0
58
0
  return new CacheOpParent(Manager(), mCacheId, aOpArgs);
59
0
}
60
61
bool
62
CacheParent::DeallocPCacheOpParent(PCacheOpParent* aActor)
63
0
{
64
0
  delete aActor;
65
0
  return true;
66
0
}
67
68
mozilla::ipc::IPCResult
69
CacheParent::RecvPCacheOpConstructor(PCacheOpParent* aActor,
70
                                     const CacheOpArgs& aOpArgs)
71
0
{
72
0
  auto actor = static_cast<CacheOpParent*>(aActor);
73
0
  actor->Execute(mManager);
74
0
  return IPC_OK();
75
0
}
76
77
mozilla::ipc::IPCResult
78
CacheParent::RecvTeardown()
79
0
{
80
0
  if (!Send__delete__(this)) {
81
0
    // child process is gone, warn and allow actor to clean up normally
82
0
    NS_WARNING("Cache failed to send delete.");
83
0
  }
84
0
  return IPC_OK();
85
0
}
86
87
} // namespace cache
88
} // namespace dom
89
} // namespace mozilla