Re: PassthruAPP question - when connection ends?



Ok so I've created this function to notify about start:

HRESULT CTestAPP::OnStart(LPCWSTR szUrl,
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
DWORD grfPI, HANDLE_PTR dwReserved, IInternetProtocol* pTargetProtocol)
{
HRESULT hr =
((PassthroughAPP::CInternetProtocol<TestStartPolicy>*)this)->OnStart(szUrl,
pOIProtSink,pOIBindInfo,grfPI,dwReserved,pTargetProtocol);

PROTOCOLDATA pd;
pd.grfFlags = PD_FORCE_SWITCH;
pd.dwState = -1234;
m_internetSink.Switch(&pd);
return hr;
}

- it works.
so I've created this to notify about end (I'll do the same for Abort) :


STDMETHODIMP CTestAPP::Terminate(DWORD dwOptions)
{
PROTOCOLDATA pd;
pd.grfFlags = PD_FORCE_SWITCH;
pd.dwState = -1235;
pd.pData = 0;
pd.cbData = 0;
m_internetSink.Switch(&pd);
return S_OK;
}

but the problem is that when I create Terminate function, something goes
wrong and object implementing IOleClientSite is not released when webbrowser
is destroyed (ref count finished at 1).
Is there something I should do in Terminate/Abort?

Thank you!

PS. there are also some Continue(PROTOCOLDATA) calls not done by me (before
report data). So is switch/contiunue used also by urlmon itself?

"Igor Tandetnik" wrote:

rrrado <rrrado@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I've just placed TRASEs to 2 Continue() functions implemented in your
APP. One is called and second is not.

You want the one that takes PROTOCOLDATA*. I forgot about the other one:
it's a member of IInternetThreadSwitch which the built-in HTTP protocol
implements (so I've also implemented it for completeness), but I haven't
seen it ever queried for or called. You can safely ignore its existence.

So when I call Switch() from CTestAPP::FinalConstruct() /
FinalRelease()

You can't call it from FinalConstruct - you don't yet have
IInternetProtocolSink pointer to call it on. And by FinalRelease, I
believe IInternetProtocolSink pointer will already be released. I
suggest you call it in Start.

will I receive Continue() from main browser thread
even for downloads started in worker threads?

Correct. Don't forget to specify PD_FORCE_SWITCH flag.

The Switch() is not well documented in msdn, I could not find any
documantation about structure PROTOCOLDATA only this :
http://msdn2.microsoft.com/en-us/library/aa767745.aspx
and it explains nothing.

You can put whatever you want in there. UrlMon will simply pass the
pointer back to you. It doesn't interpret the contents, apart from
grfFlags member.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925



.