OLD | NEW |
1 # Architecture (as of July 29th 2016) | 1 # Architecture (as of July 29th 2016) |
2 This document descibes the browser-process implementation of the [Cache | 2 This document descibes the browser-process implementation of the [Cache |
3 Storage specification]( | 3 Storage specification]( |
4 https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html). | 4 https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html). |
5 | 5 |
6 ## Major Classes and Ownership | 6 ## Major Classes and Ownership |
7 ### Ownership | 7 ### Ownership |
8 Where '=>' represents ownership, '->' is a reference, and '~>' is a weak | 8 Where '=>' represents ownership, '->' is a reference, and '~>' is a weak |
9 reference. | 9 reference. |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 3. Manages operations that span multiple caches (e.g., `CacheStorage::Match`). | 55 3. Manages operations that span multiple caches (e.g., `CacheStorage::Match`). |
56 4. Backend-specific information is handled by `CacheStorage::CacheLoader` | 56 4. Backend-specific information is handled by `CacheStorage::CacheLoader` |
57 | 57 |
58 ### CacheStorageCache | 58 ### CacheStorageCache |
59 1. Creates or opens a net::disk_cache (either `SimpleCache` or `MemoryCache`) | 59 1. Creates or opens a net::disk_cache (either `SimpleCache` or `MemoryCache`) |
60 on initialization. | 60 on initialization. |
61 2. Handles add/put/delete/match/keys calls. | 61 2. Handles add/put/delete/match/keys calls. |
62 3. Owned by `CacheStorage` and deleted either when `CacheStorage` deletes or | 62 3. Owned by `CacheStorage` and deleted either when `CacheStorage` deletes or |
63 when the last `CacheStorageCacheHandle` for the cache is gone. | 63 when the last `CacheStorageCacheHandle` for the cache is gone. |
64 | 64 |
| 65 ### CacheStorageIndex |
| 66 1. Manages an ordered collection of metadata |
| 67 (CacheStorageIndex::CacheStorageMetadata) for each CacheStorageCache owned |
| 68 by a given CacheStorage instance. |
| 69 2. Is serialized by CacheStorage::CacheLoader (WriteIndex/LoadIndex) as a |
| 70 Protobuf file. |
| 71 |
65 ### CacheStorageCacheHandle | 72 ### CacheStorageCacheHandle |
66 1. Holds a weak reference to a `CacheStorageCache`. | 73 1. Holds a weak reference to a `CacheStorageCache`. |
67 2. When the last `CacheStorageCacheHandle` to a `CacheStorageCache` is | 74 2. When the last `CacheStorageCacheHandle` to a `CacheStorageCache` is |
68 deleted, so to is the `CacheStorageCache`. | 75 deleted, so to is the `CacheStorageCache`. |
69 3. The `CacheStorageCache` may be deleted before the `CacheStorageCacheHandle` | 76 3. The `CacheStorageCache` may be deleted before the `CacheStorageCacheHandle` |
70 (on `CacheStorage` destruction), so it must be checked for validity before | 77 (on `CacheStorage` destruction), so it must be checked for validity before |
71 use. | 78 use. |
72 | 79 |
73 ## Directory Structure | 80 ## Directory Structure |
74 $PROFILE/Service Worker/CacheStorage/`origin`/`cache`/ | 81 $PROFILE/Service Worker/CacheStorage/`origin`/`cache`/ |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 `CacheStorage` as well. This has happened in the past (`Cache::Put` called | 145 `CacheStorage` as well. This has happened in the past (`Cache::Put` called |
139 `QuotaManager` to determine how much room was available, which in turn called | 146 `QuotaManager` to determine how much room was available, which in turn called |
140 `Cache::Size`). Be careful to avoid situations in which one operation triggers | 147 `Cache::Size`). Be careful to avoid situations in which one operation triggers |
141 a dependency on another operation from the same scheduler. | 148 a dependency on another operation from the same scheduler. |
142 | 149 |
143 At the end of an operation, the scheduler needs to be kicked to start the next | 150 At the end of an operation, the scheduler needs to be kicked to start the next |
144 operation. The idiom for this in CacheStorage/ is to wrap the operation's | 151 operation. The idiom for this in CacheStorage/ is to wrap the operation's |
145 callback with a function that will run the callback as well as advance the | 152 callback with a function that will run the callback as well as advance the |
146 scheduler. So long as the operation runs its wrapped callback the scheduler | 153 scheduler. So long as the operation runs its wrapped callback the scheduler |
147 will advance. | 154 will advance. |
OLD | NEW |