/src/mozilla-central/tools/profiler/gecko/ThreadResponsiveness.h
Line | Count | Source (jump to first uncovered line) |
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 |
4 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | | |
6 | | #ifndef ThreadResponsiveness_h |
7 | | #define ThreadResponsiveness_h |
8 | | |
9 | | #include "nsISupports.h" |
10 | | #include "mozilla/Maybe.h" |
11 | | #include "mozilla/RefPtr.h" |
12 | | #include "mozilla/TimeStamp.h" |
13 | | |
14 | | class CheckResponsivenessTask; |
15 | | class nsIEventTarget; |
16 | | |
17 | | // This class should only be used for the main thread. |
18 | | class ThreadResponsiveness { |
19 | | public: |
20 | | explicit ThreadResponsiveness(nsIEventTarget* aThread, bool aIsMainThread); |
21 | | |
22 | | ~ThreadResponsiveness(); |
23 | | |
24 | | void Update(); |
25 | | |
26 | | // The number of milliseconds that elapsed since the last |
27 | | // CheckResponsivenessTask was processed. |
28 | 0 | double GetUnresponsiveDuration(double aStartToNow_ms) const { |
29 | 0 | return aStartToNow_ms - *mStartToPrevTracer_ms; |
30 | 0 | } |
31 | | |
32 | 0 | bool HasData() const { |
33 | 0 | return mStartToPrevTracer_ms.isSome(); |
34 | 0 | } |
35 | | private: |
36 | | RefPtr<CheckResponsivenessTask> mActiveTracerEvent; |
37 | | // The time at which the last CheckResponsivenessTask was processed, in |
38 | | // milliseconds since process start (i.e. what you get from profiler_time()). |
39 | | mozilla::Maybe<double> mStartToPrevTracer_ms; |
40 | | }; |
41 | | |
42 | | #endif |
43 | | |