From 4081f129ac4667fccd365b4a68de4aff0211b2f1 Mon Sep 17 00:00:00 2001 From: Jungkee Song Date: Thu, 28 Apr 2016 00:07:34 +0900 Subject: [PATCH] Move worker's close() to dedicated and shared worker As WorkerGlobalScope's close() method should not be exposed to one of its derived interfaces, ServiceWorkerGlobalScope, close() needs to be moved to the derived interfaces which explicitly require it. This commit moves close() to DedicatedWorkerGlobalScope and SharedWorkerGlobalScope. Related issue: https://github.com/slightlyoff/ServiceWorker/issues/865. --- source | 73 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/source b/source index 7fcd07b45d9..2ed247a2530 100644 --- a/source +++ b/source @@ -96156,8 +96156,6 @@ interface WorkerGlobalScope : EventTarget { readonly attribute WorkerNavigator navigator; void importScripts(DOMString... urls); - void close(); - attribute OnErrorEventHandler onerror; attribute EventHandler onlanguagechange; attribute EventHandler onoffline; @@ -96199,9 +96197,6 @@ interface WorkerGlobalScope : EventTarget {
workerGlobal . importScripts(urls...)
Fetches each URL in urls, executes them one-by-one in the order they are passed, and then returns (or throws if something went amiss).
- -
workerGlobal . close()
-
Aborts workerGlobal.
@@ -96218,24 +96213,6 @@ interface WorkerGlobalScope : EventTarget { WorkerGlobalScope object, this is not problematic as it cannot be observed from script.

-
- -

When a script invokes the close() - method on a WorkerGlobalScope object, the user agent must run the following steps - (atomically):

- -
    - -
  1. Discard any tasks that have been added to the - WorkerGlobalScope object's event loop's task - queues.

    - -
  2. Set the worker's WorkerGlobalScope object's closing flag to true. (This prevents any further - tasks from being queued.)

  3. - -
-

@@ -96262,6 +96239,9 @@ interface WorkerGlobalScope : EventTarget {
[Global=(Worker,DedicatedWorker),Exposed=DedicatedWorker]
 /*sealed*/ interface DedicatedWorkerGlobalScope : WorkerGlobalScope {
   void postMessage(any message, optional sequence<object> transfer = []);
+
+  void close();
+
   attribute EventHandler onmessage;
 };
@@ -96273,11 +96253,45 @@ interface WorkerGlobalScope : EventTarget {

All messages received by that port must immediately be retargeted at the DedicatedWorkerGlobalScope object.

+
+
dedicatedWorkerGlobal . postMessage(message [, + transfer ])
+
Clones message and transmits it to the Worker object associated with + dedicatedWorkerGlobal. transfer can be passed as a list of objects that are + to be transfered rather than cloned.
+ +
dedicatedWorkerGlobal . close()
+
Aborts dedicatedWorkerGlobal.
+
+

The postMessage() method on DedicatedWorkerGlobalScope objects must act as if, when invoked, it immediately invoked the method of the same name on the port, with the same arguments, and returned the same return value.

+
+ +

To close a worker, given a workerGlobal, run these steps:

+ +
    +
  1. Discard any tasks that have been added to + workerGlobal's event loop's task + queues.

    + +
  2. Set workerGlobal's closing + flag to true. (This prevents any further tasks from being queued.)

  3. +
+ +

The close() method, when + invoked, must close a worker with this DedicatedWorkerGlobalScope + object.

+ +
+ +
+

The following are the event handlers (and their corresponding event handler event types) that must be supported, as event handler IDL attributes, by objects implementing the DedicatedWorkerGlobalScope @@ -96301,6 +96315,9 @@ interface WorkerGlobalScope : EventTarget { /*sealed*/ interface SharedWorkerGlobalScope : WorkerGlobalScope { readonly attribute DOMString name; readonly attribute ApplicationCache applicationCache; // deprecated + + void close(); + attribute EventHandler onconnect; }; @@ -96318,6 +96335,10 @@ interface WorkerGlobalScope : EventTarget {

sharedWorkerGlobal . name
Returns sharedWorkerGlobal's name.
+ +
sharedWorkerGlobal . close()
+
Aborts sharedWorkerGlobal.
@@ -96327,8 +96348,14 @@ interface WorkerGlobalScope : EventTarget { data-x="concept-SharedWorkerGlobalScope-name">name. Its value represents the name that can be used to obtain a reference to the worker using the SharedWorker constructor.

+

The close() method, when + invoked, must close a worker with this SharedWorkerGlobalScope + object.

+
+
+

The following are the event handlers (and their corresponding event handler event types) that must be supported, as event handler IDL attributes, by objects implementing the SharedWorkerGlobalScope