/src/mozilla-central/dom/performance/PerformanceService.cpp
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 | | #include "PerformanceService.h" |
8 | | |
9 | | #include "mozilla/ClearOnShutdown.h" |
10 | | #include "mozilla/StaticMutex.h" |
11 | | #include "mozilla/StaticPtr.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace dom { |
15 | | |
16 | | static StaticRefPtr<PerformanceService> gPerformanceService; |
17 | | static StaticMutex gPerformanceServiceMutex; |
18 | | |
19 | | /* static */ PerformanceService* |
20 | | PerformanceService::GetOrCreate() |
21 | 0 | { |
22 | 0 | StaticMutexAutoLock al(gPerformanceServiceMutex); |
23 | 0 |
|
24 | 0 | if (!gPerformanceService) { |
25 | 0 | gPerformanceService = new PerformanceService(); |
26 | 0 | ClearOnShutdown(&gPerformanceService); |
27 | 0 | } |
28 | 0 |
|
29 | 0 | return gPerformanceService; |
30 | 0 | } |
31 | | |
32 | | DOMHighResTimeStamp |
33 | | PerformanceService::TimeOrigin(const TimeStamp& aCreationTimeStamp) const |
34 | 0 | { |
35 | 0 | return (aCreationTimeStamp - mCreationTimeStamp).ToMilliseconds() + |
36 | 0 | (mCreationEpochTime / PR_USEC_PER_MSEC); |
37 | 0 | } |
38 | | |
39 | | PerformanceService::PerformanceService() |
40 | 0 | { |
41 | 0 | mCreationTimeStamp = TimeStamp::Now(); |
42 | 0 | mCreationEpochTime = PR_Now(); |
43 | 0 | } |
44 | | |
45 | | } // dom namespace |
46 | | } // mozilla namespace |