dom/workers/WorkerFeature.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial