зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1367885: Backed out changeset 3f6e08c5233f for bc4 bustage on a CLOSED TREE; r=backout
MozReview-Commit-ID: 4CDliBImLR7
This commit is contained in:
Родитель
0fdef67a82
Коммит
ec02e78c40
|
@ -25,31 +25,32 @@ namespace mscom {
|
||||||
|
|
||||||
/* static */ HRESULT
|
/* static */ HRESULT
|
||||||
Interceptor::Create(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink,
|
Interceptor::Create(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink,
|
||||||
REFIID aInitialIid, void** aOutInterface)
|
REFIID aIid, void** aOutput)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aOutInterface && aTarget && aSink);
|
MOZ_ASSERT(aOutput && aTarget && aSink);
|
||||||
if (!aOutInterface) {
|
if (!aOutput) {
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
*aOutInterface = nullptr;
|
*aOutput = nullptr;
|
||||||
|
|
||||||
if (!aTarget || !aSink) {
|
if (!aTarget || !aSink) {
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Interceptor> intcpt(new Interceptor(aSink));
|
RefPtr<WeakReferenceSupport> intcpt(new Interceptor(Move(aTarget), aSink));
|
||||||
return intcpt->GetInitialInterceptorForIID(aInitialIid, Move(aTarget),
|
return intcpt->QueryInterface(aIid, aOutput);
|
||||||
aOutInterface);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Interceptor::Interceptor(IInterceptorSink* aSink)
|
Interceptor::Interceptor(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink)
|
||||||
: WeakReferenceSupport(WeakReferenceSupport::Flags::eDestroyOnMainThread)
|
: WeakReferenceSupport(WeakReferenceSupport::Flags::eDestroyOnMainThread)
|
||||||
|
, mTarget(Move(aTarget))
|
||||||
, mEventSink(aSink)
|
, mEventSink(aSink)
|
||||||
, mMutex("mozilla::mscom::Interceptor::mMutex")
|
, mMutex("mozilla::mscom::Interceptor::mMutex")
|
||||||
, mStdMarshal(nullptr)
|
, mStdMarshal(nullptr)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aSink);
|
MOZ_ASSERT(aSink);
|
||||||
|
MOZ_ASSERT(!IsProxy(mTarget.get()));
|
||||||
RefPtr<IWeakReference> weakRef;
|
RefPtr<IWeakReference> weakRef;
|
||||||
if (SUCCEEDED(GetWeakReference(getter_AddRefs(weakRef)))) {
|
if (SUCCEEDED(GetWeakReference(getter_AddRefs(weakRef)))) {
|
||||||
aSink->SetInterceptor(weakRef);
|
aSink->SetInterceptor(weakRef);
|
||||||
|
@ -204,55 +205,6 @@ Interceptor::CreateInterceptor(REFIID aIid, IUnknown* aOuter, IUnknown** aOutput
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT
|
|
||||||
Interceptor::GetInitialInterceptorForIID(REFIID aTargetIid,
|
|
||||||
STAUniquePtr<IUnknown> aTarget,
|
|
||||||
void** aOutInterceptor)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(aOutInterceptor);
|
|
||||||
MOZ_ASSERT(aTargetIid != IID_IUnknown && aTargetIid != IID_IMarshal);
|
|
||||||
MOZ_ASSERT(!IsProxy(aTarget.get()));
|
|
||||||
|
|
||||||
// Raise the refcount for stabilization purposes during aggregation
|
|
||||||
RefPtr<IUnknown> kungFuDeathGrip(static_cast<IUnknown*>(
|
|
||||||
static_cast<WeakReferenceSupport*>(this)));
|
|
||||||
|
|
||||||
RefPtr<IUnknown> unkInterceptor;
|
|
||||||
HRESULT hr = CreateInterceptor(aTargetIid, kungFuDeathGrip,
|
|
||||||
getter_AddRefs(unkInterceptor));
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<ICallInterceptor> interceptor;
|
|
||||||
hr = unkInterceptor->QueryInterface(IID_ICallInterceptor,
|
|
||||||
getter_AddRefs(interceptor));
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = interceptor->RegisterSink(mEventSink);
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// mTarget is a weak reference to aTarget. This is safe because we transfer
|
|
||||||
// ownership of aTarget into mInterceptorMap which remains live for the
|
|
||||||
// lifetime of this Interceptor.
|
|
||||||
mTarget = ToInterceptorTargetPtr(aTarget);
|
|
||||||
|
|
||||||
// Now we transfer aTarget's ownership into mInterceptorMap.
|
|
||||||
mInterceptorMap.AppendElement(MapEntry(aTargetIid,
|
|
||||||
unkInterceptor,
|
|
||||||
aTarget.release()));
|
|
||||||
|
|
||||||
if (mEventSink->MarshalAs(aTargetIid) == aTargetIid) {
|
|
||||||
return unkInterceptor->QueryInterface(aTargetIid, aOutInterceptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetInterceptorForIID(aTargetIid, aOutInterceptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method contains the core guts of the handling of QueryInterface calls
|
* This method contains the core guts of the handling of QueryInterface calls
|
||||||
* that are delegated to us from the ICallInterceptor.
|
* that are delegated to us from the ICallInterceptor.
|
||||||
|
|
|
@ -67,7 +67,7 @@ class Interceptor final : public WeakReferenceSupport
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static HRESULT Create(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink,
|
static HRESULT Create(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink,
|
||||||
REFIID aInitialIid, void** aOutInterface);
|
REFIID aIid, void** aOutput);
|
||||||
|
|
||||||
// IUnknown
|
// IUnknown
|
||||||
STDMETHODIMP QueryInterface(REFIID riid, void** ppv) override;
|
STDMETHODIMP QueryInterface(REFIID riid, void** ppv) override;
|
||||||
|
@ -112,11 +112,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Interceptor(IInterceptorSink* aSink);
|
Interceptor(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink);
|
||||||
~Interceptor();
|
~Interceptor();
|
||||||
HRESULT GetInitialInterceptorForIID(REFIID aTargetIid,
|
|
||||||
STAUniquePtr<IUnknown> aTarget,
|
|
||||||
void** aOutInterface);
|
|
||||||
MapEntry* Lookup(REFIID aIid);
|
MapEntry* Lookup(REFIID aIid);
|
||||||
HRESULT QueryInterfaceTarget(REFIID aIid, void** aOutput);
|
HRESULT QueryInterfaceTarget(REFIID aIid, void** aOutput);
|
||||||
HRESULT ThreadSafeQueryInterface(REFIID aIid,
|
HRESULT ThreadSafeQueryInterface(REFIID aIid,
|
||||||
|
@ -124,7 +121,7 @@ private:
|
||||||
HRESULT CreateInterceptor(REFIID aIid, IUnknown* aOuter, IUnknown** aOutput);
|
HRESULT CreateInterceptor(REFIID aIid, IUnknown* aOuter, IUnknown** aOutput);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
InterceptorTargetPtr<IUnknown> mTarget;
|
STAUniquePtr<IUnknown> mTarget;
|
||||||
RefPtr<IInterceptorSink> mEventSink;
|
RefPtr<IInterceptorSink> mEventSink;
|
||||||
mozilla::Mutex mMutex; // Guards mInterceptorMap
|
mozilla::Mutex mMutex; // Guards mInterceptorMap
|
||||||
// Using a nsTArray since the # of interfaces is not going to be very high
|
// Using a nsTArray since the # of interfaces is not going to be very high
|
||||||
|
|
Загрузка…
Ссылка в новой задаче