michael@0: /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_workers_workerfeature_h__ michael@0: #define mozilla_dom_workers_workerfeature_h__ michael@0: michael@0: #include "mozilla/dom/workers/Workers.h" michael@0: michael@0: BEGIN_WORKERS_NAMESPACE michael@0: michael@0: /** michael@0: * Use this chart to help figure out behavior during each of the closing michael@0: * statuses. Details below. michael@0: * michael@0: * +==============================================================+ michael@0: * | Closing Statuses | michael@0: * +=============+=============+=================+================+ michael@0: * | status | clear queue | abort execution | close handler | michael@0: * +=============+=============+=================+================+ michael@0: * | Closing | yes | no | no timeout | michael@0: * +-------------+-------------+-----------------+----------------+ michael@0: * | Terminating | yes | yes | no timeout | michael@0: * +-------------+-------------+-----------------+----------------+ michael@0: * | Canceling | yes | yes | short duration | michael@0: * +-------------+-------------+-----------------+----------------+ michael@0: * | Killing | yes | yes | doesn't run | michael@0: * +-------------+-------------+-----------------+----------------+ michael@0: */ michael@0: enum Status michael@0: { michael@0: // Not yet scheduled. michael@0: Pending = 0, michael@0: michael@0: // This status means that the close handler has not yet been scheduled. michael@0: Running, michael@0: michael@0: // Inner script called close() on the worker global scope. Setting this michael@0: // status causes the worker to clear its queue of events but does not abort michael@0: // the currently running script. The close handler is also scheduled with michael@0: // no expiration time. michael@0: Closing, michael@0: michael@0: // Outer script called terminate() on the worker or the worker object was michael@0: // garbage collected in its outer script. Setting this status causes the michael@0: // worker to abort immediately, clear its queue of events, and schedules the michael@0: // close handler with no expiration time. michael@0: Terminating, michael@0: michael@0: // Either the user navigated away from the owning page or the owning page fell michael@0: // out of bfcache. Setting this status causes the worker to abort immediately michael@0: // and schedules the close handler with a short expiration time. Since the michael@0: // page has gone away the worker may not post any messages. michael@0: Canceling, michael@0: michael@0: // The application is shutting down. Setting this status causes the worker to michael@0: // abort immediately and the close handler is never scheduled. michael@0: Killing, michael@0: michael@0: // The close handler has run and the worker is effectively dead. michael@0: Dead michael@0: }; michael@0: michael@0: class WorkerFeature michael@0: { michael@0: public: michael@0: virtual ~WorkerFeature() { } michael@0: michael@0: virtual bool Suspend(JSContext* aCx) { return true; } michael@0: virtual bool Resume(JSContext* aCx) { return true; } michael@0: michael@0: virtual bool Notify(JSContext* aCx, Status aStatus) = 0; michael@0: }; michael@0: michael@0: END_WORKERS_NAMESPACE michael@0: michael@0: #endif /* mozilla_dom_workers_workerfeature_h__ */