Constructor
new DBEngine(name)
This manages all operations on an IndexedDB. This wraps all operations
in Promises. All Promises will resolve once the transaction has completed.
Depending on the browser, this may or may not be after the data is flushed
to disk. https://goo.gl/zMOeJc
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string |
- Implements:
- Source:
Members
-
(private, static) DB_VERSION_ :number
-
@const
Type:
- number
- Source:
-
(private) db_ :IDBDatabase
-
Type:
- IDBDatabase
- Source:
-
(private) name_ :string
-
Type:
- string
- Source:
-
(private, non-null) operations_ :Array.<shaka.offline.DBEngine.Operation>
-
Type:
- Array.<shaka.offline.DBEngine.Operation>
- Source:
Methods
-
(static) deleteDatabase(name) → (non-null) {Promise}
-
Delete the database. There must be no open connections to the database.
Parameters:
Name Type Description namestring - Source:
Returns:
- Type
- Promise
-
(static) isSupported() → {boolean}
-
Determines if the browsers supports IndexedDB.
- Source:
Returns:
- Type
- boolean
-
(private, static) onError_(errorSource, promisenon-null, eventnon-null)
-
Rejects the given Promise using the error fromt the transaction.
Parameters:
Name Type Description errorSourceIDBTransaction | IDBRequest promiseshaka.util.PublicPromise eventEvent - Source:
-
(static) onUpgrade(oldVersion, dbnon-null, transactionnon-null)
-
Parameters:
Name Type Description oldVersionnumber dbIDBDatabase transactionIDBTransaction - Source:
-
(private) add_(store, value) → (non-null) {Promise.<number>}
-
Parameters:
Name Type Description storeshaka.offline.DBUtils.StoreV2 valueT - Source:
Returns:
- Type
- Promise.<number>
-
addManifest(value) → (non-null) {Promise.<number>}
-
Add a manifest to storage.
Parameters:
Name Type Description valueshakaExtern.ManifestDB - Implements:
- Source:
Returns:
- Type
- Promise.<number>
-
addSegment(value) → (non-null) {Promise.<number>}
-
Add a segment to storage.
Parameters:
Name Type Description valueshakaExtern.SegmentDataDB - Implements:
- Source:
Returns:
- Type
- Promise.<number>
-
(private) closeOperation_(opnon-null)
-
Close an open operation.
Parameters:
Name Type Description opshaka.offline.DBEngine.Operation - Source:
-
(private) createTransaction_(storeName, type, actionnon-null) → (non-null) {Promise}
-
Creates a new transaction for the given store name and calls |action| to modify the store. The transaction will resolve or reject the promise returned by this function.
Parameters:
Name Type Description storeNamestring typestring action!function(IDBObjectStore) - Source:
Returns:
- Type
- Promise
-
destroy()
-
- Source:
-
(private) forEach_(store, each) → (non-null) {Promise}
-
Parameters:
Name Type Description storeshaka.offline.DBUtils.StoreV2 eachfunction(number, T) - Source:
Returns:
- Type
- Promise
-
forEachManifest(each) → (non-null) {Promise}
-
Iterate over all the manifests in storage.
Parameters:
Name Type Description eachfunction(number, shakaExtern.ManifestDB) - Implements:
- Source:
Returns:
- Type
- Promise
-
forEachSegment(each) → (non-null) {Promise}
-
Iterate over all the segments in storage.
Parameters:
Name Type Description eachfunction(number, shakaExtern.SegmentDataDB) - Implements:
- Source:
Returns:
- Type
- Promise
-
(private) get_(store, key) → (non-null) {Promise.<T>}
-
Parameters:
Name Type Description storeshaka.offline.DBUtils.StoreV2 keynumber - Source:
Returns:
- Type
- Promise.<T>
-
getManifest(key) → (non-null) {Promise.<shakaExtern.ManifestDB>}
-
Get a single manifest from storage using the key associated to the manifest.
Parameters:
Name Type Description keynumber - Implements:
- Source:
Returns:
- Type
- Promise.<shakaExtern.ManifestDB>
-
getSegment(key) → (non-null) {Promise.<shakaExtern.SegmentDataDB>}
-
Get a single segment from storage using the key associated to the segment.
Parameters:
Name Type Description keynumber - Implements:
- Source:
Returns:
- Type
- Promise.<shakaExtern.SegmentDataDB>
-
init(opt_updateRetriesopt) → (non-null) {Promise}
-
Parameters:
Name Type Attributes Description opt_updateRetriesnumber <optional>
The number of times to init the database expecting an upgrade. If an upgrade does not happen, the init will fail. - Source:
Returns:
- Type
- Promise
-
(private) remove_(store, keysnon-null, onKeyRemovednullable) → (non-null) {Promise}
-
Parameters:
Name Type Attributes Description storeshaka.offline.DBUtils.StoreV2 keysArray.<number> onKeyRemoved?function(number) <nullable>
- Source:
Returns:
- Type
- Promise
-
removeManifests(keynon-null, onKeyRemovednullable) → (non-null) {Promise}
-
Remove a manifest from storage using the associated key. If the key is not found, this should be a no-op. When a manifest has been removed or skipped (because not it was not found) |opt_onKeyRemoved| should be called with the key that was removed.
Parameters:
Name Type Attributes Description keyArray.<number> onKeyRemoved?function(number) <nullable>
- Implements:
- Source:
Returns:
- Type
- Promise
-
removeSegments(keynon-null, onKeyRemovednullable) → (non-null) {Promise}
-
Remove a segment from storage using the associated key. If the key is not found, this should be a no-op. When a segment has been removed or skipped (because not it was not found) |opt_onKeyRemoved| should be called with the key that was removed.
Parameters:
Name Type Attributes Description keyArray.<number> onKeyRemoved?function(number) <nullable>
- Implements:
- Source:
Returns:
- Type
- Promise
-
(private) update_(store, key, value) → (non-null) {Promise}
-
Parameters:
Name Type Description storeshaka.offline.DBUtils.StoreV2 keynumber valueT - Source:
Returns:
- Type
- Promise
-
updateManifest(key, value) → (non-null) {Promise}
-
Update a manifest already in storage.
Parameters:
Name Type Description keynumber valueshakaExtern.ManifestDB - Implements:
- Source:
Returns:
- Type
- Promise
Type Definitions
-
Operation
-
Type:
- {transaction: !IDBTransaction, promise: !shaka.util.PublicPromise}
Properties:
Name Type Description transactionIDBTransaction The transaction that this operation is using. promiseshaka.util.PublicPromise The promise associated with the operation. - Source: