Commit 7247eaa1 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Allow async tasks to have custom destructors.

parent 7a0600dc
......@@ -1847,7 +1847,7 @@ static HRESULT WINAPI HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow *iface,
task->window = This;
task->bscallback = bsc;
task->mon = mon;
push_task(&task->header, navigate_proc, This->task_magic);
push_task(&task->header, navigate_proc, NULL, This->task_magic);
/* Silently and repeated when real loading starts? */
This->readystate = READYSTATE_LOADING;
......@@ -1866,7 +1866,7 @@ static HRESULT WINAPI HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow *iface,
IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
task->window = This;
task->uri = uri;
push_task(&task->header, navigate_javascript_proc, This->task_magic);
push_task(&task->header, navigate_javascript_proc, NULL, This->task_magic);
/* Why silently? */
This->readystate = READYSTATE_COMPLETE;
......
......@@ -817,6 +817,7 @@ typedef void (*task_proc_t)(task_t*);
struct task_t {
LONG target_magic;
task_proc_t proc;
task_proc_t destr;
struct task_t *next;
};
......@@ -836,7 +837,7 @@ thread_data_t *get_thread_data(BOOL) DECLSPEC_HIDDEN;
HWND get_thread_hwnd(void) DECLSPEC_HIDDEN;
LONG get_task_target_magic(void) DECLSPEC_HIDDEN;
void push_task(task_t*,task_proc_t,LONG) DECLSPEC_HIDDEN;
void push_task(task_t*,task_proc_t,task_proc_t,LONG) DECLSPEC_HIDDEN;
void remove_target_tasks(LONG) DECLSPEC_HIDDEN;
DWORD set_task_timer(HTMLDocument*,DWORD,BOOL,IDispatch*) DECLSPEC_HIDDEN;
......
......@@ -1242,7 +1242,7 @@ static HRESULT async_stop_request(nsChannelBSC *This)
IBindStatusCallback_AddRef(&This->bsc.IBindStatusCallback_iface);
task->bsc = This;
push_task(&task->header, stop_request_proc, This->bsc.doc->basedoc.doc_obj->basedoc.task_magic);
push_task(&task->header, stop_request_proc, NULL, This->bsc.doc->basedoc.doc_obj->basedoc.task_magic);
return S_OK;
}
......@@ -1606,7 +1606,7 @@ HRESULT async_start_doc_binding(HTMLWindow *window, nsChannelBSC *bscallback)
task->bscallback = bscallback;
IBindStatusCallback_AddRef(&bscallback->bsc.IBindStatusCallback_iface);
push_task(&task->header, start_doc_binding_proc, window->task_magic);
push_task(&task->header, start_doc_binding_proc, NULL, window->task_magic);
return S_OK;
}
......
......@@ -925,7 +925,7 @@ static nsresult async_open(nsChannel *This, HTMLWindow *window, BOOL is_doc_chan
task->doc = window->doc;
task->bscallback = bscallback;
push_task(&task->header, start_binding_proc, window->doc->basedoc.task_magic);
push_task(&task->header, start_binding_proc, NULL, window->doc->basedoc.task_magic);
}
return NS_OK;
......
......@@ -296,14 +296,14 @@ HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, nsChannel
task = heap_alloc(sizeof(docobj_task_t));
task->doc = This->doc_obj;
push_task(&task->header, set_progress_proc, This->doc_obj->basedoc.task_magic);
push_task(&task->header, set_progress_proc, NULL, This->doc_obj->basedoc.task_magic);
}
download_task = heap_alloc(sizeof(download_proc_task_t));
download_task->doc = This->doc_obj;
download_task->set_download = set_download;
download_task->url = url;
push_task(&download_task->header, set_downloading_proc, This->doc_obj->basedoc.task_magic);
push_task(&download_task->header, set_downloading_proc, NULL, This->doc_obj->basedoc.task_magic);
return S_OK;
}
......
......@@ -47,12 +47,18 @@ typedef struct {
struct list entry;
} task_timer_t;
void push_task(task_t *task, task_proc_t proc, LONG magic)
static void default_task_destr(task_t *task)
{
heap_free(task);
}
void push_task(task_t *task, task_proc_t proc, task_proc_t destr, LONG magic)
{
thread_data_t *thread_data = get_thread_data(TRUE);
task->target_magic = magic;
task->proc = proc;
task->destr = destr ? destr : default_task_destr;
task->next = NULL;
if(thread_data->task_queue_tail)
......@@ -266,7 +272,7 @@ static LRESULT WINAPI hidden_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
break;
task->proc(task);
heap_free(task);
task->destr(task);
}
return 0;
......
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