Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/HangDetails.h
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
#ifndef mozilla_HangDetails_h
8
#define mozilla_HangDetails_h
9
10
#include "ipc/IPCMessageUtils.h"
11
#include "mozilla/ProcessedStack.h"
12
#include "mozilla/RefPtr.h"
13
#include "mozilla/Move.h"
14
#include "mozilla/HangTypes.h"
15
#include "mozilla/HangAnnotations.h"
16
#include "nsTArray.h"
17
#include "nsIHangDetails.h"
18
#include "mozilla/TimeStamp.h"
19
20
namespace mozilla {
21
22
/**
23
 * HangDetails is the concrete implementaion of nsIHangDetails, and contains the
24
 * infromation which we want to expose to observers of the bhr-thread-hang
25
 * observer notification.
26
 */
27
class nsHangDetails : public nsIHangDetails
28
{
29
public:
30
  NS_DECL_THREADSAFE_ISUPPORTS
31
  NS_DECL_NSIHANGDETAILS
32
33
  explicit nsHangDetails(HangDetails&& aDetails)
34
    : mDetails(std::move(aDetails))
35
0
  {}
36
37
  // Submit these HangDetails to the main thread. This will dispatch a runnable
38
  // to the main thread which will fire off the bhr-thread-hang observer
39
  // notification with this HangDetails as the subject.
40
  void Submit();
41
42
private:
43
  virtual ~nsHangDetails() {}
44
45
  HangDetails mDetails;
46
};
47
48
/**
49
 * This runnable is run on the StreamTransportService threadpool in order to
50
 * process the stack off main thread before submitting it to the main thread as
51
 * an observer notification.
52
 *
53
 * This object should have the only remaining reference to aHangDetails, as it
54
 * will access its fields without synchronization.
55
 */
56
class ProcessHangStackRunnable final : public Runnable
57
{
58
public:
59
  explicit ProcessHangStackRunnable(HangDetails&& aHangDetails)
60
    : Runnable("ProcessHangStackRunnable")
61
    , mHangDetails(std::move(aHangDetails))
62
  {}
63
64
  NS_IMETHOD Run() override;
65
66
private:
67
  HangDetails mHangDetails;
68
};
69
70
} // namespace mozilla
71
72
#endif // mozilla_HangDetails_h