Skip to content

Commit

Permalink
Refine Cache API (#1190)
Browse files Browse the repository at this point in the history
* Remove incumbent/fetching record from Cache behavior

 - Remove the incumbent/fetching record concept that allowed committing
   a fetching resource to cache and match/matchAll to return a fully
   written existing resource, if any, with priority over a fetching
   resource. After this change, add/addAll/put promises resolve when the
   resources ared fully fetched and committed to cache. match/matchAll
   will not return any on-going fetching resources.

 - Change the specification type of underlying cache objects from a map
   (request to response map) to a list (request response list). The
   change is to make the arguments and the return values of the Cache
   methods and algorithms (Batch Cache Operations and Query Cache)
   conform to one another. The list type seems fine as the algorithms
   tend to iterate through the list to find certain items with search
   options.

* Correct the use of objects associated to JS realm and global

 - Replace CacheBatchOperations dictionary which isn't exposed to
   JavaScript surface with cache batch operations struct.
 - Do not store JS objects in the storage but store request and response
   structs instead.
 - Create and return JS objects in the target realm when requested (from
   matchAll() and keys()).

* Refactor algorithms

 - Simplify "put" operation related steps by moving/refactoring the
   post-Batch Cache Operation steps, which clear the invalid items, from
   addAll() and put() into Batch Cache Operations.
 - Move the argument validation steps of cache.keys() out of the
   parallel thread to main thread.
 - Fix cacheStorage.keys() to run the steps async.
 - Change to early-exit in fetch abort cases.
 - Fix async steps of fulfillment handlers.
 - Change the interface of Batch Cache Operations algorithm.
  . Change to not return a promise
  . Remove the in parallel steps and make it work synchronously
  . Change the call sites to call it in a created promise's in parallel
    steps

Fixes #884.

* NB: HTML files in this commit aren't updated due to huge merge
conflicts. A separate commit with the updated HTMLs will follow this
commit with a proper link to it.
  • Loading branch information
jungkees authored Oct 13, 2017
1 parent 698dfd9 commit c8ab714
Show file tree
Hide file tree
Showing 2 changed files with 544 additions and 560 deletions.
Loading

0 comments on commit c8ab714

Please sign in to comment.