Jacek Caban : mshtml: Rename nsChannel:: content to content_type and clean up its handling.
Alexandre Julliard
julliard at winehq.org
Thu Mar 27 07:21:42 CDT 2008
Module: wine
Branch: master
Commit: 8abf7a8cc94f43266f1246e1c9df52e19559ded0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8abf7a8cc94f43266f1246e1c9df52e19559ded0
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Mar 26 15:24:03 2008 +0100
mshtml: Rename nsChannel::content to content_type and clean up its handling.
---
dlls/mshtml/mshtml_private.h | 30 +++++++++++++++++++++++++++++-
dlls/mshtml/navigate.c | 17 +++++------------
dlls/mshtml/nsio.c | 24 ++++++------------------
3 files changed, 40 insertions(+), 31 deletions(-)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 4253a87..151d266 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -241,7 +241,7 @@ typedef struct {
nsIInterfaceRequestor *notif_callback;
nsLoadFlags load_flags;
nsIURI *original_uri;
- char *content;
+ char *content_type;
char *charset;
} nsChannel;
@@ -568,6 +568,21 @@ static inline LPWSTR heap_strdupW(LPCWSTR str)
return ret;
}
+static inline char *heap_strdupA(const char *str)
+{
+ char *ret = NULL;
+
+ if(str) {
+ DWORD size;
+
+ size = strlen(str)+1;
+ ret = heap_alloc(size);
+ memcpy(ret, str, size);
+ }
+
+ return ret;
+}
+
static inline WCHAR *heap_strdupAtoW(const char *str)
{
LPWSTR ret = NULL;
@@ -583,6 +598,19 @@ static inline WCHAR *heap_strdupAtoW(const char *str)
return ret;
}
+static inline char *heap_strdupWtoA(LPCWSTR str)
+{
+ char *ret = NULL;
+
+ if(str) {
+ DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
+ ret = heap_alloc(size);
+ WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
+ }
+
+ return ret;
+}
+
HINSTANCE get_shdoclc(void);
extern HINSTANCE hInst;
diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c
index a0dc67f..8ae064c 100644
--- a/dlls/mshtml/navigate.c
+++ b/dlls/mshtml/navigate.c
@@ -884,17 +884,12 @@ static HRESULT nsChannelBSC_on_progress(BSCallback *bsc, ULONG status_code, LPCW
nsChannelBSC *This = NSCHANNELBSC_THIS(bsc);
switch(status_code) {
- case BINDSTATUS_MIMETYPEAVAILABLE: {
- int len;
-
+ case BINDSTATUS_MIMETYPEAVAILABLE:
if(!This->nschannel)
return S_OK;
- heap_free(This->nschannel->content);
- len = WideCharToMultiByte(CP_ACP, 0, status_text, -1, NULL, 0, NULL, NULL);
- This->nschannel->content = heap_alloc(len*sizeof(WCHAR));
- WideCharToMultiByte(CP_ACP, 0, status_text, -1, This->nschannel->content, -1, NULL, NULL);
- }
+ heap_free(This->nschannel->content_type);
+ This->nschannel->content_type = heap_strdupWtoA(status_text);
}
return S_OK;
@@ -958,10 +953,8 @@ HRESULT channelbsc_load_stream(nsChannelBSC *bscallback, IStream *stream)
add_nsrequest(bscallback);
- if(bscallback->nschannel) {
- bscallback->nschannel->content = heap_alloc(sizeof(text_html));
- memcpy(bscallback->nschannel->content, text_html, sizeof(text_html));
- }
+ if(bscallback->nschannel)
+ bscallback->nschannel->content_type = heap_strdupA(text_html);
hres = read_stream_data(bscallback, stream);
IBindStatusCallback_OnStopBinding(STATUSCLB(&bscallback->bsc), hres, ERROR_SUCCESS);
diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c
index b45bb08..f690344 100644
--- a/dlls/mshtml/nsio.c
+++ b/dlls/mshtml/nsio.c
@@ -209,7 +209,7 @@ static nsrefcnt NSAPI nsChannel_Release(nsIHttpChannel *iface)
nsIInterfaceRequestor_Release(This->notif_callback);
if(This->original_uri)
nsIURI_Release(This->original_uri);
- heap_free(This->content);
+ heap_free(This->content_type);
heap_free(This->charset);
heap_free(This);
}
@@ -468,8 +468,8 @@ static nsresult NSAPI nsChannel_GetContentType(nsIHttpChannel *iface, nsACString
TRACE("(%p)->(%p)\n", This, aContentType);
- if(This->content) {
- nsACString_SetData(aContentType, This->content);
+ if(This->content_type) {
+ nsACString_SetData(aContentType, This->content_type);
return S_OK;
}
@@ -688,13 +688,8 @@ static nsresult async_open_doc_uri(nsChannel *This, NSContainer *container,
channelbsc_set_channel(container->bscallback, This, listener, context);
if(container->doc && container->doc->mime) {
- DWORD len;
-
- heap_free(This->content);
-
- len = WideCharToMultiByte(CP_ACP, 0, container->doc->mime, -1, NULL, 0, NULL, NULL);
- This->content = heap_alloc(len);
- WideCharToMultiByte(CP_ACP, 0, container->doc->mime, -1, This->content, -1, NULL, NULL);
+ heap_free(This->content_type);
+ This->content_type = heap_strdupWtoA(container->doc->mime);
}
if(do_load_from_moniker_hack(This))
@@ -2155,20 +2150,13 @@ static nsresult NSAPI nsIOService_NewChannelFromURI(nsIIOService *iface, nsIURI
return channel ? NS_OK : NS_ERROR_UNEXPECTED;
}
- ret = heap_alloc(sizeof(nsChannel));
+ ret = heap_alloc_zero(sizeof(nsChannel));
ret->lpHttpChannelVtbl = &nsChannelVtbl;
ret->lpUploadChannelVtbl = &nsUploadChannelVtbl;
ret->ref = 1;
ret->channel = channel;
- ret->http_channel = NULL;
ret->uri = wine_uri;
- ret->post_data_stream = NULL;
- ret->load_group = NULL;
- ret->notif_callback = NULL;
- ret->load_flags = 0;
- ret->content = NULL;
- ret->charset = NULL;
nsIURI_AddRef(aURI);
ret->original_uri = aURI;
More information about the wine-cvs
mailing list