urlmon: Optimize registering urlmon protocols.
This commit is contained in:
parent
ae8457e431
commit
2b90a7d6d5
|
@ -101,6 +101,58 @@ static HRESULT get_protocol_cf(LPCWSTR schema, DWORD schema_len, CLSID *pclsid,
|
|||
return CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)ret);
|
||||
}
|
||||
|
||||
static HRESULT register_namespace(IClassFactory *cf, REFIID clsid, LPCWSTR protocol, BOOL urlmon_protocol)
|
||||
{
|
||||
name_space *new_name_space;
|
||||
|
||||
new_name_space = heap_alloc(sizeof(name_space));
|
||||
|
||||
if(!urlmon_protocol)
|
||||
IClassFactory_AddRef(cf);
|
||||
new_name_space->cf = cf;
|
||||
new_name_space->clsid = *clsid;
|
||||
new_name_space->protocol = heap_strdupW(protocol);
|
||||
|
||||
new_name_space->next = name_space_list;
|
||||
name_space_list = new_name_space;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT unregister_namespace(IClassFactory *cf, LPCWSTR protocol, BOOL urlmon_protocol)
|
||||
{
|
||||
name_space *iter, *last = NULL;
|
||||
|
||||
for(iter = name_space_list; iter; iter = iter->next) {
|
||||
if(iter->cf == cf && !strcmpW(iter->protocol, protocol))
|
||||
break;
|
||||
last = iter;
|
||||
}
|
||||
|
||||
if(iter) {
|
||||
if(last)
|
||||
last->next = iter->next;
|
||||
else
|
||||
name_space_list = iter->next;
|
||||
|
||||
if(!urlmon_protocol)
|
||||
IClassFactory_Release(iter->cf);
|
||||
heap_free(iter->protocol);
|
||||
heap_free(iter);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
void register_urlmon_namespace(IClassFactory *cf, REFIID clsid, LPCWSTR protocol, BOOL do_register)
|
||||
{
|
||||
if(do_register)
|
||||
register_namespace(cf, clsid, protocol, TRUE);
|
||||
else
|
||||
unregister_namespace(cf, protocol, TRUE);
|
||||
}
|
||||
|
||||
BOOL is_registered_protocol(LPCWSTR url)
|
||||
{
|
||||
DWORD schema_len;
|
||||
|
@ -209,8 +261,6 @@ static HRESULT WINAPI InternetSession_RegisterNameSpace(IInternetSession *iface,
|
|||
IClassFactory *pCF, REFCLSID rclsid, LPCWSTR pwzProtocol, ULONG cPatterns,
|
||||
const LPCWSTR *ppwzPatterns, DWORD dwReserved)
|
||||
{
|
||||
name_space *new_name_space;
|
||||
|
||||
TRACE("(%p %s %s %d %p %d)\n", pCF, debugstr_guid(rclsid), debugstr_w(pwzProtocol),
|
||||
cPatterns, ppwzPatterns, dwReserved);
|
||||
|
||||
|
@ -222,47 +272,18 @@ static HRESULT WINAPI InternetSession_RegisterNameSpace(IInternetSession *iface,
|
|||
if(!pCF || !pwzProtocol)
|
||||
return E_INVALIDARG;
|
||||
|
||||
new_name_space = heap_alloc(sizeof(name_space));
|
||||
|
||||
IClassFactory_AddRef(pCF);
|
||||
new_name_space->cf = pCF;
|
||||
new_name_space->clsid = *rclsid;
|
||||
new_name_space->protocol = heap_strdupW(pwzProtocol);
|
||||
|
||||
new_name_space->next = name_space_list;
|
||||
name_space_list = new_name_space;
|
||||
return S_OK;
|
||||
return register_namespace(pCF, rclsid, pwzProtocol, FALSE);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI InternetSession_UnregisterNameSpace(IInternetSession *iface,
|
||||
IClassFactory *pCF, LPCWSTR pszProtocol)
|
||||
{
|
||||
name_space *iter, *last = NULL;
|
||||
|
||||
TRACE("(%p %s)\n", pCF, debugstr_w(pszProtocol));
|
||||
|
||||
if(!pCF || !pszProtocol)
|
||||
return E_INVALIDARG;
|
||||
|
||||
for(iter = name_space_list; iter; iter = iter->next) {
|
||||
if(iter->cf == pCF && !strcmpW(iter->protocol, pszProtocol))
|
||||
break;
|
||||
last = iter;
|
||||
}
|
||||
|
||||
if(!iter)
|
||||
return S_OK;
|
||||
|
||||
if(last)
|
||||
last->next = iter->next;
|
||||
else
|
||||
name_space_list = iter->next;
|
||||
|
||||
IClassFactory_Release(iter->cf);
|
||||
heap_free(iter->protocol);
|
||||
heap_free(iter);
|
||||
|
||||
return S_OK;
|
||||
return unregister_namespace(pCF, pszProtocol, FALSE);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI InternetSession_RegisterMimeFilter(IInternetSession *iface,
|
||||
|
|
|
@ -210,31 +210,14 @@ static const struct object_creation_info object_creation[] =
|
|||
|
||||
static void init_session(BOOL init)
|
||||
{
|
||||
IInternetSession *session;
|
||||
int i;
|
||||
|
||||
CoInternetGetSession(0, &session, 0);
|
||||
|
||||
for(i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++) {
|
||||
if(object_creation[i].protocol) {
|
||||
if(init)
|
||||
{
|
||||
IInternetSession_RegisterNameSpace(session, object_creation[i].cf,
|
||||
object_creation[i].clsid, object_creation[i].protocol, 0, NULL, 0);
|
||||
/* make sure that the AddRef on the class factory doesn't keep us loaded */
|
||||
URLMON_UnlockModule();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* make sure that the Release on the class factory doesn't unload us */
|
||||
URLMON_LockModule();
|
||||
IInternetSession_UnregisterNameSpace(session, object_creation[i].cf,
|
||||
object_creation[i].protocol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IInternetSession_Release(session);
|
||||
if(object_creation[i].protocol)
|
||||
register_urlmon_namespace(object_creation[i].cf, object_creation[i].clsid,
|
||||
object_creation[i].protocol, init);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
|
|
@ -68,6 +68,7 @@ void UMCloseCacheFileStream(IUMCacheStream *pstr);
|
|||
IInternetProtocolInfo *get_protocol_info(LPCWSTR url);
|
||||
HRESULT get_protocol_handler(LPCWSTR url, CLSID *clsid, IClassFactory **ret);
|
||||
BOOL is_registered_protocol(LPCWSTR);
|
||||
void register_urlmon_namespace(IClassFactory*,REFIID,LPCWSTR,BOOL);
|
||||
|
||||
HRESULT bind_to_storage(LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv);
|
||||
HRESULT bind_to_object(IMoniker *mon, LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv);
|
||||
|
|
Loading…
Reference in New Issue