Files
shaka-player/lib/polyfill/indexed_db.js
T
Joey Parrish 64896d70b0 Use shorter license header
This reflects changes in Google's policy on JavaScript license
headers, which should be smaller to avoid increasing the size of the
binary unnecessarily.

This also updates the company name from "Google, Inc" to "Google LLC".

Change-Id: I3f8b9ed3700b6351f43173d50c94d35c333e82b4
2019-11-22 18:18:36 +00:00

51 lines
1.2 KiB
JavaScript

/** @license
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
goog.provide('shaka.polyfill.IndexedDB');
goog.require('goog.asserts');
goog.require('shaka.log');
goog.require('shaka.polyfill');
/**
* @summary A polyfill to patch IndexedDB bugs.
*/
shaka.polyfill.IndexedDB = class {
/**
* Install the polyfill if needed.
*/
static install() {
shaka.log.debug('IndexedDB.install');
let disableIDB = false;
if (shaka.util.Platform.isChromecast()) {
shaka.log.debug('Removing IndexedDB from ChromeCast');
disableIDB = true;
} else {
try {
// This is necessary to avoid Closure compiler over optimize this
// block and remove it if it looks like a noop
if (window.indexedDB) {
disableIDB = false;
}
} catch (e) {
shaka.log.debug(
'Removing IndexedDB due to an exception when accessing it');
disableIDB = true;
}
}
if (disableIDB) {
delete window.indexedDB;
goog.asserts.assert(
!window.indexedDB, 'Failed to override window.indexedDB');
}
}
};
shaka.polyfill.register(shaka.polyfill.IndexedDB.install);