Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 WEBGL_CONTEXT_LOSS_HANDLER_H_
7 : #define WEBGL_CONTEXT_LOSS_HANDLER_H_
8 :
9 : #include "mozilla/WeakPtr.h"
10 : #include "nsCOMPtr.h"
11 :
12 : class nsIThread;
13 : class nsITimer;
14 :
15 : namespace mozilla {
16 : class WebGLContext;
17 :
18 : class WebGLContextLossHandler final : public SupportsWeakPtr<WebGLContextLossHandler>
19 : {
20 : WebGLContext* const mWebGL;
21 : const nsCOMPtr<nsITimer> mTimer; // If we don't hold a ref to the timer, it will think
22 : bool mTimerPending; // that it's been discarded, and be canceled 'for our
23 : bool mShouldRunTimerAgain; // convenience'.
24 : #ifdef DEBUG
25 : nsISerialEventTarget* const mEventTarget;
26 : #endif
27 :
28 : friend class WatchdogTimerEvent;
29 :
30 : public:
31 0 : MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebGLContextLossHandler)
32 :
33 : explicit WebGLContextLossHandler(WebGLContext* webgl);
34 : ~WebGLContextLossHandler();
35 :
36 : void RunTimer();
37 :
38 : private:
39 : void TimerCallback();
40 : };
41 :
42 : } // namespace mozilla
43 :
44 : #endif // WEBGL_CONTEXT_LOSS_HANDLER_H_
|