Class: shaka.offline.DBEngine

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:
Source:

Methods

(static) deleteDatabase(name) → (non-null) {Promise}

Delete the database. There must be no open connections to the database.
Parameters:
Name Type Description
name string
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
errorSource IDBTransaction | IDBRequest
promise shaka.util.PublicPromise
event Event
Source:

(static) onUpgrade(oldVersion, dbnon-null, transactionnon-null)

Parameters:
Name Type Description
oldVersion number
db IDBDatabase
transaction IDBTransaction
Source:

(private) add_(store, value) → (non-null) {Promise.<number>}

Parameters:
Name Type Description
store shaka.offline.DBUtils.StoreV2
value T
Source:
Returns:
Type
Promise.<number>

addManifest(value) → (non-null) {Promise.<number>}

Add a manifest to storage.
Parameters:
Name Type Description
value shakaExtern.ManifestDB
Implements:
Source:
Returns:
Type
Promise.<number>

addSegment(value) → (non-null) {Promise.<number>}

Add a segment to storage.
Parameters:
Name Type Description
value shakaExtern.SegmentDataDB
Implements:
Source:
Returns:
Type
Promise.<number>

(private) closeOperation_(opnon-null)

Close an open operation.
Parameters:
Name Type Description
op shaka.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
storeName string
type string
action !function(IDBObjectStore)
Source:
Returns:
Type
Promise

destroy()

Source:

(private) forEach_(store, each) → (non-null) {Promise}

Parameters:
Name Type Description
store shaka.offline.DBUtils.StoreV2
each function(number, T)
Source:
Returns:
Type
Promise

forEachManifest(each) → (non-null) {Promise}

Iterate over all the manifests in storage.
Parameters:
Name Type Description
each function(number, shakaExtern.ManifestDB)
Implements:
Source:
Returns:
Type
Promise

forEachSegment(each) → (non-null) {Promise}

Iterate over all the segments in storage.
Parameters:
Name Type Description
each function(number, shakaExtern.SegmentDataDB)
Implements:
Source:
Returns:
Type
Promise

(private) get_(store, key) → (non-null) {Promise.<T>}

Parameters:
Name Type Description
store shaka.offline.DBUtils.StoreV2
key number
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
key number
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
key number
Implements:
Source:
Returns:
Type
Promise.<shakaExtern.SegmentDataDB>

init(opt_updateRetriesopt) → (non-null) {Promise}

Parameters:
Name Type Attributes Description
opt_updateRetries number <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
store shaka.offline.DBUtils.StoreV2
keys Array.<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
key Array.<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
key Array.<number>
onKeyRemoved ?function(number) <nullable>
Implements:
Source:
Returns:
Type
Promise

(private) update_(store, key, value) → (non-null) {Promise}

Parameters:
Name Type Description
store shaka.offline.DBUtils.StoreV2
key number
value T
Source:
Returns:
Type
Promise

updateManifest(key, value) → (non-null) {Promise}

Update a manifest already in storage.
Parameters:
Name Type Description
key number
value shakaExtern.ManifestDB
Implements:
Source:
Returns:
Type
Promise

Type Definitions

Operation

Type:
Properties:
Name Type Description
transaction IDBTransaction The transaction that this operation is using.
promise shaka.util.PublicPromise The promise associated with the operation.
Source: