Commit 5d6b2f13 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

urlmon: Use ifaces instead of vtbl pointers in ProtocolProxy.

parent f0bd3e69
...@@ -194,8 +194,8 @@ static HRESULT handle_mime_filter(BindProtocol *This, IInternetProtocol *mime_fi ...@@ -194,8 +194,8 @@ static HRESULT handle_mime_filter(BindProtocol *This, IInternetProtocol *mime_fi
IInternetProtocol_AddRef(mime_filter); IInternetProtocol_AddRef(mime_filter);
This->protocol_handler = mime_filter; This->protocol_handler = mime_filter;
filter_data.pProtocol = PROTOCOL(filter_proxy); filter_data.pProtocol = &filter_proxy->IInternetProtocol_iface;
hres = IInternetProtocol_Start(mime_filter, mime, PROTSINK(filter_proxy), hres = IInternetProtocol_Start(mime_filter, mime, &filter_proxy->IInternetProtocolSink_iface,
&This->IInternetBindInfo_iface, PI_FILTER_MODE|PI_FORCE_ASYNC, &This->IInternetBindInfo_iface, PI_FILTER_MODE|PI_FORCE_ASYNC,
(HANDLE_PTR)&filter_data); (HANDLE_PTR)&filter_data);
if(FAILED(hres)) { if(FAILED(hres)) {
...@@ -336,7 +336,7 @@ static ULONG WINAPI BindProtocol_Release(IInternetProtocolEx *iface) ...@@ -336,7 +336,7 @@ static ULONG WINAPI BindProtocol_Release(IInternetProtocolEx *iface)
if(This->protocol_handler && This->protocol_handler != &This->default_protocol_handler.IInternetProtocol_iface) if(This->protocol_handler && This->protocol_handler != &This->default_protocol_handler.IInternetProtocol_iface)
IInternetProtocol_Release(This->protocol_handler); IInternetProtocol_Release(This->protocol_handler);
if(This->filter_proxy) if(This->filter_proxy)
IInternetProtocol_Release(PROTOCOL(This->filter_proxy)); IInternetProtocol_Release(&This->filter_proxy->IInternetProtocol_iface);
if(This->uri) if(This->uri)
IUri_Release(This->uri); IUri_Release(This->uri);
...@@ -664,7 +664,7 @@ static HRESULT WINAPI ProtocolHandler_Terminate(IInternetProtocol *iface, DWORD ...@@ -664,7 +664,7 @@ static HRESULT WINAPI ProtocolHandler_Terminate(IInternetProtocol *iface, DWORD
IInternetProtocol_Terminate(This->protocol, 0); IInternetProtocol_Terminate(This->protocol, 0);
if(This->filter_proxy) { if(This->filter_proxy) {
IInternetProtocol_Release(PROTOCOL(This->filter_proxy)); IInternetProtocol_Release(&This->filter_proxy->IInternetProtocol_iface);
This->filter_proxy = NULL; This->filter_proxy = NULL;
} }
......
...@@ -21,25 +21,28 @@ ...@@ -21,25 +21,28 @@
WINE_DEFAULT_DEBUG_CHANNEL(urlmon); WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
#define PROTOCOL_THIS(iface) DEFINE_THIS(ProtocolProxy, IInternetProtocol, iface) static inline ProtocolProxy *impl_from_IInternetProtocol(IInternetProtocol *iface)
{
return CONTAINING_RECORD(iface, ProtocolProxy, IInternetProtocol_iface);
}
static HRESULT WINAPI ProtocolProxy_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv) static HRESULT WINAPI ProtocolProxy_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
{ {
ProtocolProxy *This = PROTOCOL_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocol(iface);
*ppv = NULL; *ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) { if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = PROTOCOL(This); *ppv = &This->IInternetProtocol_iface;
}else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) { }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv); TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
*ppv = PROTOCOL(This); *ppv = &This->IInternetProtocol_iface;
}else if(IsEqualGUID(&IID_IInternetProtocol, riid)) { }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv); TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
*ppv = PROTOCOL(This); *ppv = &This->IInternetProtocol_iface;
}else if(IsEqualGUID(&IID_IInternetProtocolSink, riid)) { }else if(IsEqualGUID(&IID_IInternetProtocolSink, riid)) {
TRACE("(%p)->(IID_IInternetProtocolSink %p)\n", This, ppv); TRACE("(%p)->(IID_IInternetProtocolSink %p)\n", This, ppv);
*ppv = PROTSINK(This); *ppv = &This->IInternetProtocolSink_iface;
} }
if(*ppv) { if(*ppv) {
...@@ -53,7 +56,7 @@ static HRESULT WINAPI ProtocolProxy_QueryInterface(IInternetProtocol *iface, REF ...@@ -53,7 +56,7 @@ static HRESULT WINAPI ProtocolProxy_QueryInterface(IInternetProtocol *iface, REF
static ULONG WINAPI ProtocolProxy_AddRef(IInternetProtocol *iface) static ULONG WINAPI ProtocolProxy_AddRef(IInternetProtocol *iface)
{ {
ProtocolProxy *This = PROTOCOL_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocol(iface);
LONG ref = InterlockedIncrement(&This->ref); LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref); TRACE("(%p) ref=%d\n", This, ref);
return ref; return ref;
...@@ -61,7 +64,7 @@ static ULONG WINAPI ProtocolProxy_AddRef(IInternetProtocol *iface) ...@@ -61,7 +64,7 @@ static ULONG WINAPI ProtocolProxy_AddRef(IInternetProtocol *iface)
static ULONG WINAPI ProtocolProxy_Release(IInternetProtocol *iface) static ULONG WINAPI ProtocolProxy_Release(IInternetProtocol *iface)
{ {
ProtocolProxy *This = PROTOCOL_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocol(iface);
LONG ref = InterlockedDecrement(&This->ref); LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref); TRACE("(%p) ref=%d\n", This, ref);
...@@ -84,7 +87,7 @@ static HRESULT WINAPI ProtocolProxy_Start(IInternetProtocol *iface, LPCWSTR szUr ...@@ -84,7 +87,7 @@ static HRESULT WINAPI ProtocolProxy_Start(IInternetProtocol *iface, LPCWSTR szUr
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
DWORD grfPI, HANDLE_PTR dwReserved) DWORD grfPI, HANDLE_PTR dwReserved)
{ {
ProtocolProxy *This = PROTOCOL_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocol(iface);
TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink, TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink,
pOIBindInfo, grfPI, dwReserved); pOIBindInfo, grfPI, dwReserved);
...@@ -94,7 +97,7 @@ static HRESULT WINAPI ProtocolProxy_Start(IInternetProtocol *iface, LPCWSTR szUr ...@@ -94,7 +97,7 @@ static HRESULT WINAPI ProtocolProxy_Start(IInternetProtocol *iface, LPCWSTR szUr
static HRESULT WINAPI ProtocolProxy_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData) static HRESULT WINAPI ProtocolProxy_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
{ {
ProtocolProxy *This = PROTOCOL_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocol(iface);
TRACE("(%p)->(%p)\n", This, pProtocolData); TRACE("(%p)->(%p)\n", This, pProtocolData);
...@@ -104,14 +107,14 @@ static HRESULT WINAPI ProtocolProxy_Continue(IInternetProtocol *iface, PROTOCOLD ...@@ -104,14 +107,14 @@ static HRESULT WINAPI ProtocolProxy_Continue(IInternetProtocol *iface, PROTOCOLD
static HRESULT WINAPI ProtocolProxy_Abort(IInternetProtocol *iface, HRESULT hrReason, static HRESULT WINAPI ProtocolProxy_Abort(IInternetProtocol *iface, HRESULT hrReason,
DWORD dwOptions) DWORD dwOptions)
{ {
ProtocolProxy *This = PROTOCOL_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocol(iface);
FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT WINAPI ProtocolProxy_Terminate(IInternetProtocol *iface, DWORD dwOptions) static HRESULT WINAPI ProtocolProxy_Terminate(IInternetProtocol *iface, DWORD dwOptions)
{ {
ProtocolProxy *This = PROTOCOL_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocol(iface);
TRACE("(%p)->(%08x)\n", This, dwOptions); TRACE("(%p)->(%08x)\n", This, dwOptions);
...@@ -120,14 +123,14 @@ static HRESULT WINAPI ProtocolProxy_Terminate(IInternetProtocol *iface, DWORD dw ...@@ -120,14 +123,14 @@ static HRESULT WINAPI ProtocolProxy_Terminate(IInternetProtocol *iface, DWORD dw
static HRESULT WINAPI ProtocolProxy_Suspend(IInternetProtocol *iface) static HRESULT WINAPI ProtocolProxy_Suspend(IInternetProtocol *iface)
{ {
ProtocolProxy *This = PROTOCOL_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocol(iface);
FIXME("(%p)\n", This); FIXME("(%p)\n", This);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT WINAPI ProtocolProxy_Resume(IInternetProtocol *iface) static HRESULT WINAPI ProtocolProxy_Resume(IInternetProtocol *iface)
{ {
ProtocolProxy *This = PROTOCOL_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocol(iface);
FIXME("(%p)\n", This); FIXME("(%p)\n", This);
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -135,7 +138,7 @@ static HRESULT WINAPI ProtocolProxy_Resume(IInternetProtocol *iface) ...@@ -135,7 +138,7 @@ static HRESULT WINAPI ProtocolProxy_Resume(IInternetProtocol *iface)
static HRESULT WINAPI ProtocolProxy_Read(IInternetProtocol *iface, void *pv, static HRESULT WINAPI ProtocolProxy_Read(IInternetProtocol *iface, void *pv,
ULONG cb, ULONG *pcbRead) ULONG cb, ULONG *pcbRead)
{ {
ProtocolProxy *This = PROTOCOL_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocol(iface);
TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead); TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
...@@ -145,14 +148,14 @@ static HRESULT WINAPI ProtocolProxy_Read(IInternetProtocol *iface, void *pv, ...@@ -145,14 +148,14 @@ static HRESULT WINAPI ProtocolProxy_Read(IInternetProtocol *iface, void *pv,
static HRESULT WINAPI ProtocolProxy_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove, static HRESULT WINAPI ProtocolProxy_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
{ {
ProtocolProxy *This = PROTOCOL_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocol(iface);
FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition); FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT WINAPI ProtocolProxy_LockRequest(IInternetProtocol *iface, DWORD dwOptions) static HRESULT WINAPI ProtocolProxy_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
{ {
ProtocolProxy *This = PROTOCOL_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocol(iface);
TRACE("(%p)->(%08x)\n", This, dwOptions); TRACE("(%p)->(%08x)\n", This, dwOptions);
...@@ -161,15 +164,13 @@ static HRESULT WINAPI ProtocolProxy_LockRequest(IInternetProtocol *iface, DWORD ...@@ -161,15 +164,13 @@ static HRESULT WINAPI ProtocolProxy_LockRequest(IInternetProtocol *iface, DWORD
static HRESULT WINAPI ProtocolProxy_UnlockRequest(IInternetProtocol *iface) static HRESULT WINAPI ProtocolProxy_UnlockRequest(IInternetProtocol *iface)
{ {
ProtocolProxy *This = PROTOCOL_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocol(iface);
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
return IInternetProtocol_UnlockRequest(This->protocol); return IInternetProtocol_UnlockRequest(This->protocol);
} }
#undef PROTOCOL_THIS
static const IInternetProtocolVtbl ProtocolProxyVtbl = { static const IInternetProtocolVtbl ProtocolProxyVtbl = {
ProtocolProxy_QueryInterface, ProtocolProxy_QueryInterface,
ProtocolProxy_AddRef, ProtocolProxy_AddRef,
...@@ -186,31 +187,34 @@ static const IInternetProtocolVtbl ProtocolProxyVtbl = { ...@@ -186,31 +187,34 @@ static const IInternetProtocolVtbl ProtocolProxyVtbl = {
ProtocolProxy_UnlockRequest ProtocolProxy_UnlockRequest
}; };
#define PROTSINK_THIS(iface) DEFINE_THIS(ProtocolProxy, IInternetProtocolSink, iface) static inline ProtocolProxy *impl_from_IInternetProtocolSink(IInternetProtocolSink *iface)
{
return CONTAINING_RECORD(iface, ProtocolProxy, IInternetProtocolSink_iface);
}
static HRESULT WINAPI ProtocolProxySink_QueryInterface(IInternetProtocolSink *iface, static HRESULT WINAPI ProtocolProxySink_QueryInterface(IInternetProtocolSink *iface,
REFIID riid, void **ppv) REFIID riid, void **ppv)
{ {
ProtocolProxy *This = PROTSINK_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv); return IInternetProtocol_QueryInterface(&This->IInternetProtocol_iface, riid, ppv);
} }
static ULONG WINAPI ProtocolProxySink_AddRef(IInternetProtocolSink *iface) static ULONG WINAPI ProtocolProxySink_AddRef(IInternetProtocolSink *iface)
{ {
ProtocolProxy *This = PROTSINK_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
return IInternetProtocol_AddRef(PROTOCOL(This)); return IInternetProtocol_AddRef(&This->IInternetProtocol_iface);
} }
static ULONG WINAPI ProtocolProxySink_Release(IInternetProtocolSink *iface) static ULONG WINAPI ProtocolProxySink_Release(IInternetProtocolSink *iface)
{ {
ProtocolProxy *This = PROTSINK_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
return IInternetProtocol_Release(PROTOCOL(This)); return IInternetProtocol_Release(&This->IInternetProtocol_iface);
} }
static HRESULT WINAPI ProtocolProxySink_Switch(IInternetProtocolSink *iface, static HRESULT WINAPI ProtocolProxySink_Switch(IInternetProtocolSink *iface,
PROTOCOLDATA *pProtocolData) PROTOCOLDATA *pProtocolData)
{ {
ProtocolProxy *This = PROTSINK_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
TRACE("(%p)->(%p)\n", This, pProtocolData); TRACE("(%p)->(%p)\n", This, pProtocolData);
...@@ -220,7 +224,7 @@ static HRESULT WINAPI ProtocolProxySink_Switch(IInternetProtocolSink *iface, ...@@ -220,7 +224,7 @@ static HRESULT WINAPI ProtocolProxySink_Switch(IInternetProtocolSink *iface,
static HRESULT WINAPI ProtocolProxySink_ReportProgress(IInternetProtocolSink *iface, static HRESULT WINAPI ProtocolProxySink_ReportProgress(IInternetProtocolSink *iface,
ULONG ulStatusCode, LPCWSTR szStatusText) ULONG ulStatusCode, LPCWSTR szStatusText)
{ {
ProtocolProxy *This = PROTSINK_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
TRACE("(%p)->(%u %s)\n", This, ulStatusCode, debugstr_w(szStatusText)); TRACE("(%p)->(%u %s)\n", This, ulStatusCode, debugstr_w(szStatusText));
...@@ -238,7 +242,7 @@ static HRESULT WINAPI ProtocolProxySink_ReportProgress(IInternetProtocolSink *if ...@@ -238,7 +242,7 @@ static HRESULT WINAPI ProtocolProxySink_ReportProgress(IInternetProtocolSink *if
static HRESULT WINAPI ProtocolProxySink_ReportData(IInternetProtocolSink *iface, static HRESULT WINAPI ProtocolProxySink_ReportData(IInternetProtocolSink *iface,
DWORD grfBSCF, ULONG ulProgress, ULONG ulProgressMax) DWORD grfBSCF, ULONG ulProgress, ULONG ulProgressMax)
{ {
ProtocolProxy *This = PROTSINK_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
TRACE("(%p)->(%d %u %u)\n", This, grfBSCF, ulProgress, ulProgressMax); TRACE("(%p)->(%d %u %u)\n", This, grfBSCF, ulProgress, ulProgressMax);
...@@ -248,15 +252,13 @@ static HRESULT WINAPI ProtocolProxySink_ReportData(IInternetProtocolSink *iface, ...@@ -248,15 +252,13 @@ static HRESULT WINAPI ProtocolProxySink_ReportData(IInternetProtocolSink *iface,
static HRESULT WINAPI ProtocolProxySink_ReportResult(IInternetProtocolSink *iface, static HRESULT WINAPI ProtocolProxySink_ReportResult(IInternetProtocolSink *iface,
HRESULT hrResult, DWORD dwError, LPCWSTR szResult) HRESULT hrResult, DWORD dwError, LPCWSTR szResult)
{ {
ProtocolProxy *This = PROTSINK_THIS(iface); ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
TRACE("(%p)->(%08x %d %s)\n", This, hrResult, dwError, debugstr_w(szResult)); TRACE("(%p)->(%08x %d %s)\n", This, hrResult, dwError, debugstr_w(szResult));
return IInternetProtocolSink_ReportResult(This->protocol_sink, hrResult, dwError, szResult); return IInternetProtocolSink_ReportResult(This->protocol_sink, hrResult, dwError, szResult);
} }
#undef PROTSINK_THIS
static const IInternetProtocolSinkVtbl InternetProtocolSinkVtbl = { static const IInternetProtocolSinkVtbl InternetProtocolSinkVtbl = {
ProtocolProxySink_QueryInterface, ProtocolProxySink_QueryInterface,
ProtocolProxySink_AddRef, ProtocolProxySink_AddRef,
...@@ -275,8 +277,8 @@ HRESULT create_protocol_proxy(IInternetProtocol *protocol, IInternetProtocolSink ...@@ -275,8 +277,8 @@ HRESULT create_protocol_proxy(IInternetProtocol *protocol, IInternetProtocolSink
if(!sink) if(!sink)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
sink->lpIInternetProtocolVtbl = &ProtocolProxyVtbl; sink->IInternetProtocol_iface.lpVtbl = &ProtocolProxyVtbl;
sink->lpIInternetProtocolSinkVtbl = &InternetProtocolSinkVtbl; sink->IInternetProtocolSink_iface.lpVtbl = &InternetProtocolSinkVtbl;
sink->ref = 1; sink->ref = 1;
IInternetProtocol_AddRef(protocol); IInternetProtocol_AddRef(protocol);
......
...@@ -152,8 +152,8 @@ HRESULT protocol_abort(Protocol*,HRESULT); ...@@ -152,8 +152,8 @@ HRESULT protocol_abort(Protocol*,HRESULT);
void protocol_close_connection(Protocol*); void protocol_close_connection(Protocol*);
typedef struct { typedef struct {
const IInternetProtocolVtbl *lpIInternetProtocolVtbl; IInternetProtocol IInternetProtocol_iface;
const IInternetProtocolSinkVtbl *lpIInternetProtocolSinkVtbl; IInternetProtocolSink IInternetProtocolSink_iface;
LONG ref; LONG ref;
...@@ -161,7 +161,6 @@ typedef struct { ...@@ -161,7 +161,6 @@ typedef struct {
IInternetProtocol *protocol; IInternetProtocol *protocol;
} ProtocolProxy; } ProtocolProxy;
#define PROTOCOL(x) ((IInternetProtocol*) &(x)->lpIInternetProtocolVtbl)
#define PROTSINK(x) ((IInternetProtocolSink*) &(x)->lpIInternetProtocolSinkVtbl) #define PROTSINK(x) ((IInternetProtocolSink*) &(x)->lpIInternetProtocolSinkVtbl)
HRESULT create_protocol_proxy(IInternetProtocol*,IInternetProtocolSink*,ProtocolProxy**); HRESULT create_protocol_proxy(IInternetProtocol*,IInternetProtocolSink*,ProtocolProxy**);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment