1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 // ============================================================
11 // Implements the FailureCache class
13 // ============================================================
15 #include "failurecache.hpp"
17 namespace BINDER_SPACE
19 FailureCache::FailureCache() : SHash<FailureCacheHashTraits>::SHash()
24 FailureCache::~FailureCache()
26 // Delete entries and contents array
27 for (Hash::Iterator i = Hash::Begin(), end = Hash::End(); i != end; i++)
29 const FailureCacheEntry *pFailureCacheEntry = *i;
30 delete pFailureCacheEntry;
35 HRESULT FailureCache::Add(SString &assemblyNameorPath,
36 HRESULT hrBindingResult)
39 BINDER_LOG_ENTER(L"FailureCache::Add");
41 NewHolder<FailureCacheEntry> pFailureCacheEntry;
42 SAFE_NEW(pFailureCacheEntry, FailureCacheEntry);
44 // No error occurred; report the original error
47 pFailureCacheEntry->GetAssemblyNameOrPath().Set(assemblyNameorPath);
48 pFailureCacheEntry->SetBindingResult(hrBindingResult);
50 Hash::Add(pFailureCacheEntry);
51 pFailureCacheEntry.SuppressRelease();
54 BINDER_LOG_LEAVE_HR(L"FailureCache::Add", hr);
58 HRESULT FailureCache::Lookup(SString &assemblyNameorPath)
61 BINDER_LOG_ENTER(L"FailureCache::Lookup");
62 FailureCacheEntry *pFailureCachEntry = Hash::Lookup(assemblyNameorPath);
64 if (pFailureCachEntry != NULL)
66 hr = pFailureCachEntry->GetBindingResult();
69 BINDER_LOG_LEAVE_HR(L"FailureCache::Lookup", hr);
73 void FailureCache::Remove(SString &assemblyName)
75 BINDER_LOG_ENTER(L"FailureCache::Remove");
77 FailureCacheEntry *pFailureCachEntry = Hash::Lookup(assemblyName);
79 // Hash::Remove does not clean up entries
80 Hash::Remove(assemblyName);
81 SAFE_DELETE(pFailureCachEntry);
83 BINDER_LOG_LEAVE(L"FailureCache::Remove");