Skip to content

Commit

Permalink
Adopt terms from Storage spec (#75)
Browse files Browse the repository at this point in the history
This is by no means perfect, but it's incrementally better. Forward progress!
  • Loading branch information
inexorabletash authored Nov 29, 2022
1 parent d99a991 commit ffddb56
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
text: agent cluster; url: integration-with-the-javascript-agent-cluster-formalism
spec: storage; urlPrefix: https://storage.spec.whatwg.org/
type: dfn
text: storage shelf; url: storage-shelf
text: storage bucket; url: storage-bucket
text: storage bottle; url: storage-bottle
</pre>

<style>
Expand Down Expand Up @@ -80,7 +81,7 @@ The API provides optional functionality that may be used as needed, including:
* diagnostics to query the state of locks, and
* an escape hatch to protect against deadlocks.

Cooperative coordination takes place within the scope of same-origin [=/agents=]; this may span multiple [=/agent clusters=].
Cooperative coordination takes place within the scope of [=/agents=] sharing a [=/storage bucket=]; this may span multiple [=/agent clusters=].

<aside class=note>
[=/Agents=] roughly correspond to windows (tabs), iframes, and workers. [=/Agent clusters=] correspond to independent processes in some user agent implementations.
Expand Down Expand Up @@ -155,7 +156,7 @@ The [=task source=] for [=parallel queue/enqueue steps|steps enqueued=] below is
A <dfn>resource name</dfn> is a [=JavaScript string=] chosen by the web application to represent an abstract resource.

A resource name has no external meaning beyond the scheduling algorithm, but is global
across [=/browsing contexts=] within an [=/origin=]. Web applications are free to use any resource naming scheme.
across [=/agents=] sharing a [=/storage bucket=]. Web applications are free to use any resource naming scheme.

<aside class=example id=example-indexeddb-transactions>
To mimic transaction locking over named stores within a named
Expand All @@ -171,31 +172,21 @@ Resource names starting with U+002D HYPHEN-MINUS (-) are reserved; requesting th
## Lock Managers ## {#lock-managers}
<!-- ====================================================================== -->

A [=/user agent=] has a <dfn>lock manager</dfn> for each [=/origin=], which encapsulates the state of all [=lock-concept|locks=] and [=lock requests=] for that origin.
A <dfn>lock manager</dfn> encapsulates the state of [=lock-concept|locks=] and [=lock requests=]. Each [=/storage bucket=] includes one [=/lock manager=] through an associated [=/storage bottle=] for the Web Locks API.

Note: Pages and workers ([=/agents=]) on a single [=/origin=] opened in the same user agent share a lock manager even if they are in unrelated [=/browsing contexts=].
Note: Pages and workers ([=/agents=]) sharing a [=/storage bucket=] opened in the same user agent share a [=/lock manager=] even if they are in unrelated [=/browsing contexts=].

<div algorithm>
To <dfn>obtain a lock manager</dfn>, given an [=/environment settings object=] |environment|, run these steps:

1. Let |origin| be |environment|'s [=/origin=].
1. If |origin| is an [=/opaque origin=], then return failure.
1. Return |origin|'s associated [=/lock manager=].
1. Let |map| be the result of [=/obtaining a local storage bottle map=] given |environment| and "`web-locks`".
1. If |map| is failure, then return failure.
1. Let |bottle| be |map|'s associated [=/storage bottle=].
1. Return |bottle|'s associated [=/lock manager=].

</div>

<aside class=note>

There is an equivalence between the following:

* Agents that share a [=lock manager=].
* Agents that share a [=/storage shelf=], i.e. a per-origin [=localStorage|local storage area=] [[HTML]], set of [[IndexedDB-2#database-construct|databases]] [[IndexedDB-2]], or [[Service-Workers#cache-objects|caches]] [[Service-Workers]].

</aside>

<aside class=issue>
Migrate this definition to [[HTML]] or [[Storage]] so it can be referenced by other standards.
</aside>
Issue: Refine the integration with [[Storage]] here, including how to get the lock manager properly from the given environment.


<!-- ====================================================================== -->
Expand Down

0 comments on commit ffddb56

Please sign in to comment.