refactor : 重构网络下载模块

This commit is contained in:
何冠峰
2026-01-07 15:08:05 +08:00
parent ee67a55c0f
commit 9b83dcf723
8 changed files with 31 additions and 32 deletions
@@ -1,9 +1,14 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace YooAsset
{
/// <summary>
/// 网络请求失败计数器(诊断用)
/// </summary>
/// <remarks>
/// 线程安全:内部使用 Dictionary 且未加锁,约定只在 Unity 主线程调用。
/// 如需在多线程/回调线程调用,请在外层加锁或改为并发容器实现。
/// </remarks>
internal class WebRequestCounter
{
#if UNITY_EDITOR
@@ -15,12 +20,12 @@ namespace YooAsset
#endif
/// <summary>
/// 记录网络请求失败事件的次数
/// 失败计数记录表(key = $"{packageName}_{eventName}")
/// </summary>
private static readonly Dictionary<string, int> _requestFailedRecorder = new Dictionary<string, int>(1000);
/// <summary>
/// 记录请求失败事件
/// 记录一次失败
/// </summary>
public static void RecordRequestFailed(string packageName, string eventName)
{
@@ -31,7 +36,7 @@ namespace YooAsset
}
/// <summary>
/// 获取请求失败的次数
/// 获取失败次数
/// </summary>
public static int GetRequestFailedCount(string packageName, string eventName)
{
@@ -41,4 +46,4 @@ namespace YooAsset
return _requestFailedRecorder[key];
}
}
}
}