History

Assets API cache methods

David Rowe committed 7 years ago

Commit 8820d1d1 parent 2ad1d7a4 files · +212 −26Browse files

Showing the changes to libraries/script-engine/src/AssetScriptingInterface.cpp (1 of 4 files). Show all

Unified · Split

libraries/script-engine/src/AssetScriptingInterface.cpp+17−0
@@ -362,6 +362,15 @@ void AssetScriptingInterface::queryCacheMeta(QScriptValue options, QScriptValue · 361 unmodified lines
362 jsPromiseReady(Parent::queryCacheMeta(url), scope, callback);362 jsPromiseReady(Parent::queryCacheMeta(url), scope, callback);
363}363}
364 364
365/**jsdoc
366 * Source and retrieval options for {@link Assets.loadFromCache}.
367 * @typedef {object} Assets.LoadFromCacheOptions
368 * @property {string} url - The URL of the asset to load from cache. Must start with <code>"atp:"</code> or
369 * <code>"cache:"</code>.
370 * @property {Assets.ResponseType} [responseType=text] - The desired result type.
371 * @property {boolean} [decompress=false] - <code>true</code> to gunzip decompress the cached data. Synonym:
372 * <code>compressed</code>.
373 */
365void AssetScriptingInterface::loadFromCache(QScriptValue options, QScriptValue scope, QScriptValue callback) {374void AssetScriptingInterface::loadFromCache(QScriptValue options, QScriptValue scope, QScriptValue callback) {
366 QString url, responseType;375 QString url, responseType;
367 bool decompress = false;376 bool decompress = false;
@@ -396,6 +405,14 @@ bool AssetScriptingInterface::canWriteCacheValue(const QUrl& url) { · 28 unmodified lines
396 return true;405 return true;
397}406}
398 407
408/**jsdoc
409 * The data to save to the cache and cache options for {@link Assets.saveToCache}.
410 * @typedef {object} Assets.SaveToCacheOptions
411 * @property {string|ArrayBuffer} data - The data to save to the cache.
412 * @property {Assets.SaveToCacheHeaders} [headers] - The last-modified and expiry times for the cache item.
413 * @property {string} [url] - The URL to associate with the cache item. Must start with <code>"atp:"</code> or
414 * <code>"cache:"</code>. If not specified, the URL is <code>"atp:"</code> followed by the SHA256 hash of the content.
415 */
399void AssetScriptingInterface::saveToCache(QScriptValue options, QScriptValue scope, QScriptValue callback) {416void AssetScriptingInterface::saveToCache(QScriptValue options, QScriptValue scope, QScriptValue callback) {
400 JS_VERIFY(options.isObject(), QString("expected options object as first parameter not: %1").arg(options.toVariant().typeName()));417 JS_VERIFY(options.isObject(), QString("expected options object as first parameter not: %1").arg(options.toVariant().typeName()));
401 418