Class: shaka.offline.DBEngine

Constructor

new DBEngine()

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

Members

(private, static) DB_NAME_ :string

Type:
  • string
Source:

(private, static) DB_VERSION_ :number

@const
Type:
  • number
Source:

(private, non-null) currentIdMap_ :Object.<string, number>

Type:
  • Object.<string, number>
Source:

(private) db_ :IDBDatabase

Type:
  • IDBDatabase
Source:

(private, non-null) operations_ :Array.<shaka.offline.DBEngine.Operation>

Type:
Source:

Methods

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

Delete the database. There must be no open connections to the database.
Source:
Returns:
Type
Promise

(static) isSupported() → {boolean}

Determines if the browsers supports IndexedDB.
Source:
Returns:
Type
boolean

(private, static) onError_(errorSource, promisenon-null, event)

Rejects the given Promise using the error fromt the transaction.
Parameters:
Name Type Description
errorSource IDBTransaction | IDBRequest
promise shaka.util.PublicPromise
event Event
Source:

(private) closeOperation_(opnon-null)

Close an open operation.
Parameters:
Name Type Description
op shaka.offline.DBEngine.Operation
Source:

(private) createConnection_(storeMapnon-null, opt_retryCountopt) → (non-null) {Promise}

Creates a new connection to the database. On IE/Edge, it is possible for the database to not be deleted when the success callback is fired. This means that when we delete the database and immediately create a new connection, we will connect to the old database. If this happens, we need to close the connection and retry.
Parameters:
Name Type Attributes Description
storeMap Object.<string, string>
opt_retryCount number <optional>
Source:
See:
Returns:
Type
Promise

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

forEach(storeName, callback) → (non-null) {Promise}

Calls the given callback for each value in the store. The promise will resolve after all items have been traversed.
Parameters:
Name Type Description
storeName string
callback function(T)
Implements:
Source:
Returns:
Type
Promise

get(storeName, key) → (non-null) {Promise.<T>}

Gets the item with the given ID in the store.
Parameters:
Name Type Description
storeName string
key number
Implements:
Source:
Returns:
Type
Promise.<T>

(private) getNextId_(storeName) → (non-null) {Promise.<number>}

Gets the ID to start at.
Parameters:
Name Type Description
storeName string
Source:
Returns:
Type
Promise.<number>

init(storeMapnon-null, opt_retryCountopt) → (non-null) {Promise}

Initializes the storage system and creates the required tables. If opt_retryCount is given, then we are creating a new database and expect an 'upgradeneeded' event. If we don't get one, we will retry opt_retryCount times. This is used to work around a bug in IE/Edge and is only used in our unit tests.
Parameters:
Name Type Attributes Description
storeMap Object.<string, string> A map of store name to the key path.
opt_retryCount number <optional>
Implements:
Source:
Returns:
Type
Promise

initialized() → {boolean}

Gets whether the storage engine is initialized.
Implements:
Source:
Returns:
Type
boolean

insert(storeName, valuenon-null) → (non-null) {Promise}

Adds or updates the given value in the store.
Parameters:
Name Type Description
storeName string
value Object
Implements:
Source:
Returns:
Type
Promise

remove(storeName, key) → (non-null) {Promise}

Removes the item with the given key.
Parameters:
Name Type Description
storeName string
key number
Implements:
Source:
Returns:
Type
Promise

removeKeys(storeName, keysnon-null, opt_onKeyRemovedopt) → (non-null) {Promise}

Removes the elements with the given keys.
Parameters:
Name Type Attributes Description
storeName string
keys Array.<number>
opt_onKeyRemoved function()= <optional>
Implements:
Source:
Returns:
Type
Promise

reserveId(storeName) → {number}

Reserves the next ID and returns it.
Parameters:
Name Type Description
storeName string
Implements:
Source:
Returns:
Type
number

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: