Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / performance / PerformanceService.h
blob80ded9b1803d7ef38f7e06812d8ae1e3968b6d01
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/. */
7 #ifndef dom_performance_PerformanceService_h
8 #define dom_performance_PerformanceService_h
10 #include "mozilla/TimeStamp.h"
11 #include "nsCOMPtr.h"
12 #include "nsDOMNavigationTiming.h"
14 namespace mozilla::dom {
16 // This class is thread-safe.
18 // We use this singleton for having the correct value of performance.timeOrigin.
19 // This value must be calculated on top of the pair:
20 // - mCreationTimeStamp (monotonic clock)
21 // - mCreationEpochTime (unix epoch time)
22 // These 2 values must be taken "at the same time" in order to be used
23 // correctly.
25 class PerformanceService {
26 public:
27 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PerformanceService)
29 static PerformanceService* GetOrCreate();
31 DOMHighResTimeStamp TimeOrigin(const TimeStamp& aCreationTimeStamp) const;
33 private:
34 PerformanceService();
35 ~PerformanceService() = default;
37 TimeStamp mCreationTimeStamp;
38 PRTime mCreationEpochTime;
41 } // namespace mozilla::dom
43 #endif // dom_performance_PerformanceService_h