/src/mozilla-central/dom/workers/WorkerEventTarget.h
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 | | #ifndef mozilla_dom_WorkerEventTarget_h |
8 | | #define mozilla_dom_WorkerEventTarget_h |
9 | | |
10 | | #include "nsISerialEventTarget.h" |
11 | | #include "mozilla/Mutex.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace dom { |
15 | | |
16 | | class WorkerPrivate; |
17 | | |
18 | | class WorkerEventTarget final : public nsISerialEventTarget |
19 | | { |
20 | | public: |
21 | | // The WorkerEventTarget supports different dispatch behaviors: |
22 | | // |
23 | | // * Hybrid targets will attempt to dispatch as a normal runnable, |
24 | | // but fallback to a control runnable if that fails. This is |
25 | | // often necessary for code that wants normal dispatch order, but |
26 | | // also needs to execute while the worker is shutting down (possibly |
27 | | // with a holder in place.) |
28 | | // |
29 | | // * ControlOnly targets will simply dispatch a control runnable. |
30 | | enum class Behavior : uint8_t { |
31 | | Hybrid, |
32 | | ControlOnly |
33 | | }; |
34 | | |
35 | | private: |
36 | | mozilla::Mutex mMutex; |
37 | | WorkerPrivate* mWorkerPrivate; |
38 | | const Behavior mBehavior; |
39 | | |
40 | 0 | ~WorkerEventTarget() = default; |
41 | | |
42 | | public: |
43 | | WorkerEventTarget(WorkerPrivate* aWorkerPrivate, Behavior aBehavior); |
44 | | |
45 | | void |
46 | | ForgetWorkerPrivate(WorkerPrivate* aWorkerPrivate); |
47 | | |
48 | | NS_DECL_THREADSAFE_ISUPPORTS |
49 | | NS_DECL_NSIEVENTTARGET |
50 | | NS_DECL_NSISERIALEVENTTARGET |
51 | | }; |
52 | | |
53 | | } // dom namespace |
54 | | } // mozilla namespace |
55 | | |
56 | | #endif // mozilla_dom_WorkerEventTarget_h |