urlmon: Depend on Read result in report_data.
This commit is contained in:
parent
f66b99db83
commit
c374936472
|
@ -55,6 +55,7 @@ typedef struct {
|
||||||
BYTE buf[1024*8];
|
BYTE buf[1024*8];
|
||||||
DWORD buf_size;
|
DWORD buf_size;
|
||||||
BOOL init_buf;
|
BOOL init_buf;
|
||||||
|
HRESULT hres;
|
||||||
} ProtocolStream;
|
} ProtocolStream;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -139,14 +140,13 @@ static task_header_t *pop_task(Binding *binding)
|
||||||
static void fill_stream_buffer(ProtocolStream *This)
|
static void fill_stream_buffer(ProtocolStream *This)
|
||||||
{
|
{
|
||||||
DWORD read = 0;
|
DWORD read = 0;
|
||||||
HRESULT hres;
|
|
||||||
|
|
||||||
if(sizeof(This->buf) == This->buf_size)
|
if(sizeof(This->buf) == This->buf_size)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hres = IInternetProtocol_Read(This->protocol, This->buf+This->buf_size,
|
This->hres = IInternetProtocol_Read(This->protocol, This->buf+This->buf_size,
|
||||||
sizeof(This->buf)-This->buf_size, &read);
|
sizeof(This->buf)-This->buf_size, &read);
|
||||||
if(SUCCEEDED(hres)) {
|
if(SUCCEEDED(This->hres)) {
|
||||||
This->buf_size += read;
|
This->buf_size += read;
|
||||||
This->init_buf = TRUE;
|
This->init_buf = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -389,7 +389,6 @@ static HRESULT WINAPI ProtocolStream_Read(IStream *iface, void *pv,
|
||||||
{
|
{
|
||||||
ProtocolStream *This = STREAM_THIS(iface);
|
ProtocolStream *This = STREAM_THIS(iface);
|
||||||
DWORD read = 0, pread = 0;
|
DWORD read = 0, pread = 0;
|
||||||
HRESULT hres;
|
|
||||||
|
|
||||||
TRACE("(%p)->(%p %d %p)\n", This, pv, cb, pcbRead);
|
TRACE("(%p)->(%p %d %p)\n", This, pv, cb, pcbRead);
|
||||||
|
|
||||||
|
@ -411,13 +410,13 @@ static HRESULT WINAPI ProtocolStream_Read(IStream *iface, void *pv,
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
hres = IInternetProtocol_Read(This->protocol, (PBYTE)pv+read, cb-read, &pread);
|
This->hres = IInternetProtocol_Read(This->protocol, (PBYTE)pv+read, cb-read, &pread);
|
||||||
*pcbRead = read + pread;
|
*pcbRead = read + pread;
|
||||||
|
|
||||||
if(hres == E_PENDING)
|
if(This->hres == E_PENDING)
|
||||||
return E_PENDING;
|
return E_PENDING;
|
||||||
else if(FAILED(hres))
|
else if(FAILED(This->hres))
|
||||||
FIXME("Read failed: %08x\n", hres);
|
FIXME("Read failed: %08x\n", This->hres);
|
||||||
|
|
||||||
return read || pread ? S_OK : S_FALSE;
|
return read || pread ? S_OK : S_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -533,6 +532,7 @@ static ProtocolStream *create_stream(IInternetProtocol *protocol)
|
||||||
ret->ref = 1;
|
ret->ref = 1;
|
||||||
ret->buf_size = 0;
|
ret->buf_size = 0;
|
||||||
ret->init_buf = FALSE;
|
ret->init_buf = FALSE;
|
||||||
|
ret->hres = S_OK;
|
||||||
|
|
||||||
IInternetProtocol_AddRef(protocol);
|
IInternetProtocol_AddRef(protocol);
|
||||||
ret->protocol = protocol;
|
ret->protocol = protocol;
|
||||||
|
@ -859,7 +859,7 @@ static void report_data(Binding *This, DWORD bscf, ULONG progress, ULONG progres
|
||||||
BINDSTATUS_BEGINDOWNLOADDATA, This->url);
|
BINDSTATUS_BEGINDOWNLOADDATA, This->url);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bscf & BSCF_LASTDATANOTIFICATION) {
|
if(This->stream->hres == S_FALSE || (bscf & BSCF_LASTDATANOTIFICATION)) {
|
||||||
IBindStatusCallback_OnProgress(This->callback, progress, progress_max,
|
IBindStatusCallback_OnProgress(This->callback, progress, progress_max,
|
||||||
BINDSTATUS_ENDDOWNLOADDATA, This->url);
|
BINDSTATUS_ENDDOWNLOADDATA, This->url);
|
||||||
}
|
}
|
||||||
|
@ -874,7 +874,7 @@ static void report_data(Binding *This, DWORD bscf, ULONG progress, ULONG progres
|
||||||
IBindStatusCallback_OnDataAvailable(This->callback, bscf, This->stream->buf_size,
|
IBindStatusCallback_OnDataAvailable(This->callback, bscf, This->stream->buf_size,
|
||||||
&formatetc, &This->stgmed);
|
&formatetc, &This->stgmed);
|
||||||
|
|
||||||
if(bscf & BSCF_LASTDATANOTIFICATION) {
|
if(This->stream->hres == S_FALSE) {
|
||||||
This->download_state = END_DOWNLOAD;
|
This->download_state = END_DOWNLOAD;
|
||||||
IBindStatusCallback_OnStopBinding(This->callback, S_OK, NULL);
|
IBindStatusCallback_OnStopBinding(This->callback, S_OK, NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue