mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-18 00:56:38 +00:00
added cache warming on startup
This commit is contained in:
parent
2df5527cc0
commit
bfea4dbf5f
@ -74,9 +74,9 @@ function restoreUiAfterNaClLoad() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function beginBackgroundPollingOfHost(host) {
|
function beginBackgroundPollingOfHost(host) {
|
||||||
|
host.warmBoxArtCache();
|
||||||
if (host.online) {
|
if (host.online) {
|
||||||
$("#hostgrid-" + host.serverUid).removeClass('host-cell-inactive');
|
$("#hostgrid-" + host.serverUid).removeClass('host-cell-inactive');
|
||||||
|
|
||||||
// The host was already online. Just start polling in the background now.
|
// The host was already online. Just start polling in the background now.
|
||||||
activePolls[host.serverUid] = window.setInterval(function() {
|
activePolls[host.serverUid] = window.setInterval(function() {
|
||||||
// every 5 seconds, poll at the address we know it was live at
|
// every 5 seconds, poll at the address we know it was live at
|
||||||
@ -90,7 +90,6 @@ function beginBackgroundPollingOfHost(host) {
|
|||||||
}, 5000);
|
}, 5000);
|
||||||
} else {
|
} else {
|
||||||
$("#hostgrid-" + host.serverUid).addClass('host-cell-inactive');
|
$("#hostgrid-" + host.serverUid).addClass('host-cell-inactive');
|
||||||
|
|
||||||
// The host was offline, so poll immediately.
|
// The host was offline, so poll immediately.
|
||||||
host.pollServer(function () {
|
host.pollServer(function () {
|
||||||
if (host.online) {
|
if (host.online) {
|
||||||
|
@ -294,6 +294,29 @@ NvHTTP.prototype = {
|
|||||||
return this.getAppListWithCacheFlush();
|
return this.getAppListWithCacheFlush();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
warmBoxArtCache: function () {
|
||||||
|
if (Object.keys(this._memCachedBoxArtArray).length != 0) {
|
||||||
|
console.log('box art cache already warmed.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (chrome.storage) {
|
||||||
|
chrome.storage.local.get('boxArtCache', function(JSONCachedBoxArtArray) {
|
||||||
|
|
||||||
|
var storedBoxArtArray; // load cached data if it exists
|
||||||
|
if (JSONCachedBoxArtArray.boxArtCache != undefined) {
|
||||||
|
storedBoxArtArray = JSONCachedBoxArtArray.boxArtCache;
|
||||||
|
for (var key in storedBoxArtArray) {
|
||||||
|
this._memCachedBoxArtArray[key] = _base64ToArrayBuffer(storedBoxArtArray[key]);
|
||||||
|
}
|
||||||
|
console.log('box art cache warmed.');
|
||||||
|
} else {
|
||||||
|
console.log('WARN: no box art found in storage. Cannot warm cache!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// returns the box art of the given appID.
|
// returns the box art of the given appID.
|
||||||
// three layers of response time are possible: memory cached (in javascript), storage cached (in chrome.storage.local), and streamed (host sends binary over the network)
|
// three layers of response time are possible: memory cached (in javascript), storage cached (in chrome.storage.local), and streamed (host sends binary over the network)
|
||||||
getBoxArt: function (appId) {
|
getBoxArt: function (appId) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user