2 * Component Category Cache 'Daemon'
4 * Copyright (C) 2008 Maarten Lankhorst
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/debug.h"
37 #include "wine/heap.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(browseui
);
44 typedef struct tagCCCD
{
45 IRunnableTask IRunnableTask_iface
;
50 static inline CompCatCacheDaemon
*impl_from_IRunnableTask(IRunnableTask
*iface
)
52 return CONTAINING_RECORD(iface
, CompCatCacheDaemon
, IRunnableTask_iface
);
55 static void CompCatCacheDaemon_Destructor(CompCatCacheDaemon
*This
)
57 TRACE("destroying %p\n", This
);
58 This
->cs
.DebugInfo
->Spare
[0] = 0;
59 DeleteCriticalSection(&This
->cs
);
61 InterlockedDecrement(&BROWSEUI_refCount
);
64 static HRESULT WINAPI
CompCatCacheDaemon_QueryInterface(IRunnableTask
*iface
, REFIID iid
, LPVOID
*ppvOut
)
66 CompCatCacheDaemon
*This
= impl_from_IRunnableTask(iface
);
69 if (IsEqualIID(iid
, &IID_IRunnableTask
) || IsEqualIID(iid
, &IID_IUnknown
))
71 *ppvOut
= &This
->IRunnableTask_iface
;
76 IRunnableTask_AddRef(iface
);
80 FIXME("unsupported interface: %s\n", debugstr_guid(iid
));
84 static ULONG WINAPI
CompCatCacheDaemon_AddRef(IRunnableTask
*iface
)
86 CompCatCacheDaemon
*This
= impl_from_IRunnableTask(iface
);
87 return InterlockedIncrement(&This
->refCount
);
90 static ULONG WINAPI
CompCatCacheDaemon_Release(IRunnableTask
*iface
)
92 CompCatCacheDaemon
*This
= impl_from_IRunnableTask(iface
);
95 ret
= InterlockedDecrement(&This
->refCount
);
97 CompCatCacheDaemon_Destructor(This
);
101 static HRESULT WINAPI
CompCatCacheDaemon_Run(IRunnableTask
*iface
)
107 static HRESULT WINAPI
CompCatCacheDaemon_Kill(IRunnableTask
*iface
, BOOL fWait
)
113 static HRESULT WINAPI
CompCatCacheDaemon_Suspend(IRunnableTask
*iface
)
119 static HRESULT WINAPI
CompCatCacheDaemon_Resume(IRunnableTask
*iface
)
125 static ULONG WINAPI
CompCatCacheDaemon_IsRunning(IRunnableTask
*iface
)
131 static const IRunnableTaskVtbl CompCatCacheDaemonVtbl
=
133 CompCatCacheDaemon_QueryInterface
,
134 CompCatCacheDaemon_AddRef
,
135 CompCatCacheDaemon_Release
,
136 CompCatCacheDaemon_Run
,
137 CompCatCacheDaemon_Kill
,
138 CompCatCacheDaemon_Suspend
,
139 CompCatCacheDaemon_Resume
,
140 CompCatCacheDaemon_IsRunning
143 HRESULT
CompCatCacheDaemon_Constructor(IUnknown
*pUnkOuter
, IUnknown
**ppOut
)
145 CompCatCacheDaemon
*This
;
147 return CLASS_E_NOAGGREGATION
;
149 This
= heap_alloc(sizeof(CompCatCacheDaemon
));
151 return E_OUTOFMEMORY
;
153 This
->IRunnableTask_iface
.lpVtbl
= &CompCatCacheDaemonVtbl
;
155 InitializeCriticalSection(&This
->cs
);
156 This
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": CompCatCacheDaemon.cs");
158 TRACE("returning %p\n", This
);
159 *ppOut
= (IUnknown
*)&This
->IRunnableTask_iface
;
160 InterlockedIncrement(&BROWSEUI_refCount
);