Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/js/ipc/CPOWTimer.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
 * vim: set ts=4 sw=4 et tw=80:
3
 *
4
 * This Source Code Form is subject to the terms of the Mozilla Public
5
 * License, v. 2.0. If a copy of the MPL was not distributed with this
6
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7
8
#include "jsfriendapi.h"
9
#include "nsContentUtils.h"
10
#include "CPOWTimer.h"
11
12
#include "jsapi.h"
13
14
CPOWTimer::CPOWTimer(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
15
    : cx_(nullptr)
16
    , startInterval_(0)
17
0
{
18
0
    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
19
0
    if (!js::GetStopwatchIsMonitoringCPOW(cx)) {
20
0
        return;
21
0
    }
22
0
    cx_ = cx;
23
0
    startInterval_ = JS_Now();
24
0
}
25
CPOWTimer::~CPOWTimer()
26
0
{
27
0
    if (!cx_) {
28
0
        // Monitoring was off when we started the timer.
29
0
        return;
30
0
    }
31
0
32
0
    if (!js::GetStopwatchIsMonitoringCPOW(cx_)) {
33
0
        // Monitoring has been deactivated while we were in the timer.
34
0
        return;
35
0
    }
36
0
37
0
    const int64_t endInterval = JS_Now();
38
0
    if (endInterval <= startInterval_) {
39
0
        // Do not assume monotonicity.
40
0
        return;
41
0
    }
42
0
43
0
    js::AddCPOWPerformanceDelta(cx_, endInterval - startInterval_);
44
0
}