diff options
author | Rider Linden <rider@lindenlab.com> | 2015-07-20 15:57:10 -0700 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2015-07-20 15:57:10 -0700 |
commit | 37d17eaebd05325f0ddb3334cbabf7a8710d5843 (patch) | |
tree | b706c56898eeb6489f70d3bc04d72f7c8f4d40cb /indra | |
parent | 2fc4ddb92bfb7b05851372adcfda7e0ab4886718 (diff) |
Remove old "compile queue" and replace with the coroutine based upload queue.
Diffstat (limited to 'indra')
-rwxr-xr-x | indra/newview/CMakeLists.txt | 2 | ||||
-rwxr-xr-x | indra/newview/llassetuploadqueue.cpp | 219 | ||||
-rwxr-xr-x | indra/newview/llassetuploadqueue.h | 93 | ||||
-rwxr-xr-x | indra/newview/llassetuploadresponders.cpp | 3 | ||||
-rwxr-xr-x | indra/newview/llassetuploadresponders.h | 2 | ||||
-rwxr-xr-x | indra/newview/llcompilequeue.cpp | 163 | ||||
-rwxr-xr-x | indra/newview/llcompilequeue.h | 7 | ||||
-rw-r--r-- | indra/newview/llviewerassetupload.cpp | 7 | ||||
-rw-r--r-- | indra/newview/llviewerassetupload.h | 3 |
9 files changed, 107 insertions, 392 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 7a6267251e..e79fa8b084 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -123,7 +123,6 @@ set(viewer_SOURCE_FILES llappearancemgr.cpp llappviewer.cpp llappviewerlistener.cpp - llassetuploadqueue.cpp llassetuploadresponders.cpp llattachmentsmgr.cpp llaudiosourcevo.cpp @@ -735,7 +734,6 @@ set(viewer_HEADER_FILES llappearancemgr.h llappviewer.h llappviewerlistener.h - llassetuploadqueue.h llassetuploadresponders.h llattachmentsmgr.h llaudiosourcevo.h diff --git a/indra/newview/llassetuploadqueue.cpp b/indra/newview/llassetuploadqueue.cpp deleted file mode 100755 index 9e52807d02..0000000000 --- a/indra/newview/llassetuploadqueue.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/** - * @file llassetupload.cpp - * @brief Serializes asset upload request - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llassetuploadqueue.h" -#include "llviewerregion.h" -#include "llviewerobjectlist.h" - -#include "llassetuploadresponders.h" -#include "llsd.h" -#include <iostream> - -class LLAssetUploadChainResponder : public LLUpdateTaskInventoryResponder -{ - LOG_CLASS(LLAssetUploadChainResponder); -public: - - LLAssetUploadChainResponder(const LLSD& post_data, - const std::string& file_name, - const LLUUID& queue_id, - U8* data, - U32 data_size, - std::string script_name, - LLAssetUploadQueueSupplier *supplier) : - LLUpdateTaskInventoryResponder(post_data, file_name, queue_id, LLAssetType::AT_LSL_TEXT), - mSupplier(supplier), - mData(data), - mDataSize(data_size), - mScriptName(script_name) - { - } - - virtual ~LLAssetUploadChainResponder() - { - if(mSupplier) - { - LLAssetUploadQueue *queue = mSupplier->get(); - if (queue) - { - // Give ownership of supplier back to queue. - queue->mSupplier = mSupplier; - mSupplier = NULL; - } - } - delete mSupplier; - delete mData; - } - -protected: - virtual void httpFailure() - { - // Parent class will spam the failure. - //LL_WARNS() << dumpResponse() << LL_ENDL; - LLUpdateTaskInventoryResponder::httpFailure(); - LLAssetUploadQueue *queue = mSupplier->get(); - if (queue) - { - queue->request(&mSupplier); - } - } - - virtual void httpSuccess() - { - LLUpdateTaskInventoryResponder::httpSuccess(); - LLAssetUploadQueue *queue = mSupplier->get(); - if (queue) - { - // Responder is reused across 2 phase upload, - // so only start next upload after 2nd phase complete. - const std::string& state = getContent()["state"].asStringRef(); - if(state == "complete") - { - queue->request(&mSupplier); - } - } - } - -public: - virtual void uploadUpload(const LLSD& content) - { - std::string uploader = content["uploader"]; - - mSupplier->log(std::string("Compiling " + mScriptName).c_str()); - LL_INFOS() << "Compiling " << LL_ENDL; - - // postRaw takes ownership of mData and will delete it. - LLHTTPClient::postRaw(uploader, mData, mDataSize, this); - mData = NULL; - mDataSize = 0; - } - - virtual void uploadComplete(const LLSD& content) - { - // Bytecode save completed - if (content["compiled"]) - { - mSupplier->log("Compilation succeeded"); - LL_INFOS() << "Compiled!" << LL_ENDL; - } - else - { - LLSD compile_errors = content["errors"]; - for(LLSD::array_const_iterator line = compile_errors.beginArray(); - line < compile_errors.endArray(); line++) - { - std::string str = line->asString(); - str.erase(std::remove(str.begin(), str.end(), '\n'), str.end()); - mSupplier->log(str); - LL_INFOS() << content["errors"] << LL_ENDL; - } - } - LLUpdateTaskInventoryResponder::uploadComplete(content); - } - - LLAssetUploadQueueSupplier *mSupplier; - U8* mData; - U32 mDataSize; - std::string mScriptName; -}; - -LLAssetUploadQueue::LLAssetUploadQueue(LLAssetUploadQueueSupplier *supplier) : - mSupplier(supplier) -{ -} - -//virtual -LLAssetUploadQueue::~LLAssetUploadQueue() -{ - delete mSupplier; -} - -// Takes ownership of supplier. -void LLAssetUploadQueue::request(LLAssetUploadQueueSupplier** supplier) -{ - if (mQueue.empty()) - return; - - UploadData data = mQueue.front(); - mQueue.pop_front(); - - LLSD body; - body["task_id"] = data.mTaskId; - body["item_id"] = data.mItemId; - body["is_script_running"] = data.mIsRunning; - body["target"] = data.mIsTargetMono? "mono" : "lsl2"; - body["experience"] = data.mExperienceId; - - std::string url = ""; - LLViewerObject* object = gObjectList.findObject(data.mTaskId); - if (object) - { - url = object->getRegion()->getCapability("UpdateScriptTask"); - LLHTTPClient::post(url, body, - new LLAssetUploadChainResponder( - body, data.mFilename, data.mQueueId, - data.mData, data.mDataSize, data.mScriptName, *supplier)); - } - - *supplier = NULL; -} - -void LLAssetUploadQueue::queue(const std::string& filename, - const LLUUID& task_id, - const LLUUID& item_id, - BOOL is_running, - BOOL is_target_mono, - const LLUUID& queue_id, - U8* script_data, - U32 data_size, - std::string script_name, - const LLUUID& experience_id) -{ - UploadData data; - data.mTaskId = task_id; - data.mItemId = item_id; - data.mIsRunning = is_running; - data.mIsTargetMono = is_target_mono; - data.mQueueId = queue_id; - data.mFilename = filename; - data.mData = script_data; - data.mDataSize = data_size; - data.mScriptName = script_name; - data.mExperienceId = experience_id; - - mQueue.push_back(data); - - if(mSupplier) - { - request(&mSupplier); - } -} - -LLAssetUploadQueueSupplier::~LLAssetUploadQueueSupplier() -{ -} diff --git a/indra/newview/llassetuploadqueue.h b/indra/newview/llassetuploadqueue.h deleted file mode 100755 index 2ceee8f700..0000000000 --- a/indra/newview/llassetuploadqueue.h +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @file llassetuploadqueue.h - * @brief Serializes asset upload request - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLASSETUPLOADQUEUE_H -#define LL_LLASSETUPLOADQUEUE_H - -#include "lluuid.h" - -#include <string> -#include <deque> - -class LLAssetUploadQueueSupplier; - -class LLAssetUploadQueue -{ -public: - - // Takes ownership of supplier. - LLAssetUploadQueue(LLAssetUploadQueueSupplier* supplier); - virtual ~LLAssetUploadQueue(); - - void queue(const std::string& filename, - const LLUUID& task_id, - const LLUUID& item_id, - BOOL is_running, - BOOL is_target_mono, - const LLUUID& queue_id, - U8* data, - U32 data_size, - std::string script_name, - const LLUUID& experience_id); - - bool isEmpty() const {return mQueue.empty();} - -private: - - friend class LLAssetUploadChainResponder; - - struct UploadData - { - std::string mFilename; - LLUUID mTaskId; - LLUUID mItemId; - BOOL mIsRunning; - BOOL mIsTargetMono; - LLUUID mQueueId; - U8* mData; - U32 mDataSize; - std::string mScriptName; - LLUUID mExperienceId; - }; - - // Ownership of mSupplier passed to currently waiting responder - // and returned to queue when no requests in progress. - LLAssetUploadQueueSupplier* mSupplier; - std::deque<UploadData> mQueue; - - // Passes on ownership of mSupplier if request is made. - void request(LLAssetUploadQueueSupplier** supplier); -}; - -class LLAssetUploadQueueSupplier -{ -public: - virtual ~LLAssetUploadQueueSupplier(); - virtual LLAssetUploadQueue* get() const = 0; - virtual void log(std::string message) const = 0; -}; - -#endif // LL_LLASSETUPLOADQUEUE_H diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp index 14020af166..f62c57b2b3 100755 --- a/indra/newview/llassetuploadresponders.cpp +++ b/indra/newview/llassetuploadresponders.cpp @@ -585,6 +585,7 @@ void LLUpdateAgentInventoryResponder::uploadComplete(const LLSD& content) } #endif +#if 0 LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data, const LLUUID& vfile_id, LLAssetType::EType asset_type) @@ -675,7 +676,7 @@ void LLUpdateTaskInventoryResponder::uploadComplete(const LLSD& content) break; } } - +#endif #if 0 ///////////////////////////////////////////////////// diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h index 71995873fa..d3457ce450 100755 --- a/indra/newview/llassetuploadresponders.h +++ b/indra/newview/llassetuploadresponders.h @@ -133,6 +133,7 @@ public: }; #endif +#if 0 class LLUpdateTaskInventoryResponder : public LLAssetUploadResponder { public: @@ -152,5 +153,6 @@ public: private: LLUUID mQueueId; }; +#endif #endif // LL_LLASSETUPLOADRESPONDER_H diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp index d9fd4509a5..c4b0b96d4c 100755 --- a/indra/newview/llcompilequeue.cpp +++ b/indra/newview/llcompilequeue.cpp @@ -37,7 +37,6 @@ #include "llcompilequeue.h" #include "llagent.h" -#include "llassetuploadqueue.h" #include "llassetuploadresponders.h" #include "llchat.h" #include "llfloaterreg.h" @@ -62,8 +61,51 @@ #include "llexperienceassociationresponder.h" #include "llexperiencecache.h" -// *TODO: This should be separated into the script queue, and the floater views of that queue. -// There should only be one floater class that can view any queue type +#include "llviewerassetupload.h" + +// *NOTE$: A minor specialization of LLScriptAssetUpload, it does not require a buffer +// (and does not save a buffer to the vFS) and it finds the compile queue window and +// displays a compiling message. +class LLQueuedScriptAssetUpload : public LLScriptAssetUpload +{ +public: + LLQueuedScriptAssetUpload(LLUUID taskId, LLUUID itemId, LLUUID assetId, TargetType_t targetType, + bool isRunning, std::string scriptName, LLUUID queueId, LLUUID exerienceId, taskUploadFinish_f finish) : + LLScriptAssetUpload(taskId, itemId, targetType, isRunning, + exerienceId, std::string(), finish), + mScriptName(scriptName), + mQueueId(queueId) + { + setAssetId(assetId); + } + + virtual LLSD prepareUpload() + { + /* *NOTE$: The parent class (LLScriptAssetUpload will attempt to save + * the script buffer into to the VFS. Since the resource is already in + * the VFS we don't want to do that. Just put a compiling message in + * the window and move on + */ + LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance<LLFloaterCompileQueue>("compile_queue", LLSD(mQueueId)); + if (queue) + { + std::string message = std::string("Compiling \"") + getScriptName() + std::string("\"..."); + + queue->getChild<LLScrollListCtrl>("queue output")->addSimpleElement(message, ADD_BOTTOM); + } + + return LLSD().with("success", LLSD::Boolean(true)); + } + + + std::string getScriptName() const { return mScriptName; } + +private: + void setScriptName(const std::string &scriptName) { mScriptName = scriptName; } + + LLUUID mQueueId; + std::string mScriptName; +}; ///---------------------------------------------------------------------------- /// Local function declarations, constants, enums, and typedefs @@ -127,7 +169,7 @@ void LLFloaterScriptQueue::inventoryChanged(LLViewerObject* viewer_object, //which it internally stores. //If we call this further down in the function, calls to handleInventory - //and nextObject may update the interally stored viewer object causing + //and nextObject may update the internally stored viewer object causing //the removal of the incorrect listener from an incorrect object. //Fixes SL-6119:Recompile scripts fails to complete @@ -275,48 +317,13 @@ public: ///---------------------------------------------------------------------------- /// Class LLFloaterCompileQueue ///---------------------------------------------------------------------------- - -class LLCompileFloaterUploadQueueSupplier : public LLAssetUploadQueueSupplier -{ -public: - - LLCompileFloaterUploadQueueSupplier(const LLUUID& queue_id) : - mQueueId(queue_id) - { - } - - virtual LLAssetUploadQueue* get() const - { - LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance<LLFloaterCompileQueue>("compile_queue", LLSD(mQueueId)); - if(NULL == queue) - { - return NULL; - } - return queue->getUploadQueue(); - } - - virtual void log(std::string message) const - { - LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance<LLFloaterCompileQueue>("compile_queue", LLSD(mQueueId)); - if(NULL == queue) - { - return; - } - - queue->getChild<LLScrollListCtrl>("queue output")->addSimpleElement(message, ADD_BOTTOM); - } - -private: - LLUUID mQueueId; -}; - LLFloaterCompileQueue::LLFloaterCompileQueue(const LLSD& key) : LLFloaterScriptQueue(key) { setTitle(LLTrans::getString("CompileQueueTitle")); setStartString(LLTrans::getString("CompileQueueStart")); - mUploadQueue = new LLAssetUploadQueue(new LLCompileFloaterUploadQueueSupplier(key.asUUID())); +// mUploadQueue = new LLAssetUploadQueue(new LLCompileFloaterUploadQueueSupplier(key.asUUID())); } LLFloaterCompileQueue::~LLFloaterCompileQueue() @@ -423,6 +430,37 @@ void LLFloaterCompileQueue::requestAsset( LLScriptQueueData* datap, const LLSD& (void*)datap); } +/*static*/ +void LLFloaterCompileQueue::finishLSLUpload(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, std::string scriptName, LLUUID queueId) +{ + + LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance<LLFloaterCompileQueue>("compile_queue", LLSD(queueId)); + if (queue) + { + // Bytecode save completed + if (response["compiled"]) + { + std::string message = std::string("Compilation of \"") + scriptName + std::string("\" succeeded"); + + queue->getChild<LLScrollListCtrl>("queue output")->addSimpleElement(message, ADD_BOTTOM); + LL_INFOS() << message << LL_ENDL; + } + else + { + LLSD compile_errors = response["errors"]; + for (LLSD::array_const_iterator line = compile_errors.beginArray(); + line < compile_errors.endArray(); line++) + { + std::string str = line->asString(); + str.erase(std::remove(str.begin(), str.end(), '\n'), str.end()); + + queue->getChild<LLScrollListCtrl>("queue output")->addSimpleElement(str, ADD_BOTTOM); + } + LL_INFOS() << response["errors"] << LL_ENDL; + } + + } +} // This is the callback for when each script arrives // static @@ -441,36 +479,21 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id, std::string buffer; if(queue && (0 == status)) { - //LL_INFOS() << "ITEM NAME 3: " << data->mScriptName << LL_ENDL; - - // Dump this into a file on the local disk so we can compile it. - std::string filename; - LLVFile file(vfs, asset_id, type); - std::string uuid_str; - asset_id.toString(uuid_str); - filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str) + llformat(".%s",LLAssetType::lookup(type)); - - const bool is_running = true; - LLViewerObject* object = gObjectList.findObject(data->mTaskId); - if (object) - { - std::string url = object->getRegion()->getCapability("UpdateScriptTask"); - if(!url.empty()) - { - // Read script source in to buffer. - U32 script_size = file.getSize(); - U8* script_data = new U8[script_size]; - file.read(script_data, script_size); - - queue->mUploadQueue->queue(filename, data->mTaskId, - data->mItem->getUUID(), is_running, queue->mMono, queue->getKey().asUUID(), - script_data, script_size, data->mItem->getName(), data->mExperienceId); - } - else - { - buffer = LLTrans::getString("CompileQueueServiceUnavailable") + (": ") + data->mItem->getName(); - } - } + LLViewerObject* object = gObjectList.findObject(data->mTaskId); + if (object) + { + std::string url = object->getRegion()->getCapability("UpdateScriptTask"); + std::string scriptName = data->mItem->getName(); + + LLBufferedAssetUploadInfo::taskUploadFinish_f proc = boost::bind(&LLFloaterCompileQueue::finishLSLUpload, _1, _2, _3, _4, + scriptName, data->mQueueID); + + LLResourceUploadInfo::ptr_t uploadInfo(new LLQueuedScriptAssetUpload(data->mTaskId, data->mItem->getUUID(), asset_id, + (queue->mMono) ? LLScriptAssetUpload::MONO : LLScriptAssetUpload::LSL2, + true, scriptName, data->mQueueID, data->mExperienceId, proc)); + + LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo); + } } else { diff --git a/indra/newview/llcompilequeue.h b/indra/newview/llcompilequeue.h index 54842bb302..c7be4fbe3b 100755 --- a/indra/newview/llcompilequeue.h +++ b/indra/newview/llcompilequeue.h @@ -118,8 +118,6 @@ struct LLCompileQueueData mQueueID(q_id), mItemId(item_id) {} }; -class LLAssetUploadQueue; - class LLFloaterCompileQueue : public LLFloaterScriptQueue { friend class LLFloaterReg; @@ -131,8 +129,6 @@ public: // remove any object in mScriptScripts with the matching uuid. void removeItemByItemID(const LLUUID& item_id); - LLAssetUploadQueue* getUploadQueue() { return mUploadQueue; } - void experienceIdsReceived( const LLSD& content ); BOOL hasExperience(const LLUUID& id)const; @@ -147,6 +143,8 @@ protected: static void requestAsset(struct LLScriptQueueData* datap, const LLSD& experience); + static void finishLSLUpload(LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response, std::string scriptName, LLUUID queueId); + // This is the callback for when each script arrives static void scriptArrived(LLVFS *vfs, const LLUUID& asset_id, LLAssetType::EType type, @@ -157,7 +155,6 @@ protected: LLViewerInventoryItem::item_array_t mCurrentScripts; private: - LLAssetUploadQueue* mUploadQueue; uuid_list_t mExperienceIds; }; diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index b29a9a6114..9982d68f52 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -486,7 +486,6 @@ LLSD LLBufferedAssetUploadInfo::prepareUpload() mStoredToVFS = true; - return LLSD().with("success", LLSD::Boolean(true)); } @@ -555,7 +554,10 @@ LLUUID LLBufferedAssetUploadInfo::finishUpload(LLSD &result) //========================================================================= LLScriptAssetUpload::LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish): - LLBufferedAssetUploadInfo(itemId, LLAssetType::AT_LSL_TEXT, buffer, finish) + LLBufferedAssetUploadInfo(itemId, LLAssetType::AT_LSL_TEXT, buffer, finish), + mExerienceId(), + mTargetType(LSL2), + mIsRunning(false) { } @@ -568,6 +570,7 @@ LLScriptAssetUpload::LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, TargetTyp { } + LLSD LLScriptAssetUpload::generatePostBody() { LLSD body; diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index e7145068c5..23013ac664 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -105,6 +105,8 @@ protected: void incrementUploadStats() const; virtual void assignDefaults(); + void setAssetId(LLUUID assetId) { mAssetId = assetId; } + private: LLTransactionID mTransactionId; LLAssetType::EType mAssetType; @@ -205,6 +207,7 @@ public: bool getIsRunning() const { return mIsRunning; } private: + bool mSaveToVFS; LLUUID mExerienceId; TargetType_t mTargetType; bool mIsRunning; |