urlmon: Better implementation of bind stopping.

This commit is contained in:
Jacek Caban 2007-12-30 17:43:11 +01:00 committed by Alexandre Julliard
parent ed1c7f8135
commit 2f34d0093c
1 changed files with 22 additions and 6 deletions

View File

@ -52,6 +52,7 @@ typedef enum {
} download_state_t;
#define BINDING_LOCKED 0x0001
#define BINDING_STOPPED 0x0002
struct Binding {
const IBindingVtbl *lpBindingVtbl;
@ -74,6 +75,7 @@ struct Binding {
BOOL report_mime;
DWORD continue_call;
DWORD state;
HRESULT hres;
download_state_t download_state;
DWORD apartment_thread;
@ -310,6 +312,21 @@ static void mime_available(Binding *This, LPCWSTR mime, BOOL verify)
}
}
static void stop_binding(Binding *binding, HRESULT hres, LPCWSTR str)
{
if(binding->state & BINDING_LOCKED) {
IInternetProtocol_UnlockRequest(binding->protocol);
binding->state &= ~BINDING_LOCKED;
}
if(!(binding->state & BINDING_STOPPED)) {
binding->state |= BINDING_STOPPED;
IBindStatusCallback_OnStopBinding(binding->callback, hres, str);
binding->hres = hres;
}
}
#define STREAM_THIS(iface) DEFINE_THIS(ProtocolStream, Stream, iface)
static HRESULT WINAPI ProtocolStream_QueryInterface(IStream *iface,
@ -852,9 +869,8 @@ static void report_data(Binding *This, DWORD bscf, ULONG progress, ULONG progres
IBindStatusCallback_OnDataAvailable(This->callback, bscf, progress,
&formatetc, &This->stgmed);
if(This->download_state == END_DOWNLOAD) {
IBindStatusCallback_OnStopBinding(This->callback, S_OK, NULL);
}
if(This->download_state == END_DOWNLOAD)
stop_binding(This, S_OK, NULL);
}
typedef struct {
@ -1167,6 +1183,7 @@ static HRESULT Binding_Create(LPCWSTR url, IBindCtx *pbc, REFIID riid, Binding *
ret->state = 0;
ret->download_state = BEFORE_DOWNLOAD;
ret->task_queue_head = ret->task_queue_tail = NULL;
ret->hres = S_OK;
memset(&ret->bindinfo, 0, sizeof(BINDINFO));
ret->bindinfo.cbSize = sizeof(BINDINFO);
@ -1232,7 +1249,7 @@ static HRESULT start_binding(LPCWSTR url, IBindCtx *pbc, REFIID riid, Binding **
hres = IBindStatusCallback_OnStartBinding(binding->callback, 0, BINDING(binding));
if(FAILED(hres)) {
WARN("OnStartBinding failed: %08x\n", hres);
IBindStatusCallback_OnStopBinding(binding->callback, 0x800c0008, NULL);
stop_binding(binding, 0x800c0008, NULL);
IBinding_Release(BINDING(binding));
return hres;
}
@ -1245,8 +1262,7 @@ static HRESULT start_binding(LPCWSTR url, IBindCtx *pbc, REFIID riid, Binding **
if(FAILED(hres)) {
WARN("Start failed: %08x\n", hres);
IInternetProtocol_Terminate(binding->protocol, 0);
IBindStatusCallback_OnStopBinding(binding->callback, S_OK, NULL);
stop_binding(binding, hres, NULL);
IBinding_Release(BINDING(binding));
return hres;