1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4  * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 
6 #include "nsCodeCoverage.h"
7 #include "mozilla/CodeCoverageHandler.h"
8 #include "mozilla/Unused.h"
9 #include "mozilla/dom/ContentParent.h"
10 
11 using namespace mozilla;
12 using namespace mozilla::dom;
13 
NS_IMPL_ISUPPORTS(nsCodeCoverage,nsICodeCoverage)14 NS_IMPL_ISUPPORTS(nsCodeCoverage, nsICodeCoverage)
15 
16 nsCodeCoverage::nsCodeCoverage() {}
17 
~nsCodeCoverage()18 nsCodeCoverage::~nsCodeCoverage() {}
19 
DumpCounters()20 NS_IMETHODIMP nsCodeCoverage::DumpCounters() {
21   MOZ_ASSERT(XRE_IsParentProcess());
22   MOZ_ASSERT(NS_IsMainThread());
23 
24   CodeCoverageHandler::DumpCounters(0);
25   for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
26     Unused << cp->SendDumpCodeCoverageCounters();
27   }
28 
29   return NS_OK;
30 }
31 
ResetCounters()32 NS_IMETHODIMP nsCodeCoverage::ResetCounters() {
33   MOZ_ASSERT(XRE_IsParentProcess());
34   MOZ_ASSERT(NS_IsMainThread());
35 
36   CodeCoverageHandler::ResetCounters(0);
37   for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
38     Unused << cp->SendResetCodeCoverageCounters();
39   }
40 
41   return NS_OK;
42 }
43