Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/ipc/glue/CrashReporterClient.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 "CrashReporterClient.h"
8
#include "CrashReporterMetadataShmem.h"
9
#include "nsISupportsImpl.h"
10
11
namespace mozilla {
12
namespace ipc {
13
14
StaticMutex CrashReporterClient::sLock;
15
StaticRefPtr<CrashReporterClient> CrashReporterClient::sClientSingleton;
16
17
CrashReporterClient::CrashReporterClient(const Shmem& aShmem)
18
 : mMetadata(new CrashReporterMetadataShmem(aShmem))
19
0
{
20
0
  MOZ_COUNT_CTOR(CrashReporterClient);
21
0
}
22
23
CrashReporterClient::~CrashReporterClient()
24
0
{
25
0
  MOZ_COUNT_DTOR(CrashReporterClient);
26
0
}
27
28
void
29
CrashReporterClient::AnnotateCrashReport(CrashReporter::Annotation aKey,
30
                                         const nsCString& aData)
31
0
{
32
0
  StaticMutexAutoLock lock(sLock);
33
0
  mMetadata->AnnotateCrashReport(aKey, aData);
34
0
}
35
36
void
37
CrashReporterClient::AppendAppNotes(const nsCString& aData)
38
0
{
39
0
  StaticMutexAutoLock lock(sLock);
40
0
  mMetadata->AppendAppNotes(aData);
41
0
}
42
43
/* static */ void
44
CrashReporterClient::InitSingletonWithShmem(const Shmem& aShmem)
45
0
{
46
0
  {
47
0
    StaticMutexAutoLock lock(sLock);
48
0
49
0
    MOZ_ASSERT(!sClientSingleton);
50
0
    sClientSingleton = new CrashReporterClient(aShmem);
51
0
  }
52
0
53
0
  CrashReporter::NotifyCrashReporterClientCreated();
54
0
}
55
56
/* static */ void
57
CrashReporterClient::DestroySingleton()
58
0
{
59
0
  StaticMutexAutoLock lock(sLock);
60
0
  sClientSingleton = nullptr;
61
0
}
62
63
/* static */ RefPtr<CrashReporterClient>
64
CrashReporterClient::GetSingleton()
65
0
{
66
0
  StaticMutexAutoLock lock(sLock);
67
0
  return sClientSingleton;
68
0
}
69
70
} // namespace ipc
71
} // namespace mozilla