urlmon: Added support for COM aggregation to http protocol handler.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2018-05-08 18:18:32 +02:00 committed by Alexandre Julliard
parent 74989b6e41
commit 8eeac66052
2 changed files with 59 additions and 23 deletions

View File

@ -32,6 +32,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
typedef struct {
Protocol base;
IUnknown IUnknown_outer;
IInternetProtocolEx IInternetProtocolEx_iface;
IInternetPriority IInternetPriority_iface;
IWinInetHttpInfo IWinInetHttpInfo_iface;
@ -41,8 +42,14 @@ typedef struct {
WCHAR *full_header;
LONG ref;
IUnknown *outer;
} HttpProtocol;
static inline HttpProtocol *impl_from_IUnknown(IUnknown *iface)
{
return CONTAINING_RECORD(iface, HttpProtocol, IUnknown_outer);
}
static inline HttpProtocol *impl_from_IInternetProtocolEx(IInternetProtocolEx *iface)
{
return CONTAINING_RECORD(iface, HttpProtocol, IInternetProtocolEx_iface);
@ -624,14 +631,13 @@ static const ProtocolVtbl AsyncProtocolVtbl = {
HttpProtocol_on_error
};
static HRESULT WINAPI HttpProtocol_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv)
static HRESULT WINAPI HttpProtocolUnk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
{
HttpProtocol *This = impl_from_IInternetProtocolEx(iface);
HttpProtocol *This = impl_from_IUnknown(iface);
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = &This->IInternetProtocolEx_iface;
*ppv = &This->IUnknown_outer;
}else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
*ppv = &This->IInternetProtocolEx_iface;
@ -650,28 +656,27 @@ static HRESULT WINAPI HttpProtocol_QueryInterface(IInternetProtocolEx *iface, RE
}else if(IsEqualGUID(&IID_IWinInetHttpInfo, riid)) {
TRACE("(%p)->(IID_IWinInetHttpInfo %p)\n", This, ppv);
*ppv = &This->IWinInetHttpInfo_iface;
}else {
*ppv = NULL;
WARN("not supported interface %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
if(*ppv) {
IInternetProtocolEx_AddRef(iface);
return S_OK;
}
WARN("not supported interface %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI HttpProtocol_AddRef(IInternetProtocolEx *iface)
static ULONG WINAPI HttpProtocolUnk_AddRef(IUnknown *iface)
{
HttpProtocol *This = impl_from_IInternetProtocolEx(iface);
HttpProtocol *This = impl_from_IUnknown(iface);
LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
return ref;
}
static ULONG WINAPI HttpProtocol_Release(IInternetProtocolEx *iface)
static ULONG WINAPI HttpProtocolUnk_Release(IUnknown *iface)
{
HttpProtocol *This = impl_from_IInternetProtocolEx(iface);
HttpProtocol *This = impl_from_IUnknown(iface);
LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
@ -686,6 +691,33 @@ static ULONG WINAPI HttpProtocol_Release(IInternetProtocolEx *iface)
return ref;
}
static const IUnknownVtbl HttpProtocolUnkVtbl = {
HttpProtocolUnk_QueryInterface,
HttpProtocolUnk_AddRef,
HttpProtocolUnk_Release
};
static HRESULT WINAPI HttpProtocol_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv)
{
HttpProtocol *This = impl_from_IInternetProtocolEx(iface);
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return IUnknown_QueryInterface(This->outer, riid, ppv);
}
static ULONG WINAPI HttpProtocol_AddRef(IInternetProtocolEx *iface)
{
HttpProtocol *This = impl_from_IInternetProtocolEx(iface);
TRACE("(%p)\n", This);
return IUnknown_AddRef(This->outer);
}
static ULONG WINAPI HttpProtocol_Release(IInternetProtocolEx *iface)
{
HttpProtocol *This = impl_from_IInternetProtocolEx(iface);
TRACE("(%p)\n", This);
return IUnknown_Release(This->outer);
}
static HRESULT WINAPI HttpProtocol_Start(IInternetProtocolEx *iface, LPCWSTR szUrl,
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
DWORD grfPI, HANDLE_PTR dwReserved)
@ -926,7 +958,7 @@ static const IWinInetHttpInfoVtbl WinInetHttpInfoVtbl = {
HttpInfo_QueryInfo
};
static HRESULT create_http_protocol(BOOL https, void **ppobj)
static HRESULT create_http_protocol(BOOL https, IUnknown *outer, void **ppobj)
{
HttpProtocol *ret;
@ -935,29 +967,31 @@ static HRESULT create_http_protocol(BOOL https, void **ppobj)
return E_OUTOFMEMORY;
ret->base.vtbl = &AsyncProtocolVtbl;
ret->IUnknown_outer.lpVtbl = &HttpProtocolUnkVtbl;
ret->IInternetProtocolEx_iface.lpVtbl = &HttpProtocolVtbl;
ret->IInternetPriority_iface.lpVtbl = &HttpPriorityVtbl;
ret->IWinInetHttpInfo_iface.lpVtbl = &WinInetHttpInfoVtbl;
ret->https = https;
ret->ref = 1;
ret->outer = outer ? outer : &ret->IUnknown_outer;
*ppobj = &ret->IInternetProtocolEx_iface;
*ppobj = &ret->IUnknown_outer;
URLMON_LockModule();
return S_OK;
}
HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
HRESULT HttpProtocol_Construct(IUnknown *outer, void **ppv)
{
TRACE("(%p %p)\n", pUnkOuter, ppobj);
TRACE("(%p %p)\n", outer, ppv);
return create_http_protocol(FALSE, ppobj);
return create_http_protocol(FALSE, outer, ppv);
}
HRESULT HttpSProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
HRESULT HttpSProtocol_Construct(IUnknown *outer, void **ppv)
{
TRACE("(%p %p)\n", pUnkOuter, ppobj);
TRACE("(%p %p)\n", outer, ppv);
return create_http_protocol(TRUE, ppobj);
return create_http_protocol(TRUE, outer, ppv);
}

View File

@ -4101,6 +4101,8 @@ START_TEST(protocol)
CloseHandle(event_continue_done);
test_com_aggregation(&CLSID_FileProtocol);
test_com_aggregation(&CLSID_HttpProtocol);
test_com_aggregation(&CLSID_HttpSProtocol);
OleUninitialize();
}