Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim:set ts=2 sw=2 sts=2 et cindent: */
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 : #ifndef mozilla_dom_timeout_handler_h
8 : #define mozilla_dom_timeout_handler_h
9 :
10 : #include "nsCOMPtr.h"
11 : #include "nsISupports.h"
12 : #include "nsITimeoutHandler.h"
13 : #include "nsCycleCollectionParticipant.h"
14 : #include "nsString.h"
15 :
16 : namespace mozilla {
17 : namespace dom {
18 :
19 : /**
20 : * Utility class for implementing nsITimeoutHandlers, designed to be subclassed.
21 : */
22 : class TimeoutHandler : public nsITimeoutHandler
23 : {
24 : public:
25 : // TimeoutHandler doesn't actually contain cycles, but subclasses
26 : // probably will.
27 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
28 19 : NS_DECL_CYCLE_COLLECTION_CLASS(TimeoutHandler)
29 :
30 : virtual nsresult Call() override;
31 : virtual void GetLocation(const char** aFileName, uint32_t* aLineNo,
32 : uint32_t* aColumn) override;
33 0 : virtual void MarkForCC() override {}
34 : protected:
35 3 : TimeoutHandler() : mFileName(""), mLineNo(0), mColumn(0) {}
36 : explicit TimeoutHandler(JSContext *aCx);
37 :
38 0 : virtual ~TimeoutHandler() {}
39 : private:
40 : TimeoutHandler(const TimeoutHandler&) = delete;
41 : TimeoutHandler& operator=(const TimeoutHandler&) = delete;
42 : TimeoutHandler& operator=(const TimeoutHandler&&) = delete;
43 :
44 : nsCString mFileName;
45 : uint32_t mLineNo;
46 : uint32_t mColumn;
47 : };
48 :
49 : } // namespace dom
50 : } // namespace mozilla
51 :
52 : #endif // mozilla_dom_timeout_handler_h
|