From 7c77c57ab85ee03d68b54161aa4410d3c2e94486 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 2 Mar 2009 03:19:44 +0100 Subject: [PATCH] urlmon: Moved HttpProtocol::[Lock|Unlock]Request implementation to generic Protocol object. --- dlls/urlmon/Makefile.in | 1 + dlls/urlmon/http.c | 14 ++----------- dlls/urlmon/protocol.c | 44 +++++++++++++++++++++++++++++++++++++++ dlls/urlmon/urlmon_main.h | 3 +++ 4 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 dlls/urlmon/protocol.c diff --git a/dlls/urlmon/Makefile.in b/dlls/urlmon/Makefile.in index d853541e096..0a9497c517b 100644 --- a/dlls/urlmon/Makefile.in +++ b/dlls/urlmon/Makefile.in @@ -17,6 +17,7 @@ C_SRCS = \ http.c \ internet.c \ mk.c \ + protocol.c \ regsvr.c \ sec_mgr.c \ session.c \ diff --git a/dlls/urlmon/http.c b/dlls/urlmon/http.c index 87d2036167a..ab5aa38d63b 100644 --- a/dlls/urlmon/http.c +++ b/dlls/urlmon/http.c @@ -827,10 +827,7 @@ static HRESULT WINAPI HttpProtocol_LockRequest(IInternetProtocol *iface, DWORD d TRACE("(%p)->(%08x)\n", This, dwOptions); - if (!InternetLockRequestFile(This->base.request, &This->base.lock)) - WARN("InternetLockRequest failed: %d\n", GetLastError()); - - return S_OK; + return protocol_lock_request(&This->base); } static HRESULT WINAPI HttpProtocol_UnlockRequest(IInternetProtocol *iface) @@ -839,14 +836,7 @@ static HRESULT WINAPI HttpProtocol_UnlockRequest(IInternetProtocol *iface) TRACE("(%p)\n", This); - if (This->base.lock) - { - if (!InternetUnlockRequestFile(This->base.lock)) - WARN("InternetUnlockRequest failed: %d\n", GetLastError()); - This->base.lock = 0; - } - - return S_OK; + return protocol_unlock_request(&This->base); } #undef PROTOCOL_THIS diff --git a/dlls/urlmon/protocol.c b/dlls/urlmon/protocol.c new file mode 100644 index 00000000000..b25c9dedac0 --- /dev/null +++ b/dlls/urlmon/protocol.c @@ -0,0 +1,44 @@ +/* + * Copyright 2007 Misha Koshelev + * Copyright 2009 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "urlmon_main.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(urlmon); + +HRESULT protocol_lock_request(Protocol *protocol) +{ + if (!InternetLockRequestFile(protocol->request, &protocol->lock)) + WARN("InternetLockRequest failed: %d\n", GetLastError()); + + return S_OK; +} + +HRESULT protocol_unlock_request(Protocol *protocol) +{ + if(!protocol->lock) + return S_OK; + + if(!InternetUnlockRequestFile(protocol->lock)) + WARN("InternetUnlockRequest failed: %d\n", GetLastError()); + protocol->lock = 0; + + return S_OK; +} diff --git a/dlls/urlmon/urlmon_main.h b/dlls/urlmon/urlmon_main.h index 36862d1570f..906cd315122 100644 --- a/dlls/urlmon/urlmon_main.h +++ b/dlls/urlmon/urlmon_main.h @@ -98,6 +98,9 @@ typedef struct { LONG priority; } Protocol; +HRESULT protocol_lock_request(Protocol*); +HRESULT protocol_unlock_request(Protocol*); + static inline void *heap_alloc(size_t len) { return HeapAlloc(GetProcessHeap(), 0, len);