changes per CR feedback; additional jsdoc

This commit is contained in:
humbletim 2018-01-24 13:38:10 -05:00
parent 76cbc4ee55
commit c2ee13931e
3 changed files with 18 additions and 7 deletions

View file

@ -92,7 +92,7 @@ MiniPromise::Promise AssetClient::cacheInfoRequestAsync(MiniPromise::Promise def
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "cacheInfoRequestAsync", Q_ARG(MiniPromise::Promise, deferred));
} else {
auto* cache = qobject_cast<QNetworkDiskCache*>(NetworkAccessManager::getInstance().cache());
auto cache = qobject_cast<QNetworkDiskCache*>(NetworkAccessManager::getInstance().cache());
if (cache) {
deferred->resolve({
{ "cacheDirectory", cache->cacheDirectory() },

View file

@ -21,9 +21,6 @@
#include "NetworkAccessManager.h"
#include <QtNetwork/QNetworkDiskCache>
/**jsdoc
* @namespace Assets
*/
class BaseAssetScriptingInterface : public QObject {
Q_OBJECT
public:

View file

@ -215,6 +215,21 @@ void AssetScriptingInterface::deleteAsset(QScriptValue options, QScriptValue sco
jsVerify(false, "TODO: deleteAsset API");
}
/**jsdoc
* @typedef {string} Assets.GetOptions.ResponseType
* <p>Available <code>responseType</code> values for use with @{link Assets.getAsset} and @{link Assets.loadFromCache} configuration option. </p>
* <table>
* <thead>
* <tr><th>responseType</th><th>typeof response value</th></tr>
* </thead>
* <tbody>
* <tr><td><code>"text"</code></td><td>contents returned as utf-8 decoded <code>String</code> value</td></tr>
* <tr><td><code>"arraybuffer"</code></td><td>contents as a binary <code>ArrayBuffer</code> object</td></tr>
* <tr><td><code>"json"</code></td><td>contents as a parsed <code>JSON</code> object</td></tr>
* </tbody>
* </table>
*/
void AssetScriptingInterface::getAsset(QScriptValue options, QScriptValue scope, QScriptValue callback) {
JS_VERIFY(options.isObject() || options.isString(), "expected request options Object or URL as first parameter");
@ -224,7 +239,7 @@ void AssetScriptingInterface::getAsset(QScriptValue options, QScriptValue scope,
if (options.isString()) {
url = options.toString();
}
if (responseType.isEmpty() || responseType == "string") {
if (responseType.isEmpty()) {
responseType = "text";
}
auto asset = AssetUtils::getATPUrl(url).path();
@ -389,8 +404,7 @@ bool AssetScriptingInterface::canWriteCacheValue(const QUrl& url) {
// allow cache writes only from Client, EntityServer and Agent scripts
bool isAllowedContext = (
scriptEngine->isClientScript() ||
scriptEngine->isAgentScript() ||
scriptEngine->isEntityServerScript()
scriptEngine->isAgentScript()
);
if (!isAllowedContext) {
qCDebug(scriptengine) << __FUNCTION__ << "invalid context" << scriptEngine->getContext() << url;