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

     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
    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,
    36   // This status means that the close handler has not yet been scheduled.
    37   Running,
    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,
    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,
    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,
    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,
    61   // The close handler has run and the worker is effectively dead.
    62   Dead
    63 };
    65 class WorkerFeature
    66 {
    67 public:
    68   virtual ~WorkerFeature() { }
    70   virtual bool Suspend(JSContext* aCx) { return true; }
    71   virtual bool Resume(JSContext* aCx) { return true; }
    73   virtual bool Notify(JSContext* aCx, Status aStatus) = 0;
    74 };
    76 END_WORKERS_NAMESPACE
    78 #endif /* mozilla_dom_workers_workerfeature_h__ */

mercurial