Skip to content

Commit

Permalink
* Defer opaque origin checks to "obtain a poodle beetle noodle bottle…
Browse files Browse the repository at this point in the history
… paddle battle" algorithm.

* Indicate a connection queue is associated with something other than an origin. A bottle? Map? Not sure.
  • Loading branch information
inexorabletash committed May 18, 2020
1 parent 4e16df4 commit 09203f3
Showing 1 changed file with 24 additions and 31 deletions.
55 changes: 24 additions & 31 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
type: dfn
text: sequence<any>; url: idl-sequence
text: sequence<DOMString>; url: idl-sequence
spec: storage; urlPrefix: https://storage.spec.whatwg.org/
type: dfn
text: storage identifier; url: storage-identifier
text: storage bottle; url: storage-bottle
for: storage bottle; text: map; url: storage-bottle-map
text: storage bucket; url: storage-bucket
text: storage proxy map; url: storage-proxy-map
for: storage proxy map; text: backing map; url: storage-proxy-map-backing-map
text: obtain a local storage bottle map; url: obtain-a-local-storage-bottle-map
</pre>

<style>
Expand Down Expand Up @@ -949,7 +958,7 @@ A [=/transaction=] has a <dfn>durability hint</dfn>. This is a hint to the user
: {{"relaxed"}}
:: The user agent may consider that the [=/transaction=] has successfully [=transaction/committed=] as soon as all outstanding changes have been written to the operating system, without subsequent verification.
: {{"default"}}
:: The user agent should use its default durability behavior for the storage [=/bucket=]. This is the default for [=/transactions=] if not otherwise specified.
:: The user agent should use its default durability behavior for the storage [=/storage bucket=]. This is the default for [=/transactions=] if not otherwise specified.

<aside class=note>
In a typical implementation, {{"strict"}} is a hint to the user agent to flush any operating system I/O buffers before a {{"complete"}} event is fired. While this provides greater confidence that the changes will be persisted in case of subsequent operating system crash or power loss, flushing buffers can take significant time and consume battery life on portable devices.
Expand Down Expand Up @@ -1274,14 +1283,17 @@ unless an <a event>`upgradeneeded`</a> event has been fired.
An [=open request=]'s [=get the parent=] algorithm returns null.

[=Open requests=] are processed in a <dfn>connection queue</dfn>.
The queue contains all [=open requests=] associated with an
[=/origin=] and a [=database/name=]. Requests added to the
The queue contains all [=open requests=] associated with a
[=/storage bottle=] and a [=database/name=]. Requests added to the
[=connection queue=] processed in order and each request must run
to completion before the next request is processed. An open request
may be blocked on other [=/connections=], requiring those
connections to [=connection/close=] before the request can complete and allow
further requests to be processed.

Issue: Make the queue/bottle (or bottle map) association more rigorous.


<aside class=note>
A [=connection queue=] is not a [=task queue=] associated with
an [=/event loop=], as the requests are processed outside any
Expand Down Expand Up @@ -2210,17 +2222,14 @@ when invoked, must run these steps:

1. Let |environment| be [=/this=]'s [=/relevant settings object=].

1. Let |origin| be |environment|'s [=environment settings object/origin=].

1. If |origin| is an [=opaque origin=], [=throw=] a
"{{SecurityError}}" {{DOMException}} and abort these steps.
1. Let |map| be the result of running [=/obtain a local storage bottle map=] with |environment| and <code>"indexedDB"</code>. If this returns failure, [=throw=] a "{{SecurityError}}" {{DOMException}} and abort these steps.

1. Let |request| be a new [=open request=].

1. Run these steps [=in parallel=]:

1. Let |result| be the result of running
[=open a database=], with |environment|,
[=open a database=], with |map|,
|name|, |version| if given and undefined
otherwise, and |request|.

Expand Down Expand Up @@ -2282,17 +2291,14 @@ when invoked, must run these steps:

1. Let |environment| be [=/this=]'s [=/relevant settings object=].

1. Let |origin| be |environment|'s [=environment settings object/origin=].

1. If |origin| is an [=opaque origin=], [=throw=] a
"{{SecurityError}}" {{DOMException}} and abort these steps.
1. Let |map| be the result of running [=/obtain a local storage bottle map=] with |environment| and <code>"indexedDB"</code>. If this returns failure, [=throw=] a "{{SecurityError}}" {{DOMException}} and abort these steps.

1. Let |request| be a new [=open request=].

1. Run these steps [=in parallel=]:

1. Let |result| be the result of running
[=delete a database=], with |environment|,
[=delete a database=], with |map|,
|name|, and |request|.

1. Set |request|'s [=request/processed flag=] to true.
Expand Down Expand Up @@ -2339,16 +2345,11 @@ when invoked, must run these steps:

1. Let |environment| be [=/this=]'s [=/relevant settings object=].

1. Let |origin| be |environment|'s [=environment settings object/origin=].

1. If |origin| is an [=opaque origin=],
then return [=/a promise rejected with=] a "{{SecurityError}}" {{DOMException}}.

1. Let |p| be [=/a new promise=].

1. Run these steps [=in parallel=]:

1. Let |map| be the result of running [=/obtain a local bottle storage map=] with |environment| and <code>"indexedDB"</code>. If this returns failure, [=/reject=] |p| with an appropriate error (e.g. an "{{UnknownError}}" {{DOMException}}) and terminate these steps.
1. Let |map| be the result of running [=/obtain a local storage bottle map=] with |environment| and <code>"indexedDB"</code>. If this returns failure, [=/reject=] |p| with a "{{SecurityError}}" {{DOMException}} and terminate these steps.

1. [=map/For each=] |name| &rarr; |db| of |map|:

Expand Down Expand Up @@ -4998,18 +4999,14 @@ event handler for the <a event>`error`</a> event.

<div class=algorithm>

To <dfn>open a database</dfn> with [=/environment settings object=] |environment|, a database |name|, a database |version|, and a |request|, run these steps:

1. Let |origin| be |environment|'s [=environment settings object/origin=].
To <dfn>open a database</dfn> with [=/storage proxy map=] |map|, a database |name|, a database |version|, and a |request|, run these steps:

1. Let |queue| be the [=connection queue=] for |origin| and |name|.
1. Let |queue| be the [=connection queue=] for |map|'s [=storage proxy map/backing map=] and |name|.

1. Add |request| to |queue|.

1. Wait until all previous requests in |queue| have been processed.

1. Let |map| be the result of running [=/obtain a local bottle storage map=] with |environment| and <code>"indexedDB"</code>. If this returns failure, return an appropriate error (e.g. an "{{UnknownError}}" {{DOMException}}).

1. Let |db| be |map|\[|name|] if it [=map/exists=], or null otherwise.

1. If |version| is undefined, let |version| be 1 if |db| is null, or
Expand Down Expand Up @@ -5126,18 +5123,14 @@ optional |forced flag|, run these steps:

<div class=algorithm>

To <dfn>delete a database</dfn> with [=/environment settings object=] |environment|, a database |name|, and a |request|, run these steps:
To <dfn>delete a database</dfn> with [=/storage proxy map=] |map|, a database |name|, and a |request|, run these steps:

1. Let |origin| be |environment|'s [=environment settings object/origin=].

1. Let |queue| be the [=connection queue=] for |origin| and |name|.
1. Let |queue| be the [=connection queue=] for |map|'s [=storage proxy map/backing map=] and |name|.

1. Add |request| to |queue|.

1. Wait until all previous requests in |queue| have been processed.

1. Let |map| be the result of running [=/obtain a local bottle storage map=] with |environment| and <code>"indexedDB"</code>. If this returns failure, return an appropriate error (e.g. an "{{UnknownError}}" {{DOMException}}).

1. If |map|\[|name|] does not [=map/exist=], then return 0 (zero).

1. Otherwise, let |db| be |map|\[|name|].
Expand Down

0 comments on commit 09203f3

Please sign in to comment.