summaryrefslogtreecommitdiff
path: root/indra/newview/llinventorymodelbackgroundfetch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp')
-rw-r--r--indra/newview/llinventorymodelbackgroundfetch.cpp123
1 files changed, 60 insertions, 63 deletions
diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp
index eab8f187a7..b4f0947b2c 100644
--- a/indra/newview/llinventorymodelbackgroundfetch.cpp
+++ b/indra/newview/llinventorymodelbackgroundfetch.cpp
@@ -2,39 +2,46 @@
* @file llinventorymodel.cpp
* @brief Implementation of the inventory model used to track agent inventory.
*
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2002&license=viewergpl$
+ *
+ * Copyright (c) 2002-2009, 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.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab. Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
- * 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.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
- * 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
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
*
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llinventorymodelbackgroundfetch.h"
+// Seraph clean this up
#include "llagent.h"
-#include "llappviewer.h"
-#include "llcallbacklist.h"
#include "llinventorypanel.h"
#include "llviewercontrol.h"
#include "llviewermessage.h"
-#include "llviewerregion.h"
#include "llviewerwindow.h"
+#include "llappviewer.h"
+#include "llviewerregion.h"
+#include "llcallbacklist.h"
const F32 MAX_TIME_FOR_SINGLE_FETCH = 10.f;
const S32 MAX_FETCH_RETRIES = 10;
@@ -56,47 +63,47 @@ LLInventoryModelBackgroundFetch::~LLInventoryModelBackgroundFetch()
{
}
-bool LLInventoryModelBackgroundFetch::isBulkFetchProcessingComplete() const
+bool LLInventoryModelBackgroundFetch::isBulkFetchProcessingComplete()
{
return mFetchQueue.empty() && mBulkFetchCount<=0;
}
-bool LLInventoryModelBackgroundFetch::libraryFetchStarted() const
+bool LLInventoryModelBackgroundFetch::libraryFetchStarted()
{
return mRecursiveLibraryFetchStarted;
}
-bool LLInventoryModelBackgroundFetch::libraryFetchCompleted() const
+bool LLInventoryModelBackgroundFetch::libraryFetchCompleted()
{
return libraryFetchStarted() && fetchQueueContainsNoDescendentsOf(gInventory.getLibraryRootFolderID());
}
-bool LLInventoryModelBackgroundFetch::libraryFetchInProgress() const
+bool LLInventoryModelBackgroundFetch::libraryFetchInProgress()
{
return libraryFetchStarted() && !libraryFetchCompleted();
}
-bool LLInventoryModelBackgroundFetch::inventoryFetchStarted() const
+bool LLInventoryModelBackgroundFetch::inventoryFetchStarted()
{
return mRecursiveInventoryFetchStarted;
}
-bool LLInventoryModelBackgroundFetch::inventoryFetchCompleted() const
+bool LLInventoryModelBackgroundFetch::inventoryFetchCompleted()
{
return inventoryFetchStarted() && fetchQueueContainsNoDescendentsOf(gInventory.getRootFolderID());
}
-bool LLInventoryModelBackgroundFetch::inventoryFetchInProgress() const
+bool LLInventoryModelBackgroundFetch::inventoryFetchInProgress()
{
return inventoryFetchStarted() && !inventoryFetchCompleted();
}
-bool LLInventoryModelBackgroundFetch::isEverythingFetched() const
+bool LLInventoryModelBackgroundFetch::isEverythingFetched()
{
return mAllFoldersFetched;
}
-BOOL LLInventoryModelBackgroundFetch::backgroundFetchActive() const
+BOOL LLInventoryModelBackgroundFetch::backgroundFetchActive()
{
return mBackgroundFetchActive;
}
@@ -125,7 +132,7 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& cat_id, BOOL recursive
}
else
{
- // Specific folder requests go to front of queue.
+ // specific folder requests go to front of queue
if (mFetchQueue.empty() || mFetchQueue.front().mCatUUID != cat_id)
{
mFetchQueue.push_front(FetchQueueInfo(cat_id, recursive));
@@ -180,7 +187,7 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
{
if (mBackgroundFetchActive && gAgent.getRegion())
{
- // If we'll be using the capability, we'll be sending batches and the background thing isn't as important.
+ //If we'll be using the capability, we'll be sending batches and the background thing isn't as important.
std::string url = gAgent.getRegion()->getCapability("WebFetchInventoryDescendents");
if (!url.empty())
{
@@ -188,12 +195,8 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
return;
}
-#if 1
- //--------------------------------------------------------------------------------
- // DEPRECATED OLD CODE
- //
-
- // No more categories to fetch, stop fetch process.
+ //DEPRECATED OLD CODE FOLLOWS.
+ // no more categories to fetch, stop fetch process
if (mFetchQueue.empty())
{
llinfos << "Inventory fetch completed" << llendl;
@@ -206,11 +209,11 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
F32 slow_fetch_time = lerp(mMinTimeBetweenFetches, mMaxTimeBetweenFetches, 0.5f);
if (mTimelyFetchPending && mFetchTimer.getElapsedTimeF32() > slow_fetch_time)
{
- // Double timeouts on failure.
+ // double timeouts on failure
mMinTimeBetweenFetches = llmin(mMinTimeBetweenFetches * 2.f, 10.f);
mMaxTimeBetweenFetches = llmin(mMaxTimeBetweenFetches * 2.f, 120.f);
llinfos << "Inventory fetch times grown to (" << mMinTimeBetweenFetches << ", " << mMaxTimeBetweenFetches << ")" << llendl;
- // fetch is no longer considered "timely" although we will wait for full time-out.
+ // fetch is no longer considered "timely" although we will wait for full time-out
mTimelyFetchPending = FALSE;
}
@@ -223,14 +226,14 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
if(gDisconnected)
{
- // Just bail if we are disconnected.
+ // just bail if we are disconnected.
break;
}
const FetchQueueInfo info = mFetchQueue.front();
LLViewerInventoryCategory* cat = gInventory.getCategory(info.mCatUUID);
- // Category has been deleted, remove from queue.
+ // category has been deleted, remove from queue.
if (!cat)
{
mFetchQueue.pop_front();
@@ -240,8 +243,8 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
if (mFetchTimer.getElapsedTimeF32() > mMinTimeBetweenFetches &&
LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion())
{
- // Category exists but has no children yet, fetch the descendants
- // for now, just request every time and rely on retry timer to throttle.
+ // category exists but has no children yet, fetch the descendants
+ // for now, just request every time and rely on retry timer to throttle
if (cat->fetch())
{
mFetchTimer.reset();
@@ -255,13 +258,13 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
break;
}
}
- // Do I have all my children?
+ // do I have all my children?
else if (gInventory.isCategoryComplete(info.mCatUUID))
{
- // Finished with this category, remove from queue.
+ // finished with this category, remove from queue
mFetchQueue.pop_front();
- // Add all children to queue.
+ // add all children to queue
LLInventoryModel::cat_array_t* categories;
LLInventoryModel::item_array_t* items;
gInventory.getDirectDescendentsOf(cat->getUUID(), categories, items);
@@ -272,10 +275,10 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(),info.mRecursive));
}
- // We received a response in less than the fast time.
+ // we received a response in less than the fast time
if (mTimelyFetchPending && mFetchTimer.getElapsedTimeF32() < fast_fetch_time)
{
- // Shrink timeouts based on success.
+ // shrink timeouts based on success
mMinTimeBetweenFetches = llmax(mMinTimeBetweenFetches * 0.8f, 0.3f);
mMaxTimeBetweenFetches = llmax(mMaxTimeBetweenFetches * 0.8f, 10.f);
//llinfos << "Inventory fetch times shrunk to (" << mMinTimeBetweenFetches << ", " << mMaxTimeBetweenFetches << ")" << llendl;
@@ -286,8 +289,8 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
}
else if (mFetchTimer.getElapsedTimeF32() > mMaxTimeBetweenFetches)
{
- // Received first packet, but our num descendants does not match db's num descendants
- // so try again later.
+ // received first packet, but our num descendants does not match db's num descendants
+ // so try again later
mFetchQueue.pop_front();
if (mNumFetchRetries++ < MAX_FETCH_RETRIES)
@@ -300,14 +303,9 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
break;
}
- // Not enough time has elapsed to do a new fetch
+ // not enough time has elapsed to do a new fetch
break;
}
-
- //
- // DEPRECATED OLD CODE
- //--------------------------------------------------------------------------------
-#endif
}
}
@@ -335,10 +333,10 @@ protected:
BOOL getIsRecursive(const LLUUID& cat_id) const;
private:
LLSD mRequestSD;
- uuid_vec_t mRecursiveCatUUIDs; // hack for storing away which cat fetches are recursive
+ uuid_vec_t mRecursiveCatUUIDs; // Hack for storing away which cat fetches are recursive.
};
-// If we get back a normal response, handle it here.
+//If we get back a normal response, handle it here
void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
{
LLInventoryModelBackgroundFetch *fetcher = LLInventoryModelBackgroundFetch::getInstance();
@@ -430,7 +428,7 @@ void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
gInventory.updateItem(titem);
}
- // Set version and descendentcount according to message.
+ // set version and descendentcount according to message.
LLViewerInventoryCategory* cat = gInventory.getCategory(parent_id);
if(cat)
{
@@ -450,7 +448,7 @@ void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
{
LLSD folder_sd = *folder_it;
- // These folders failed on the dataserver. We probably don't want to retry them.
+ //These folders failed on the dataserver. We probably don't want to retry them.
llinfos << "Folder " << folder_sd["folder_id"].asString()
<< "Error: " << folder_sd["error"].asString() << llendl;
}
@@ -467,7 +465,7 @@ void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
gInventory.notifyObservers("fetchDescendents");
}
-// If we get back an error (not found, etc...), handle it here.
+//If we get back an error (not found, etc...), handle it here
void LLInventoryModelFetchDescendentsResponder::error(U32 status, const std::string& reason)
{
LLInventoryModelBackgroundFetch *fetcher = LLInventoryModelBackgroundFetch::getInstance();
@@ -477,7 +475,7 @@ void LLInventoryModelFetchDescendentsResponder::error(U32 status, const std::str
fetcher->incrBulkFetch(-1);
- if (status==499) // timed out
+ if (status==499) // Timed out.
{
for(LLSD::array_const_iterator folder_it = mRequestSD["folders"].beginArray();
folder_it != mRequestSD["folders"].endArray();
@@ -504,8 +502,7 @@ BOOL LLInventoryModelFetchDescendentsResponder::getIsRecursive(const LLUUID& cat
return (std::find(mRecursiveCatUUIDs.begin(),mRecursiveCatUUIDs.end(), cat_id) != mRecursiveCatUUIDs.end());
}
-// Bundle up a bunch of requests to send all at once.
-// static
+//static Bundle up a bunch of requests to send all at once.
void LLInventoryModelBackgroundFetch::bulkFetch(std::string url)
{
//Background fetch is called from gIdleCallbacks in a loop until background fetch is stopped.
@@ -524,7 +521,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch(std::string url)
(mBulkFetchCount > max_concurrent_fetches) ||
(mFetchTimer.getElapsedTimeF32() < mMinTimeBetweenFetches))
{
- return; // just bail if we are disconnected
+ return; // just bail if we are disconnected.
}
U32 folder_count=0;