Files
shaka-player/lib/offline/i_storage_engine.js
T
Aaron Vaage 3db0f3357a Creating IStorageEngine Interface
To better support alternate storage mechanisms, this change abstracts
shaka.offline.DBEngine into an interface called
shaka.offline.IStorageEngine.

DBEngine has been changed to implement this interface, and allows the
addition of implementations that do not use IndexedDB.

Change-Id: I6a94067001ee53049df11cb68604bb57912300bb
2017-02-10 21:27:32 +00:00

113 lines
2.4 KiB
JavaScript

/**
* @license
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
goog.provide('shaka.offline.IStorageEngine');
goog.require('shaka.util.IDestroyable');
/**
* An interface to abstract away the type of storage used on a specific
* platform.
*
* @interface
* @extends {shaka.util.IDestroyable}
*/
shaka.offline.IStorageEngine = function() {};
/**
* Gets whether the storage engine is initialized.
*
* @return {boolean}
*/
shaka.offline.IStorageEngine.prototype.initialized;
/**
* Initializes the storage system and creates the required tables.
*
* @param {!Object.<string, string>} storeMap
* A map of store name to the key path.
* @return {!Promise}
*/
shaka.offline.IStorageEngine.prototype.init;
/**
* Gets the item with the given ID in the store.
*
* @param {string} storeName
* @param {number} key
* @return {!Promise.<T>}
* @template T
*/
shaka.offline.IStorageEngine.prototype.get;
/**
* Calls the given callback for each value in the store. The promise will
* resolve after all items have been traversed.
*
* @param {string} storeName
* @param {function(T)} callback
* @return {!Promise}
* @template T
*/
shaka.offline.IStorageEngine.prototype.forEach;
/**
* Adds or updates the given value in the store.
*
* @param {string} storeName
* @param {!Object} value
* @return {!Promise}
*/
shaka.offline.IStorageEngine.prototype.insert;
/**
* Removes the item with the given key.
*
* @param {string} storeName
* @param {number} key
* @return {!Promise}
*/
shaka.offline.IStorageEngine.prototype.remove;
/**
* Removes all items for which the given predicate returns true.
*
* @param {string} storeName
* @param {function(T):boolean} callback
* @return {!Promise.<number>}
* @template T
*/
shaka.offline.IStorageEngine.prototype.removeWhere;
/**
* Reserves the next ID and returns it.
*
* @param {string} storeName
* @return {number}
*/
shaka.offline.IStorageEngine.prototype.reserveId;