diff options
-rw-r--r-- | indra/llmessage/llassetstorage.cpp | 26 | ||||
-rw-r--r-- | indra/llmessage/llassetstorage.h | 4 | ||||
-rw-r--r-- | indra/newview/llstartup.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llviewerassetstorage.cpp | 49 | ||||
-rw-r--r-- | indra/newview/llviewerassetstorage.h | 6 |
5 files changed, 45 insertions, 42 deletions
diff --git a/indra/llmessage/llassetstorage.cpp b/indra/llmessage/llassetstorage.cpp index 78c7462286..7bf886ef26 100644 --- a/indra/llmessage/llassetstorage.cpp +++ b/indra/llmessage/llassetstorage.cpp @@ -546,13 +546,12 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, _queueDataRequest(uuid, type, callback, user_data, duplicate, is_priority); } - } // static -void LLAssetStorage::removeAndCallbackPendingDownloads(S32 result, const LLUUID& file_id, LLAssetType::EType file_type, +void LLAssetStorage::removeAndCallbackPendingDownloads(const LLUUID& file_id, LLAssetType::EType file_type, const LLUUID& callback_id, LLAssetType::EType callback_type, - LLExtStat ext_status) + S32 result_code, LLExtStat ext_status) { // find and callback ALL pending requests for this UUID // SJB: We process the callbacks in reverse order, I do not know if this is important, @@ -576,11 +575,11 @@ void LLAssetStorage::removeAndCallbackPendingDownloads(S32 result, const LLUUID& LLAssetRequest* tmp = *curiter; if (tmp->mDownCallback) { - if (result != LL_ERR_NOERR) + if (result_code!= LL_ERR_NOERR) { add(sFailedDownloadCount, 1); } - tmp->mDownCallback(gAssetStorage->mVFS, callback_id, callback_type, tmp->mUserData, result, ext_status); + tmp->mDownCallback(gAssetStorage->mVFS, callback_id, callback_type, tmp->mUserData, result_code, ext_status); } delete tmp; } @@ -644,7 +643,7 @@ void LLAssetStorage::downloadCompleteCallback( } } - removeAndCallbackPendingDownloads(result, file_id, file_type, callback_id, callback_type, ext_status); + removeAndCallbackPendingDownloads(file_id, file_type, callback_id, callback_type, ext_status, result); } void LLAssetStorage::getEstateAsset( @@ -806,19 +805,6 @@ void LLAssetStorage::getInvItemAsset( { LL_DEBUGS() << "LLAssetStorage::getInvItemAsset() - " << asset_id << "," << LLAssetType::lookup(atype) << LL_ENDL; - // - // Probably will get rid of this early out? - // - //if (asset_id.isNull()) - //{ - // // Special case early out for NULL uuid - // if (callback) - // { - // callback(mVFS, asset_id, atype, user_data, LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE); - // } - // return; - //} - bool exists = false; U32 size = 0; @@ -879,6 +865,8 @@ void LLAssetStorage::getInvItemAsset( spi.setInvItem(owner_id, task_id, item_id); spi.setAsset(asset_id, atype); + LL_DEBUGS("ViewerAsset") << "requesting inv item id " << item_id << " asset_id " << asset_id << " type " << LLAssetType::lookup(atype) << LL_ENDL; + // Set our destination file, and the completion callback. LLTransferTargetParamsVFile tpvf; tpvf.setAsset(asset_id, atype); diff --git a/indra/llmessage/llassetstorage.h b/indra/llmessage/llassetstorage.h index e1c6028fa0..2ec8ac31b4 100644 --- a/indra/llmessage/llassetstorage.h +++ b/indra/llmessage/llassetstorage.h @@ -319,9 +319,9 @@ public: const LLUUID& asset_id); - static void removeAndCallbackPendingDownloads(S32 result, const LLUUID& file_id, LLAssetType::EType file_type, + static void removeAndCallbackPendingDownloads(const LLUUID& file_id, LLAssetType::EType file_type, const LLUUID& callback_id, LLAssetType::EType callback_type, - LLExtStat ext_status); + S32 result_code, LLExtStat ext_status); // download process callbacks static void downloadCompleteCallback( diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 38fdaea9d8..0b41e35455 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -313,7 +313,7 @@ bool idle_startup() { // FIXME asset-http - this configuration stuff is temporary // construction; once it is always on for certain types - // and we can remove the setting. + // we can remove the setting. static bool va_types_initialized = false; if (!va_types_initialized) { diff --git a/indra/newview/llviewerassetstorage.cpp b/indra/newview/llviewerassetstorage.cpp index 628eb9ec89..3bb2b531dc 100644 --- a/indra/newview/llviewerassetstorage.cpp +++ b/indra/newview/llviewerassetstorage.cpp @@ -35,8 +35,6 @@ #include "llagent.h" #include "llviewerregion.h" -// FIXME asset-http: We are the only customer for gTransferManager - the -// whole class can be yanked once everything is http-ified. #include "lltransfersourceasset.h" #include "lltransfertargetvfile.h" #include "llviewerassetstats.h" @@ -427,7 +425,7 @@ void LLViewerAssetStorage::queueRequestHttp( if (cap_url.empty()) { LL_WARNS() << "No ViewerAsset cap found, fetch fails" << LL_ENDL; - // TODO: handle waiting for caps? Other failure mechanism? + // TODO asset-http: handle waiting for caps? Other failure mechanism? return; } else @@ -446,13 +444,13 @@ void LLViewerAssetStorage::queueRequestHttp( } mPendingDownloads.push_back(req); - // TODO AssetStatsFF stuff from UDP too? - // This is the same as the current UDP logic - don't re-request a duplicate. if (!duplicate) { + LLViewerAssetStatsFF::record_enqueue(atype, false, false); + LLCoros::instance().launch("LLViewerAssetStorage::assetRequestCoro", - boost::bind(&LLViewerAssetStorage::assetRequestCoro, this, uuid, atype, callback, user_data, duplicate, is_priority)); + boost::bind(&LLViewerAssetStorage::assetRequestCoro, this, uuid, atype, callback, user_data)); } } } @@ -461,28 +459,24 @@ void LLViewerAssetStorage::assetRequestCoro( const LLUUID& uuid, LLAssetType::EType atype, LLGetAssetCallback callback, - void *user_data, - BOOL duplicate, - BOOL is_priority) + void *user_data) { std::string url = getAssetURL(uuid,atype); LL_DEBUGS("ViewerAsset") << "request url: " << url << LL_ENDL; - // TODO: what about duplicates? - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("assetRequestCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); - LLSD result = httpAdapter->getAndSuspend(httpRequest, url, httpOpts); + LLSD result = httpAdapter->getRawAndSuspend(httpRequest, url, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { - // TODO: handle failures + // TODO asset-http: handle failures LL_DEBUGS("ViewerAsset") << "request failed, status " << status.toTerseString() << ", now what?" << LL_ENDL; } else @@ -491,13 +485,36 @@ void LLViewerAssetStorage::assetRequestCoro( LL_DEBUGS("ViewerAsset") << "result: " << ll_pretty_print_sd(httpResults) << LL_ENDL; - // TODO: Use asset data to create the asset + const LLSD::Binary &raw = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_RAW].asBinary(); + + S32 size = raw.size(); + if (size > 0) + { + // This create-then-rename flow is modeled on LLTransferTargetVFile, which is what's used in the UDP case. + LLUUID temp_id; + temp_id.generate(); + LLVFile vf(gAssetStorage->mVFS, temp_id, atype, LLVFile::WRITE); + vf.setMaxSize(size); + if (!vf.write(raw.data(),size)) + { + // TODO asset-http: handle error + LL_ERRS() << "Failure in vf.write()" << LL_ENDL; + } + if (!vf.rename(uuid, atype)) + { + LL_ERRS() << "rename failed" << LL_ENDL; + } + } + else + { + // TODO asset-http: handle invalid size case + } // Clean up pending downloads and trigger callbacks - // TODO: what are result_code and ext_status? + // TODO asset-http: what are the result_code and ext_status? S32 result_code = LL_ERR_NOERR; LLExtStat ext_status = LL_EXSTAT_NONE; - removeAndCallbackPendingDownloads(result_code, uuid, atype, uuid, atype, ext_status); + removeAndCallbackPendingDownloads(uuid, atype, uuid, atype, result_code, ext_status); } } diff --git a/indra/newview/llviewerassetstorage.h b/indra/newview/llviewerassetstorage.h index 474330c7c9..d28a8a276f 100644 --- a/indra/newview/llviewerassetstorage.h +++ b/indra/newview/llviewerassetstorage.h @@ -86,11 +86,9 @@ protected: BOOL is_priority); void assetRequestCoro(const LLUUID& uuid, - LLAssetType::EType type, + LLAssetType::EType atype, void (*callback) (LLVFS *vfs, const LLUUID&, LLAssetType::EType, void *, S32, LLExtStat), - void *user_data, - BOOL duplicate, - BOOL is_priority); + void *user_data); std::string getAssetURL(const LLUUID& uuid, LLAssetType::EType atype); |