mshtml: Moved IStream::Read calls to separated function.
This commit is contained in:
parent
9f7e450c4b
commit
f011ccedea
|
@ -48,6 +48,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
||||||
#define UTF16_STR "utf-16"
|
#define UTF16_STR "utf-16"
|
||||||
|
|
||||||
static const WCHAR emptyW[] = {0};
|
static const WCHAR emptyW[] = {0};
|
||||||
|
static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
|
||||||
|
|
||||||
struct nsProtocolStream {
|
struct nsProtocolStream {
|
||||||
nsIInputStream nsIInputStream_iface;
|
nsIInputStream nsIInputStream_iface;
|
||||||
|
@ -614,6 +615,16 @@ static void init_bscallback(BSCallback *This, const BSCallbackVtbl *vtbl, IMonik
|
||||||
This->mon = mon;
|
This->mon = mon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT read_stream(BSCallback *This, IStream *stream, void *buf, DWORD size, DWORD *ret_size)
|
||||||
|
{
|
||||||
|
DWORD read_size = 0;
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
hres = IStream_Read(stream, buf, size, &read_size);
|
||||||
|
This->readed += (*ret_size = read_size);
|
||||||
|
return hres;
|
||||||
|
}
|
||||||
|
|
||||||
static void parse_content_type(nsChannelBSC *This, const WCHAR *value)
|
static void parse_content_type(nsChannelBSC *This, const WCHAR *value)
|
||||||
{
|
{
|
||||||
const WCHAR *ptr;
|
const WCHAR *ptr;
|
||||||
|
@ -820,9 +831,7 @@ static HRESULT BufferBSC_read_data(BSCallback *bsc, IStream *stream)
|
||||||
This->buf = heap_realloc(This->buf, This->size);
|
This->buf = heap_realloc(This->buf, This->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
readed = 0;
|
hres = read_stream(&This->bsc, stream, This->buf+This->bsc.readed, This->size-This->bsc.readed, &readed);
|
||||||
hres = IStream_Read(stream, This->buf+This->bsc.readed, This->size-This->bsc.readed, &readed);
|
|
||||||
This->bsc.readed += readed;
|
|
||||||
}while(hres == S_OK);
|
}while(hres == S_OK);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -1031,8 +1040,6 @@ static void on_stop_nsrequest(nsChannelBSC *This, HRESULT result)
|
||||||
|
|
||||||
static HRESULT read_stream_data(nsChannelBSC *This, IStream *stream)
|
static HRESULT read_stream_data(nsChannelBSC *This, IStream *stream)
|
||||||
{
|
{
|
||||||
static const WCHAR mimeTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
|
|
||||||
|
|
||||||
DWORD read;
|
DWORD read;
|
||||||
nsresult nsres;
|
nsresult nsres;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
@ -1041,8 +1048,7 @@ static HRESULT read_stream_data(nsChannelBSC *This, IStream *stream)
|
||||||
BYTE buf[1024];
|
BYTE buf[1024];
|
||||||
|
|
||||||
do {
|
do {
|
||||||
read = 0;
|
hres = read_stream(&This->bsc, stream, buf, sizeof(buf), &read);
|
||||||
hres = IStream_Read(stream, buf, sizeof(buf), &read);
|
|
||||||
}while(hres == S_OK && read);
|
}while(hres == S_OK && read);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -1052,15 +1058,16 @@ static HRESULT read_stream_data(nsChannelBSC *This, IStream *stream)
|
||||||
This->nsstream = create_nsprotocol_stream();
|
This->nsstream = create_nsprotocol_stream();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
read = 0;
|
BOOL first_read = !This->bsc.readed;
|
||||||
hres = IStream_Read(stream, This->nsstream->buf+This->nsstream->buf_size,
|
|
||||||
|
hres = read_stream(&This->bsc, stream, This->nsstream->buf+This->nsstream->buf_size,
|
||||||
sizeof(This->nsstream->buf)-This->nsstream->buf_size, &read);
|
sizeof(This->nsstream->buf)-This->nsstream->buf_size, &read);
|
||||||
if(!read)
|
if(!read)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
This->nsstream->buf_size += read;
|
This->nsstream->buf_size += read;
|
||||||
|
|
||||||
if(!This->bsc.readed) {
|
if(first_read) {
|
||||||
if(This->nsstream->buf_size >= 2
|
if(This->nsstream->buf_size >= 2
|
||||||
&& (BYTE)This->nsstream->buf[0] == 0xff
|
&& (BYTE)This->nsstream->buf[0] == 0xff
|
||||||
&& (BYTE)This->nsstream->buf[1] == 0xfe)
|
&& (BYTE)This->nsstream->buf[1] == 0xfe)
|
||||||
|
@ -1075,7 +1082,7 @@ static HRESULT read_stream_data(nsChannelBSC *This, IStream *stream)
|
||||||
WCHAR *mime;
|
WCHAR *mime;
|
||||||
|
|
||||||
hres = FindMimeFromData(NULL, NULL, This->nsstream->buf, This->nsstream->buf_size,
|
hres = FindMimeFromData(NULL, NULL, This->nsstream->buf, This->nsstream->buf_size,
|
||||||
This->is_doc_channel ? mimeTextHtml : NULL, 0, &mime, 0);
|
This->is_doc_channel ? text_htmlW : NULL, 0, &mime, 0);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
||||||
|
@ -1090,8 +1097,6 @@ static HRESULT read_stream_data(nsChannelBSC *This, IStream *stream)
|
||||||
on_start_nsrequest(This);
|
on_start_nsrequest(This);
|
||||||
}
|
}
|
||||||
|
|
||||||
This->bsc.readed += This->nsstream->buf_size;
|
|
||||||
|
|
||||||
nsres = nsIStreamListener_OnDataAvailable(This->nslistener,
|
nsres = nsIStreamListener_OnDataAvailable(This->nslistener,
|
||||||
(nsIRequest*)&This->nschannel->nsIHttpChannel_iface, This->nscontext,
|
(nsIRequest*)&This->nschannel->nsIHttpChannel_iface, This->nscontext,
|
||||||
&This->nsstream->nsIInputStream_iface, This->bsc.readed-This->nsstream->buf_size,
|
&This->nsstream->nsIInputStream_iface, This->bsc.readed-This->nsstream->buf_size,
|
||||||
|
|
Loading…
Reference in New Issue