dom/workers/WorkerFeature.h

branch
TOR_BUG_9701
changeset 14
925c144e1f1f
equal deleted inserted replaced
-1:000000000000 0:f8d979785976
1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
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 mozilla_dom_workers_workerfeature_h__
7 #define mozilla_dom_workers_workerfeature_h__
8
9 #include "mozilla/dom/workers/Workers.h"
10
11 BEGIN_WORKERS_NAMESPACE
12
13 /**
14 * Use this chart to help figure out behavior during each of the closing
15 * statuses. Details below.
16 *
17 * +==============================================================+
18 * | Closing Statuses |
19 * +=============+=============+=================+================+
20 * | status | clear queue | abort execution | close handler |
21 * +=============+=============+=================+================+
22 * | Closing | yes | no | no timeout |
23 * +-------------+-------------+-----------------+----------------+
24 * | Terminating | yes | yes | no timeout |
25 * +-------------+-------------+-----------------+----------------+
26 * | Canceling | yes | yes | short duration |
27 * +-------------+-------------+-----------------+----------------+
28 * | Killing | yes | yes | doesn't run |
29 * +-------------+-------------+-----------------+----------------+
30 */
31 enum Status
32 {
33 // Not yet scheduled.
34 Pending = 0,
35
36 // This status means that the close handler has not yet been scheduled.
37 Running,
38
39 // Inner script called close() on the worker global scope. Setting this
40 // status causes the worker to clear its queue of events but does not abort
41 // the currently running script. The close handler is also scheduled with
42 // no expiration time.
43 Closing,
44
45 // Outer script called terminate() on the worker or the worker object was
46 // garbage collected in its outer script. Setting this status causes the
47 // worker to abort immediately, clear its queue of events, and schedules the
48 // close handler with no expiration time.
49 Terminating,
50
51 // Either the user navigated away from the owning page or the owning page fell
52 // out of bfcache. Setting this status causes the worker to abort immediately
53 // and schedules the close handler with a short expiration time. Since the
54 // page has gone away the worker may not post any messages.
55 Canceling,
56
57 // The application is shutting down. Setting this status causes the worker to
58 // abort immediately and the close handler is never scheduled.
59 Killing,
60
61 // The close handler has run and the worker is effectively dead.
62 Dead
63 };
64
65 class WorkerFeature
66 {
67 public:
68 virtual ~WorkerFeature() { }
69
70 virtual bool Suspend(JSContext* aCx) { return true; }
71 virtual bool Resume(JSContext* aCx) { return true; }
72
73 virtual bool Notify(JSContext* aCx, Status aStatus) = 0;
74 };
75
76 END_WORKERS_NAMESPACE
77
78 #endif /* mozilla_dom_workers_workerfeature_h__ */

mercurial