-
Notifications
You must be signed in to change notification settings - Fork 2
/
PolicyManager.cpp
72 lines (52 loc) · 1.63 KB
/
PolicyManager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "PolicyManager.h"
#include "Logger.h"
SHPolicyManager::SHPolicyManager(HostContext* context) {
hostContext = context;
}
SHPolicyManager::~SHPolicyManager() {}
// IUnknown
STDMETHODIMP_(DWORD) SHPolicyManager::AddRef() {
return InterlockedIncrement(&m_cRef);
}
STDMETHODIMP_(DWORD) SHPolicyManager::Release() {
ULONG cRef = InterlockedDecrement(&m_cRef);
if (cRef == 0)
delete this;
return cRef;
}
STDMETHODIMP SHPolicyManager::QueryInterface(const IID &riid, void **ppvObject) {
if (ppvObject == NULL)
return E_INVALIDARG;
if (riid == IID_IUnknown || riid == IID_IHostPolicyManager) {
*ppvObject = this;
AddRef();
return S_OK;
}
*ppvObject = NULL;
return E_NOINTERFACE;
}
// IHostPolicyManager
STDMETHODIMP SHPolicyManager::OnDefaultAction(
/* [in] */ EClrOperation operation,
/* [in] */ EPolicyAction action) {
Logger::Debug("In PolicyManager::OnDefaultAction %d - %d", operation, action);
if (action == eRudeUnloadAppDomain)
hostContext->OnDomainRudeUnload();
return S_OK;
}
STDMETHODIMP SHPolicyManager::OnTimeout(
/* [in] */ EClrOperation operation,
/* [in] */ EPolicyAction action) {
Logger::Debug("In PolicyManager::OnTimeout %d - %d", operation, action);
if (action == eRudeUnloadAppDomain)
hostContext->OnDomainRudeUnload();
return S_OK;
}
STDMETHODIMP SHPolicyManager::OnFailure(
/* [in] */ EClrFailure failure,
/* [in] */ EPolicyAction action) {
Logger::Debug("In PolicyManager::OnFailure %d - %d", failure, action);
if (action == eRudeUnloadAppDomain)
hostContext->OnDomainRudeUnload();
return S_OK;
}