LCOV - code coverage report
Current view: directory - dom/workers - WorkerFeature.h (source / functions) Found Hit Coverage
Test: app.info Lines: 4 0 0.0 %
Date: 2012-06-02 Functions: 5 0 0.0 %

       1                 : /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is Web Workers.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  *   The Mozilla Foundation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2011
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Ben Turner <bent.mozilla@gmail.com> (Original Author)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #ifndef mozilla_dom_workers_workerfeature_h__
      40                 : #define mozilla_dom_workers_workerfeature_h__
      41                 : 
      42                 : #include "Workers.h"
      43                 : 
      44                 : #include "jspubtd.h"
      45                 : 
      46                 : BEGIN_WORKERS_NAMESPACE
      47                 : 
      48                 : /**
      49                 :  * Use this chart to help figure out behavior during each of the closing
      50                 :  * statuses. Details below.
      51                 :  *
      52                 :  * +==============================================================+
      53                 :  * |                       Closing Statuses                       |
      54                 :  * +=============+=============+=================+================+
      55                 :  * |    status   | clear queue | abort execution |  close handler |
      56                 :  * +=============+=============+=================+================+
      57                 :  * |   Closing   |     yes     |       no        |   no timeout   |
      58                 :  * +-------------+-------------+-----------------+----------------+
      59                 :  * | Terminating |     yes     |       yes       |   no timeout   |
      60                 :  * +-------------+-------------+-----------------+----------------+
      61                 :  * |  Canceling  |     yes     |       yes       | short duration |
      62                 :  * +-------------+-------------+-----------------+----------------+
      63                 :  * |   Killing   |     yes     |       yes       |   doesn't run  |
      64                 :  * +-------------+-------------+-----------------+----------------+
      65                 :  */
      66                 : enum Status
      67                 : {
      68                 :   // Not yet scheduled.
      69                 :   Pending = 0,
      70                 : 
      71                 :   // This status means that the close handler has not yet been scheduled.
      72                 :   Running,
      73                 : 
      74                 :   // Inner script called close() on the worker global scope. Setting this
      75                 :   // status causes the worker to clear its queue of events but does not abort
      76                 :   // the currently running script. The close handler is also scheduled with
      77                 :   // no expiration time.
      78                 :   Closing,
      79                 : 
      80                 :   // Outer script called terminate() on the worker or the worker object was
      81                 :   // garbage collected in its outer script. Setting this status causes the
      82                 :   // worker to abort immediately, clear its queue of events, and schedules the
      83                 :   // close handler with no expiration time.
      84                 :   Terminating,
      85                 : 
      86                 :   // Either the user navigated away from the owning page or the owning page fell
      87                 :   // out of bfcache. Setting this status causes the worker to abort immediately
      88                 :   // and schedules the close handler with a short expiration time. Since the
      89                 :   // page has gone away the worker may not post any messages.
      90                 :   Canceling,
      91                 : 
      92                 :   // The application is shutting down. Setting this status causes the worker to
      93                 :   // abort immediately and the close handler is never scheduled.
      94                 :   Killing,
      95                 : 
      96                 :   // The close handler has run and the worker is effectively dead.
      97                 :   Dead
      98                 : };
      99                 : 
     100                 : class WorkerFeature
     101               0 : {
     102                 : public:
     103               0 :   virtual ~WorkerFeature() { }
     104                 : 
     105               0 :   virtual bool Suspend(JSContext* aCx) { return true; }
     106               0 :   virtual bool Resume(JSContext* aCx) { return true; }
     107                 : 
     108                 :   virtual bool Notify(JSContext* aCx, Status aStatus) = 0;
     109                 : };
     110                 : 
     111                 : END_WORKERS_NAMESPACE
     112                 : 
     113                 : #endif /* mozilla_dom_workers_workerfeature_h__ */

Generated by: LCOV version 1.7