summaryrefslogtreecommitdiff
path: root/indra/newview/llinventorymodelbackgroundfetch.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2024-04-24 18:49:41 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2024-04-24 18:49:41 +0300
commit3713c33098ab98d840c0ed20bcbb5a1cb8e15235 (patch)
treef2ee6c215244bdea45440b1a753c83d19eace121 /indra/newview/llinventorymodelbackgroundfetch.cpp
parentea4ddb5f40ee8dd253be0ac4229de90f1eef61a3 (diff)
parentd98fc504a1d4bc292ba86acdda053c8b4598a193 (diff)
Merge branch 'main' into marchcat/b-merge
Diffstat (limited to 'indra/newview/llinventorymodelbackgroundfetch.cpp')
-rw-r--r--indra/newview/llinventorymodelbackgroundfetch.cpp118
1 files changed, 89 insertions, 29 deletions
diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp
index c36b4b9726..7335d1e4fe 100644
--- a/indra/newview/llinventorymodelbackgroundfetch.cpp
+++ b/indra/newview/llinventorymodelbackgroundfetch.cpp
@@ -194,13 +194,16 @@ LLInventoryModelBackgroundFetch::LLInventoryModelBackgroundFetch():
mLastFetchCount(0),
mFetchFolderCount(0),
mAllRecursiveFoldersFetched(false),
- mRecursiveInventoryFetchStarted(false),
- mRecursiveLibraryFetchStarted(false),
- mMinTimeBetweenFetches(0.3f)
+ mRecursiveInventoryFetchStarted(false),
+ mRecursiveLibraryFetchStarted(false),
+ mRecursiveMarketplaceFetchStarted(false),
+ mMinTimeBetweenFetches(0.3f)
{}
LLInventoryModelBackgroundFetch::~LLInventoryModelBackgroundFetch()
-{}
+{
+ gIdleCallbacks.deleteFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
+}
bool LLInventoryModelBackgroundFetch::isBulkFetchProcessingComplete() const
{
@@ -315,6 +318,23 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive)
gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
}
}
+ else if (recursive && cat && cat->getPreferredType() == LLFolderType::FT_MARKETPLACE_LISTINGS)
+ {
+ if (mFetchFolderQueue.empty() || mFetchFolderQueue.back().mUUID != id)
+ {
+ if (recursive && AISAPI::isAvailable())
+ {
+ // Request marketplace folder and content separately
+ mFetchFolderQueue.push_front(FetchQueueInfo(id, FT_FOLDER_AND_CONTENT));
+ }
+ else
+ {
+ mFetchFolderQueue.push_front(FetchQueueInfo(id, recursion_type));
+ }
+ gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
+ mRecursiveMarketplaceFetchStarted = true;
+ }
+ }
else
{
if (AISAPI::isAvailable())
@@ -360,8 +380,22 @@ void LLInventoryModelBackgroundFetch::scheduleFolderFetch(const LLUUID& cat_id,
mBackgroundFetchActive = true;
mFolderFetchActive = true;
- // Specific folder requests go to front of queue.
- mFetchFolderQueue.push_front(FetchQueueInfo(cat_id, forced ? FT_FORCED : FT_DEFAULT));
+ if (forced)
+ {
+ // check if already requested
+ if (mForceFetchSet.find(cat_id) == mForceFetchSet.end())
+ {
+ mForceFetchSet.insert(cat_id);
+ mFetchItemQueue.push_front(FetchQueueInfo(cat_id, FT_FORCED));
+ }
+ }
+ else
+ {
+ // Specific folder requests go to front of queue.
+ // version presence acts as dupplicate prevention for normal fetches
+ mFetchItemQueue.push_front(FetchQueueInfo(cat_id, FT_DEFAULT));
+ }
+
gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
}
}
@@ -371,8 +405,21 @@ void LLInventoryModelBackgroundFetch::scheduleItemFetch(const LLUUID& item_id, b
if (mFetchItemQueue.empty() || mFetchItemQueue.front().mUUID != item_id)
{
mBackgroundFetchActive = true;
+ if (forced)
+ {
+ // check if already requested
+ if (mForceFetchSet.find(item_id) == mForceFetchSet.end())
+ {
+ mForceFetchSet.insert(item_id);
+ mFetchItemQueue.push_front(FetchQueueInfo(item_id, FT_FORCED, false));
+ }
+ }
+ else
+ {
+ // 'isFinished' being set acts as dupplicate prevention for normal fetches
+ mFetchItemQueue.push_front(FetchQueueInfo(item_id, FT_DEFAULT, false));
+ }
- mFetchItemQueue.push_front(FetchQueueInfo(item_id, forced ? FT_FORCED : FT_DEFAULT, false));
gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
}
}
@@ -608,6 +655,7 @@ void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_i
return;
}
+ LLViewerInventoryCategory::EFetchType new_state = LLViewerInventoryCategory::FETCH_NONE;
bool request_descendants = false;
if (response_id.isNull()) // Failure
{
@@ -625,10 +673,12 @@ void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_i
// set folder's version to prevent viewer from trying to request folder indefinetely
LLViewerInventoryCategory* cat(gInventory.getCategory(request_id));
- if (cat->getVersion() == LLViewerInventoryCategory::VERSION_UNKNOWN)
+ if (cat && cat->getVersion() == LLViewerInventoryCategory::VERSION_UNKNOWN)
{
cat->setVersion(0);
}
+ // back off for a bit in case something tries to force-request immediately
+ new_state = LLViewerInventoryCategory::FETCH_FAILED;
}
}
else
@@ -681,7 +731,7 @@ void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_i
LLViewerInventoryCategory * cat(gInventory.getCategory(request_id));
if (cat)
{
- cat->setFetching(LLViewerInventoryCategory::FETCH_NONE);
+ cat->setFetching(new_state);
}
}
@@ -770,7 +820,26 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis()
if (isFolderFetchProcessingComplete() && mFolderFetchActive)
{
- setAllFoldersFetched();
+ if (!mRecursiveInventoryFetchStarted || mRecursiveMarketplaceFetchStarted)
+ {
+ setAllFoldersFetched();
+ }
+ else
+ {
+ // Intent is for marketplace request to happen after
+ // main inventory is done, unless requested by floater
+ mRecursiveMarketplaceFetchStarted = true;
+ const LLUUID& marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS);
+ if (marketplacelistings_id.notNull())
+ {
+ mFetchFolderQueue.push_front(FetchQueueInfo(marketplacelistings_id, FT_FOLDER_AND_CONTENT));
+ }
+ else
+ {
+ setAllFoldersFetched();
+ }
+ }
+
}
if (isBulkFetchProcessingComplete())
@@ -830,22 +899,8 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc
if (child_cat->getPreferredType() == LLFolderType::FT_MARKETPLACE_LISTINGS)
{
- // special case
- content_done = false;
- if (children.empty())
- {
- // fetch marketplace alone
- // Should it actually be fetched as FT_FOLDER_AND_CONTENT?
- children.push_back(child_cat->getUUID());
- mExpectedFolderIds.push_back(child_cat->getUUID());
- child_cat->setFetching(target_state);
- break;
- }
- else
- {
- // fetch marketplace alone next run
- continue;
- }
+ // special case, marketplace will fetch that as needed
+ continue;
}
children.push_back(child_cat->getUUID());
@@ -919,10 +974,10 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc
mExpectedFolderIds.push_back(cat_id);
EFetchType type = fetch_info.mFetchType;
- LLUUID cat_id = cat->getUUID();
- AISAPI::completion_t cb = [cat_id , type](const LLUUID& response_id)
+ LLUUID cat_cb_id = cat_id;
+ AISAPI::completion_t cb = [cat_cb_id, type](const LLUUID& response_id)
{
- LLInventoryModelBackgroundFetch::instance().onAISFolderCalback(cat_id , response_id , type);
+ LLInventoryModelBackgroundFetch::instance().onAISFolderCalback(cat_cb_id, response_id , type);
};
AISAPI::ITEM_TYPE item_type = AISAPI::INVENTORY;
@@ -981,6 +1036,11 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc
AISAPI::FetchItem(fetch_info.mUUID, AISAPI::INVENTORY, ais_simple_item_callback);
}
}
+
+ if (fetch_info.mFetchType == FT_FORCED)
+ {
+ mForceFetchSet.erase(fetch_info.mUUID);
+ }
}
// Bundle up a bunch of requests to send all at once.