summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2015-09-02 11:50:26 -0700
committerRider Linden <rider@lindenlab.com>2015-09-02 11:50:26 -0700
commit6c9610b4e44020bf266a5da7375fb9f2b24f4f8a (patch)
treebaf73d9f0c948149dfee20d850904bed0f01f27c
parentc5dc9b1a572f00e69b9cd3b5853f0a3d104af20f (diff)
Move associated experience fetching into the ExperienceCache as a coro remove the responder.
-rw-r--r--indra/llmessage/llexperiencecache.cpp63
-rw-r--r--indra/llmessage/llexperiencecache.h16
-rwxr-xr-xindra/newview/CMakeLists.txt2
-rwxr-xr-xindra/newview/llcompilequeue.cpp5
-rw-r--r--indra/newview/llexperienceassociationresponder.cpp97
-rw-r--r--indra/newview/llexperienceassociationresponder.h58
-rwxr-xr-xindra/newview/llpreviewscript.cpp6
-rwxr-xr-xindra/newview/llsidepaneliteminfo.cpp5
8 files changed, 78 insertions, 174 deletions
diff --git a/indra/llmessage/llexperiencecache.cpp b/indra/llmessage/llexperiencecache.cpp
index 36a4fc8823..b65a3c59d5 100644
--- a/indra/llmessage/llexperiencecache.cpp
+++ b/indra/llmessage/llexperiencecache.cpp
@@ -356,7 +356,7 @@ void LLExperienceCache::requestExperiences()
if (mRequestQueue.empty() || (ostr.tellp() > EXP_URL_SEND_THRESHOLD))
{ // request is placed in the coprocedure pool for the ExpCache cache. Throttling is done by the pool itself.
- LLCoprocedureManager::getInstance()->enqueueCoprocedure("ExpCache", "Request",
+ LLCoprocedureManager::getInstance()->enqueueCoprocedure("ExpCache", "RequestExperiences",
boost::bind(&LLExperienceCache::requestExperiencesCoro, this, _1, ostr.str(), requests) );
ostr.str(std::string());
@@ -506,7 +506,8 @@ const LLSD& LLExperienceCache::get(const LLUUID& key)
return empty;
}
-void LLExperienceCache::get(const LLUUID& key, LLExperienceCache::Callback_t slot)
+
+void LLExperienceCache::get(const LLUUID& key, LLExperienceCache::ExperienceGetFn_t slot)
{
if(key.isNull())
return;
@@ -533,6 +534,64 @@ void LLExperienceCache::get(const LLUUID& key, LLExperienceCache::Callback_t slo
}
//=========================================================================
+void LLExperienceCache::fetchAssociatedExperience(const LLUUID& objectId, const LLUUID& itemId, ExperienceGetFn_t fn)
+{
+ if (mCapability.empty())
+ {
+ LL_WARNS("ExperienceCache") << "Capability query method not set." << LL_ENDL;
+ return;
+ }
+
+ LLCoprocedureManager::getInstance()->enqueueCoprocedure("ExpCache", "Fetch Associated",
+ boost::bind(&LLExperienceCache::fetchAssociatedExperienceCoro, this, _1, objectId, itemId, fn));
+}
+
+void LLExperienceCache::fetchAssociatedExperienceCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, LLUUID objectId, LLUUID itemId, ExperienceGetFn_t fn)
+{
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest());
+
+ std::string url = mCapability("GetMetadata");
+ if (url.empty())
+ {
+ LL_WARNS("ExperienceCache") << "No Metadata capability." << LL_ENDL;
+ return;
+ }
+
+ LLSD fields;
+ fields.append("experience");
+ LLSD data;
+ data["object-id"] = objectId;
+ data["item-id"] = itemId;
+ data["fields"] = fields;
+
+ LLSD result = httpAdapter->postAndYield(httpRequest, url, data);
+
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ if ((!status) || (!result.has("experience")))
+ {
+ LLSD failure;
+ if (!status)
+ {
+ failure["error"] = (LLSD::Integer)status.getType();
+ failure["message"] = status.getMessage();
+ }
+ else
+ {
+ failure["error"] = -1;
+ failure["message"] = "no experience";
+ }
+ if (fn && !fn.empty())
+ fn(failure);
+ return;
+ }
+
+ LLUUID expId = result["experience"].asUUID();
+ get(expId, fn);
+}
+
+//=========================================================================
void LLExperienceCacheImpl::mapKeys(const LLSD& legacyKeys)
{
LLSD::array_const_iterator exp = legacyKeys.beginArray();
diff --git a/indra/llmessage/llexperiencecache.h b/indra/llmessage/llexperiencecache.h
index 937225a80a..d1222933df 100644
--- a/indra/llmessage/llexperiencecache.h
+++ b/indra/llmessage/llexperiencecache.h
@@ -47,22 +47,25 @@ class LLExperienceCache: public LLSingleton < LLExperienceCache >
public:
typedef boost::function<std::string(const std::string &)> CapabilityQuery_t;
- typedef boost::function<void(const LLSD &)> Callback_t;
+ typedef boost::function<void(const LLSD &)> ExperienceGetFn_t;
+ void setCapabilityQuery(CapabilityQuery_t queryfn);
void cleanup();
+ //-------------------------------------------
+ // Cache methods
void erase(const LLUUID& key);
bool fetch(const LLUUID& key, bool refresh = false);
void insert(const LLSD& experience_data);
const LLSD& get(const LLUUID& key);
-
- // If name information is in cache, callback will be called immediately.
- void get(const LLUUID& key, Callback_t slot);
+ void get(const LLUUID& key, ExperienceGetFn_t slot); // If name information is in cache, callback will be called immediately.
bool isRequestPending(const LLUUID& public_key);
- void setCapabilityQuery(CapabilityQuery_t queryfn);
+ //-------------------------------------------
+ void fetchAssociatedExperience(const LLUUID& objectId, const LLUUID& itemId, ExperienceGetFn_t fn);
+ //-------------------------------------------
static const std::string NAME; // "name"
static const std::string EXPERIENCE_ID; // "public_id"
static const std::string AGENT_ID; // "agent_id"
@@ -120,7 +123,6 @@ private:
RequestQueue_t mRequestQueue;
PendingQueue_t mPendingQueue;
- LLFrameTimer mRequestTimer;
LLFrameTimer mEraseExpiredTimer; // Periodically clean out expired entries from the cache
CapabilityQuery_t mCapability;
std::string mCacheFileName;
@@ -131,7 +133,7 @@ private:
void requestExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &, std::string, RequestQueue_t);
void requestExperiences();
- void setMaximumLookups(int maximumLookups);
+ void fetchAssociatedExperienceCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &, LLUUID objectId, LLUUID itemId, ExperienceGetFn_t fn);
void bootstrap(const LLSD& legacyKeys, int initialExpiration);
void exportFile(std::ostream& ostr) const;
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 090879e372..67af240f8d 100755
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -192,7 +192,6 @@ set(viewer_SOURCE_FILES
lleventnotifier.cpp
lleventpoll.cpp
llexpandabletextbox.cpp
- llexperienceassociationresponder.cpp
llexperiencelog.cpp
llexternaleditor.cpp
llface.cpp
@@ -801,7 +800,6 @@ set(viewer_HEADER_FILES
lleventnotifier.h
lleventpoll.h
llexpandabletextbox.h
- llexperienceassociationresponder.h
llexperiencelog.h
llexternaleditor.h
llface.h
diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp
index 9545771c8d..f763a59c94 100755
--- a/indra/newview/llcompilequeue.cpp
+++ b/indra/newview/llcompilequeue.cpp
@@ -57,7 +57,6 @@
#include "lltrans.h"
#include "llselectmgr.h"
-#include "llexperienceassociationresponder.h"
#include "llexperiencecache.h"
#include "llviewerassetupload.h"
@@ -358,8 +357,8 @@ void LLFloaterCompileQueue::handleInventory(LLViewerObject *viewer_object,
LLScriptQueueData* datap = new LLScriptQueueData(getKey().asUUID(),
viewer_object->getID(), itemp);
- ExperienceAssociationResponder::fetchAssociatedExperience(itemp->getParentUUID(), itemp->getUUID(),
- boost::bind(LLFloaterCompileQueue::requestAsset, datap, _1));
+ LLExperienceCache::getInstance()->fetchAssociatedExperience(itemp->getParentUUID(), itemp->getUUID(),
+ boost::bind(LLFloaterCompileQueue::requestAsset, datap, _1));
}
}
}
diff --git a/indra/newview/llexperienceassociationresponder.cpp b/indra/newview/llexperienceassociationresponder.cpp
deleted file mode 100644
index cd4a7516b1..0000000000
--- a/indra/newview/llexperienceassociationresponder.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * @file llexperienceassociationresponder.cpp
- * @brief llexperienceassociationresponder implementation. This class combines
- * a lookup for a script association and an experience details request. The first
- * is always async, but the second may be cached locally.
- *
- * $LicenseInfo:firstyear=2013&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2013, 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 "llexperienceassociationresponder.h"
-#include "llexperiencecache.h"
-#include "llviewerregion.h"
-#include "llagent.h"
-
-ExperienceAssociationResponder::ExperienceAssociationResponder(ExperienceAssociationResponder::callback_t callback):mCallback(callback)
-{
- ref();
-}
-
-void ExperienceAssociationResponder::fetchAssociatedExperience( const LLUUID& object_id, const LLUUID& item_id, callback_t callback )
-{
- LLSD request;
- request["object-id"]=object_id;
- request["item-id"]=item_id;
- fetchAssociatedExperience(request, callback);
-}
-
-void ExperienceAssociationResponder::fetchAssociatedExperience(LLSD& request, callback_t callback)
-{
- LLViewerRegion* region = gAgent.getRegion();
- if (region)
- {
- std::string lookup_url=region->getCapability("GetMetadata");
- if(!lookup_url.empty())
- {
- LLSD fields;
- fields.append("experience");
- request["fields"] = fields;
- LLHTTPClient::post(lookup_url, request, new ExperienceAssociationResponder(callback));
- }
- }
-}
-
-void ExperienceAssociationResponder::httpFailure()
-{
- LLSD msg;
- msg["error"]=(LLSD::Integer)getStatus();
- msg["message"]=getReason();
- LL_INFOS("ExperienceAssociation") << "Failed to look up associated experience: " << getStatus() << ": " << getReason() << LL_ENDL;
-
- sendResult(msg);
-
-}
-void ExperienceAssociationResponder::httpSuccess()
-{
- if(!getContent().has("experience"))
- {
-
- LLSD msg;
- msg["message"]="no experience";
- msg["error"]=-1;
- sendResult(msg);
- return;
- }
-
- LLExperienceCache::getInstance()->get(getContent()["experience"].asUUID(), boost::bind(&ExperienceAssociationResponder::sendResult, this, _1));
-
-}
-
-void ExperienceAssociationResponder::sendResult( const LLSD& experience )
-{
- mCallback(experience);
- unref();
-}
-
-
-
diff --git a/indra/newview/llexperienceassociationresponder.h b/indra/newview/llexperienceassociationresponder.h
deleted file mode 100644
index 2bdc3d251b..0000000000
--- a/indra/newview/llexperienceassociationresponder.h
+++ /dev/null
@@ -1,58 +0,0 @@
-#include "llhttpclient.h"
-#include "llsd.h"
-/**
- * @file llexperienceassociationresponder.h
- * @brief llexperienceassociationresponder and related class definitions
- *
- * $LicenseInfo:firstyear=2013&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2013, 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_LLEXPERIENCEASSOCIATIONRESPONDER_H
-#define LL_LLEXPERIENCEASSOCIATIONRESPONDER_H
-
-#include "llhttpclient.h"
-#include "llsd.h"
-
-class ExperienceAssociationResponder : public LLHTTPClient::Responder
-{
-public:
- typedef boost::function<void(const LLSD& experience)> callback_t;
-
- ExperienceAssociationResponder(callback_t callback);
-
- /*virtual*/ void httpSuccess();
- /*virtual*/ void httpFailure();
-
- static void fetchAssociatedExperience(const LLUUID& object_it, const LLUUID& item_id, callback_t callback);
-
-private:
- static void fetchAssociatedExperience(LLSD& request, callback_t callback);
-
- void sendResult(const LLSD& experience);
-
- callback_t mCallback;
-
-};
-
-#endif // LL_LLEXPERIENCEASSOCIATIONRESPONDER_H
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 4f5d21b6be..8a493b7084 100755
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -87,7 +87,6 @@
#include "llfloatergotoline.h"
#include "llexperiencecache.h"
#include "llfloaterexperienceprofile.h"
-#include "llexperienceassociationresponder.h"
#include "llviewerassetupload.h"
const std::string HELLO_LSL =
@@ -2039,8 +2038,9 @@ void LLLiveLSLEditor::loadAsset()
if(item)
{
- ExperienceAssociationResponder::fetchAssociatedExperience(item->getParentUUID(), item->getUUID(), boost::bind(&LLLiveLSLEditor::setAssociatedExperience, getDerivedHandle<LLLiveLSLEditor>(), _1));
-
+ LLExperienceCache::getInstance()->fetchAssociatedExperience(item->getParentUUID(), item->getUUID(),
+ boost::bind(&LLLiveLSLEditor::setAssociatedExperience, getDerivedHandle<LLLiveLSLEditor>(), _1));
+
bool isGodlike = gAgent.isGodlike();
bool copyManipulate = gAgent.allowOperation(PERM_COPY, item->getPermissions(), GP_OBJECT_MANIPULATE);
mIsModifiable = gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE);
diff --git a/indra/newview/llsidepaneliteminfo.cpp b/indra/newview/llsidepaneliteminfo.cpp
index a7cfc173af..ca17fe77b1 100755
--- a/indra/newview/llsidepaneliteminfo.cpp
+++ b/indra/newview/llsidepaneliteminfo.cpp
@@ -44,7 +44,6 @@
#include "llviewercontrol.h"
#include "llviewerinventory.h"
#include "llviewerobjectlist.h"
-#include "llexperienceassociationresponder.h"
#include "llexperiencecache.h"
#include "lltrans.h"
@@ -328,7 +327,9 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
LLTextBox* tb = getChild<LLTextBox>("LabelItemExperience");
tb->setText(getString("loading_experience"));
tb->setVisible(TRUE);
- ExperienceAssociationResponder::fetchAssociatedExperience(item->getParentUUID(), item->getUUID(), boost::bind(&LLSidepanelItemInfo::setAssociatedExperience, getDerivedHandle<LLSidepanelItemInfo>(), _1));
+
+ LLExperienceCache::getInstance()->fetchAssociatedExperience(item->getParentUUID(), item->getUUID(),
+ boost::bind(&LLSidepanelItemInfo::setAssociatedExperience, getDerivedHandle<LLSidepanelItemInfo>(), _1));
}
//////////////////////