Line data Source code
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/RefPtr.h"
11 : #include "mozilla/TimeStamp.h"
12 :
13 : class CheckResponsivenessTask;
14 :
15 : // This class should only be used for the main thread.
16 : class ThreadResponsiveness {
17 : public:
18 : explicit ThreadResponsiveness();
19 :
20 : ~ThreadResponsiveness();
21 :
22 : void Update();
23 :
24 0 : mozilla::TimeDuration GetUnresponsiveDuration(const mozilla::TimeStamp& now) const {
25 0 : return now - mLastTracerTime;
26 : }
27 :
28 0 : bool HasData() const {
29 0 : return !mLastTracerTime.IsNull();
30 : }
31 : private:
32 : RefPtr<CheckResponsivenessTask> mActiveTracerEvent;
33 : mozilla::TimeStamp mLastTracerTime;
34 : };
35 :
36 : #endif
37 :
|