Commit 2e62330c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Move setting protocol_sink to separated function.

parent c0361750
......@@ -105,9 +105,8 @@ static ULONG WINAPI BindProtocol_Release(IInternetProtocol *iface)
IInternetProtocol_Release(This->protocol);
if(This->bind_info)
IInternetBindInfo_Release(This->bind_info);
if(This->protocol_sink)
IInternetProtocolSink_Release(This->protocol_sink);
set_binding_sink(PROTOCOL(This), NULL);
heap_free(This);
URLMON_UnlockModule();
......@@ -172,10 +171,7 @@ static HRESULT WINAPI BindProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
IInternetBindInfo_AddRef(pOIBindInfo);
This->bind_info = pOIBindInfo;
IInternetProtocolSink_AddRef(pOIProtSink);
This->protocol_sink = pOIProtSink;
IInternetProtocolSink_QueryInterface(pOIProtSink, &IID_IServiceProvider, (void**)&This->service_provider);
set_binding_sink(PROTOCOL(This), pOIProtSink);
hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority, (void**)&priority);
if(SUCCEEDED(hres)) {
......@@ -268,6 +264,25 @@ static HRESULT WINAPI BindProtocol_UnlockRequest(IInternetProtocol *iface)
return IInternetProtocol_UnlockRequest(This->protocol);
}
void set_binding_sink(IInternetProtocol *bind_protocol, IInternetProtocolSink *sink)
{
BindProtocol *This = PROTOCOL_THIS(bind_protocol);
IInternetProtocolSink *prev_sink;
IServiceProvider *service_provider = NULL;
if(sink)
IInternetProtocolSink_AddRef(sink);
prev_sink = InterlockedExchangePointer((void**)&This->protocol_sink, sink);
if(prev_sink)
IInternetProtocolSink_Release(prev_sink);
if(sink)
IInternetProtocolSink_QueryInterface(sink, &IID_IServiceProvider, (void**)&service_provider);
service_provider = InterlockedExchangePointer((void**)&This->service_provider, service_provider);
if(service_provider)
IServiceProvider_Release(service_provider);
}
#undef PROTOCOL_THIS
static const IInternetProtocolVtbl BindProtocolVtbl = {
......
......@@ -71,6 +71,7 @@ HRESULT get_protocol_handler(LPCWSTR url, CLSID *clsid, IClassFactory **ret);
HRESULT start_binding(LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv);
HRESULT create_binding_protocol(LPCWSTR url, IInternetProtocol **protocol);
void set_binding_sink(IInternetProtocol *bind_protocol, IInternetProtocolSink *sink);
static inline void *heap_alloc(size_t len)
{
......
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