2017-10-27 01:08:41 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2017-06-16 10:17:09 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "TimeoutBudgetManager.h"
|
|
|
|
|
2017-06-19 11:11:47 +03:00
|
|
|
#include "mozilla/dom/Timeout.h"
|
|
|
|
|
2017-06-16 10:17:09 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
/* static */ TimeoutBudgetManager& TimeoutBudgetManager::Get() {
|
2017-06-19 11:11:47 +03:00
|
|
|
static TimeoutBudgetManager gTimeoutBudgetManager;
|
2017-06-16 10:17:09 +03:00
|
|
|
return gTimeoutBudgetManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TimeoutBudgetManager::StartRecording(const TimeStamp& aNow) {
|
|
|
|
mStart = aNow;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TimeoutBudgetManager::StopRecording() { mStart = TimeStamp(); }
|
|
|
|
|
|
|
|
TimeDuration TimeoutBudgetManager::RecordExecution(const TimeStamp& aNow,
|
2018-10-12 21:01:19 +03:00
|
|
|
const Timeout* aTimeout) {
|
2017-06-16 10:17:09 +03:00
|
|
|
if (!mStart) {
|
|
|
|
// If we've started a sync operation mStart might be null, in
|
|
|
|
// which case we should not record this piece of execution.
|
2017-06-14 18:47:38 +03:00
|
|
|
return TimeDuration();
|
2017-06-16 10:17:09 +03:00
|
|
|
}
|
|
|
|
|
2018-10-12 21:01:19 +03:00
|
|
|
return aNow - mStart;
|
2017-06-16 10:17:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|