1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/workers/WorkerFeature.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef mozilla_dom_workers_workerfeature_h__ 1.10 +#define mozilla_dom_workers_workerfeature_h__ 1.11 + 1.12 +#include "mozilla/dom/workers/Workers.h" 1.13 + 1.14 +BEGIN_WORKERS_NAMESPACE 1.15 + 1.16 +/** 1.17 + * Use this chart to help figure out behavior during each of the closing 1.18 + * statuses. Details below. 1.19 + * 1.20 + * +==============================================================+ 1.21 + * | Closing Statuses | 1.22 + * +=============+=============+=================+================+ 1.23 + * | status | clear queue | abort execution | close handler | 1.24 + * +=============+=============+=================+================+ 1.25 + * | Closing | yes | no | no timeout | 1.26 + * +-------------+-------------+-----------------+----------------+ 1.27 + * | Terminating | yes | yes | no timeout | 1.28 + * +-------------+-------------+-----------------+----------------+ 1.29 + * | Canceling | yes | yes | short duration | 1.30 + * +-------------+-------------+-----------------+----------------+ 1.31 + * | Killing | yes | yes | doesn't run | 1.32 + * +-------------+-------------+-----------------+----------------+ 1.33 + */ 1.34 +enum Status 1.35 +{ 1.36 + // Not yet scheduled. 1.37 + Pending = 0, 1.38 + 1.39 + // This status means that the close handler has not yet been scheduled. 1.40 + Running, 1.41 + 1.42 + // Inner script called close() on the worker global scope. Setting this 1.43 + // status causes the worker to clear its queue of events but does not abort 1.44 + // the currently running script. The close handler is also scheduled with 1.45 + // no expiration time. 1.46 + Closing, 1.47 + 1.48 + // Outer script called terminate() on the worker or the worker object was 1.49 + // garbage collected in its outer script. Setting this status causes the 1.50 + // worker to abort immediately, clear its queue of events, and schedules the 1.51 + // close handler with no expiration time. 1.52 + Terminating, 1.53 + 1.54 + // Either the user navigated away from the owning page or the owning page fell 1.55 + // out of bfcache. Setting this status causes the worker to abort immediately 1.56 + // and schedules the close handler with a short expiration time. Since the 1.57 + // page has gone away the worker may not post any messages. 1.58 + Canceling, 1.59 + 1.60 + // The application is shutting down. Setting this status causes the worker to 1.61 + // abort immediately and the close handler is never scheduled. 1.62 + Killing, 1.63 + 1.64 + // The close handler has run and the worker is effectively dead. 1.65 + Dead 1.66 +}; 1.67 + 1.68 +class WorkerFeature 1.69 +{ 1.70 +public: 1.71 + virtual ~WorkerFeature() { } 1.72 + 1.73 + virtual bool Suspend(JSContext* aCx) { return true; } 1.74 + virtual bool Resume(JSContext* aCx) { return true; } 1.75 + 1.76 + virtual bool Notify(JSContext* aCx, Status aStatus) = 0; 1.77 +}; 1.78 + 1.79 +END_WORKERS_NAMESPACE 1.80 + 1.81 +#endif /* mozilla_dom_workers_workerfeature_h__ */