Imported Upstream version 5.4.0.167

Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-08-21 15:34:15 +00:00
parent e49d6f06c0
commit 536cd135cc
12856 changed files with 563812 additions and 223249 deletions

View File

@ -91,31 +91,20 @@ namespace System.Web.Hosting {
if (memoryCache == null) {
throw new ArgumentNullException("memoryCache");
}
long delta = 0;
lock (_lock) {
if (_cacheInfos != null) {
MemoryCacheInfo info = null;
if (_cacheInfos.TryGetValue(memoryCache, out info)) {
delta = 0 - info.Size;
_cacheInfos.Remove(memoryCache);
}
}
}
if (delta != 0) {
ApplicationManager appManager = HostingEnvironment.GetApplicationManager();
if (appManager != null) {
ExecutionContextUtil.RunInNullExecutionContext(delegate {
appManager.GetUpdatedTotalCacheSize(delta);
});
}
}
}
void IMemoryCacheManager.UpdateCacheSize(long size, MemoryCache memoryCache) {
if (memoryCache == null) {
throw new ArgumentNullException("memoryCache");
}
long delta = 0;
lock (_lock) {
if (_cacheInfos == null) {
_cacheInfos = new Dictionary<MemoryCache, MemoryCacheInfo>();
@ -126,15 +115,8 @@ namespace System.Web.Hosting {
info.Cache = memoryCache;
_cacheInfos[memoryCache] = info;
}
delta = size - info.Size;
info.Size = size;
}
ApplicationManager appManager = HostingEnvironment.GetApplicationManager();
if (appManager != null) {
ExecutionContextUtil.RunInNullExecutionContext(delegate {
appManager.GetUpdatedTotalCacheSize(delta);
});
}
}
internal long TrimCache(int percent) {