History

remove debug prints; CR feedback

humbletim committed 8 years ago

Commit 8d2e0411 parent 8c7a8f02 files · +70 −85Browse files

Showing the changes to libraries/networking/src/BaseAssetScriptingInterface.cpp (1 of 2 files). Show all

Unified · Split

libraries/networking/src/BaseAssetScriptingInterface.cpp+1−15
@@ -36,8 +36,6 @@ BaseAssetScriptingInterface::BaseAssetScriptingInterface(QObject* parent) : QObj · 35 unmodified lines
36 36
37 37
38bool BaseAssetScriptingInterface::initializeCache() {38bool BaseAssetScriptingInterface::initializeCache() {
39 qDebug() << "BaseAssetScriptingInterface::getCacheStatus -- current values" << _cache.cacheDirectory() << _cache.cacheSize() << _cache.maximumCacheSize();
40
41 // NOTE: *instances* of QNetworkDiskCache are not thread-safe -- however, different threads can effectively39 // NOTE: *instances* of QNetworkDiskCache are not thread-safe -- however, different threads can effectively
42 // use the same underlying cache if configured with identical settings. Once AssetClient's disk cache settings40 // use the same underlying cache if configured with identical settings. Once AssetClient's disk cache settings
43 // become available we configure our instance to match.41 // become available we configure our instance to match.
@@ -50,29 +48,23 @@ bool BaseAssetScriptingInterface::initializeCache() { · 6 unmodified lines
50 }48 }
51 49
52 // attempt to initialize the cache50 // attempt to initialize the cache
53 qDebug() << "BaseAssetScriptingInterface::getCacheStatus -- invoking AssetClient::init" << assetClient().data();
54 QMetaObject::invokeMethod(assetClient().data(), "init");51 QMetaObject::invokeMethod(assetClient().data(), "init");
55 52
56 qDebug() << "BaseAssetScriptingInterface::getCacheStatus querying cache status" << QThread::currentThread();
57 Promise deferred = makePromise("BaseAssetScriptingInterface--queryCacheStatus");53 Promise deferred = makePromise("BaseAssetScriptingInterface--queryCacheStatus");
58 deferred->then([&](QVariantMap result) {54 deferred->then([&](QVariantMap result) {
59 qDebug() << "//queryCacheStatus" << QThread::currentThread();
60 auto cacheDirectory = result.value("cacheDirectory").toString();55 auto cacheDirectory = result.value("cacheDirectory").toString();
61 auto cacheSize = result.value("cacheSize").toLongLong();
62 auto maximumCacheSize = result.value("maximumCacheSize").toLongLong();56 auto maximumCacheSize = result.value("maximumCacheSize").toLongLong();
63 qDebug() << "///queryCacheStatus" << cacheDirectory << cacheSize << maximumCacheSize;
64 _cache.setCacheDirectory(cacheDirectory);57 _cache.setCacheDirectory(cacheDirectory);
65 _cache.setMaximumCacheSize(maximumCacheSize);58 _cache.setMaximumCacheSize(maximumCacheSize);
66 });59 });
67 deferred->fail([&](QString error) {60 deferred->fail([&](QString error) {
68 qDebug() << "//queryCacheStatus ERROR" << QThread::currentThread() << error;61 qDebug() << "BaseAssetScriptingInterface::queryCacheStatus ERROR" << QThread::currentThread() << error;
69 });62 });
70 assets->cacheInfoRequest(deferred);63 assets->cacheInfoRequest(deferred);
71 return false; // cache is not ready yet64 return false; // cache is not ready yet
72}65}
73 66
74QVariantMap BaseAssetScriptingInterface::getCacheStatus() {67QVariantMap BaseAssetScriptingInterface::getCacheStatus() {
75 //assetClient()->cacheInfoRequest(this, "onCacheInfoResponse");
76 return {68 return {
77 { "cacheDirectory", _cache.cacheDirectory() },69 { "cacheDirectory", _cache.cacheDirectory() },
78 { "cacheSize", _cache.cacheSize() },70 { "cacheSize", _cache.cacheSize() },
@@ -104,7 +96,6 @@ QVariantMap BaseAssetScriptingInterface::queryCacheMeta(const QUrl& url) { · 25 unmodified lines
104}96}
105 97
106QVariantMap BaseAssetScriptingInterface::loadFromCache(const QUrl& url) {98QVariantMap BaseAssetScriptingInterface::loadFromCache(const QUrl& url) {
107 qDebug() << "loadFromCache" << url;
108 QVariantMap result = {99 QVariantMap result = {
109 { "metadata", queryCacheMeta(url) },100 { "metadata", queryCacheMeta(url) },
110 { "data", QByteArray() },101 { "data", QByteArray() },
@@ -112,7 +103,6 @@ QVariantMap BaseAssetScriptingInterface::loadFromCache(const QUrl& url) { · 1 unmodified line
112 // caller is responsible for the deletion of the ioDevice, hence the unique_ptr103 // caller is responsible for the deletion of the ioDevice, hence the unique_ptr
113 if (auto ioDevice = std::unique_ptr<QIODevice>(_cache.data(url))) {104 if (auto ioDevice = std::unique_ptr<QIODevice>(_cache.data(url))) {
114 QByteArray data = ioDevice->readAll();105 QByteArray data = ioDevice->readAll();
115 qCDebug(asset_client) << url.toDisplayString() << "loaded from disk cache (" << data.size() << " bytes)";
116 result["data"] = data;106 result["data"] = data;
117 }107 }
118 return result;108 return result;
@@ -170,7 +160,6 @@ Promise BaseAssetScriptingInterface::loadAsset(QString asset, bool decompress, Q · 51 unmodified lines
170 Q_ASSERT(thread() == QThread::currentThread());160 Q_ASSERT(thread() == QThread::currentThread());
171 fetched->mixin(result);161 fetched->mixin(result);
172 if (decompress) {162 if (decompress) {
173 qDebug() << "loadAsset::decompressBytes...";
174 decompressBytes(result.value("data").toByteArray())163 decompressBytes(result.value("data").toByteArray())
175 ->mixin(result)164 ->mixin(result)
176 ->ready([=](QString error, QVariantMap result) {165 ->ready([=](QString error, QVariantMap result) {
@@ -182,7 +171,6 @@ Promise BaseAssetScriptingInterface::loadAsset(QString asset, bool decompress, Q · 5 unmodified lines
182 });171 });
183 172
184 fetched->ready([=](QString error, QVariantMap result) {173 fetched->ready([=](QString error, QVariantMap result) {
185 qDebug() << "loadAsset::fetched" << error;
186 if (responseType == "arraybuffer") {174 if (responseType == "arraybuffer") {
187 loaded->resolve(NoError, result);175 loaded->resolve(NoError, result);
188 } else {176 } else {
@@ -268,7 +256,6 @@ Promise BaseAssetScriptingInterface::downloadBytes(QString hash) { · 79 unmodified lines
268 Promise deferred = makePromise(__FUNCTION__);256 Promise deferred = makePromise(__FUNCTION__);
269 257
270 QObject::connect(assetRequest, &AssetRequest::finished, assetRequest, [this, deferred](AssetRequest* request) {258 QObject::connect(assetRequest, &AssetRequest::finished, assetRequest, [this, deferred](AssetRequest* request) {
271 qDebug() << "...BaseAssetScriptingInterface::downloadBytes" << request->getErrorString();
272 // note: we are now on the "Resource Manager" thread259 // note: we are now on the "Resource Manager" thread
273 Q_ASSERT(QThread::currentThread() == request->thread());260 Q_ASSERT(QThread::currentThread() == request->thread());
274 Q_ASSERT(request->getState() == AssetRequest::Finished);261 Q_ASSERT(request->getState() == AssetRequest::Finished);
@@ -287,7 +274,6 @@ Promise BaseAssetScriptingInterface::downloadBytes(QString hash) { · 12 unmodified lines
287 error = request->getError();274 error = request->getError();
288 result = { { "error", request->getError() } };275 result = { { "error", request->getError() } };
289 }276 }
290 qDebug() << "//BaseAssetScriptingInterface::downloadBytes" << error << result.keys();
291 // forward thread-safe copies back to our thread277 // forward thread-safe copies back to our thread
292 deferred->handle(error, result);278 deferred->handle(error, result);
293 request->deleteLater();279 request->deleteLater();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t