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/. */
6 #ifndef mozilla_dom_workers_workerfeature_h__
7 #define mozilla_dom_workers_workerfeature_h__
9 #include "mozilla/dom/workers/Workers.h"
11 BEGIN_WORKERS_NAMESPACE
14 * Use this chart to help figure out behavior during each of the closing
15 * statuses. Details below.
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 * +-------------+-------------+-----------------+----------------+
33 /* Xlib headers insist on this for some reason... Nuke it because
34 it'll override our member name */
42 // This status means that the close handler has not yet been scheduled.
45 // Inner script called close() on the worker global scope. Setting this
46 // status causes the worker to clear its queue of events but does not abort
47 // the currently running script. The close handler is also scheduled with
48 // no expiration time.
51 // Outer script called terminate() on the worker or the worker object was
52 // garbage collected in its outer script. Setting this status causes the
53 // worker to abort immediately, clear its queue of events, and schedules the
54 // close handler with no expiration time.
57 // Either the user navigated away from the owning page or the owning page fell
58 // out of bfcache. Setting this status causes the worker to abort immediately
59 // and schedules the close handler with a short expiration time. Since the
60 // page has gone away the worker may not post any messages.
63 // The application is shutting down. Setting this status causes the worker to
64 // abort immediately and the close handler is never scheduled.
67 // The close handler has run and the worker is effectively dead.
74 virtual ~WorkerFeature() { }
76 virtual bool Suspend(JSContext
* aCx
) { return true; }
77 virtual bool Resume(JSContext
* aCx
) { return true; }
79 virtual bool Notify(JSContext
* aCx
, Status aStatus
) = 0;
84 #endif /* mozilla_dom_workers_workerfeature_h__ */