Bug 1367885: Backed out changeset 3f6e08c5233f for bc4 bustage on a CLOSED TREE; r=backout

MozReview-Commit-ID: 4CDliBImLR7
This commit is contained in:
Aaron Klotz 2017-06-05 12:51:52 -06:00
Родитель 0fdef67a82
Коммит ec02e78c40
2 изменённых файлов: 12 добавлений и 63 удалений

Просмотреть файл

@ -25,31 +25,32 @@ namespace mscom {
/* static */ HRESULT
Interceptor::Create(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink,
REFIID aInitialIid, void** aOutInterface)
REFIID aIid, void** aOutput)
{
MOZ_ASSERT(aOutInterface && aTarget && aSink);
if (!aOutInterface) {
MOZ_ASSERT(aOutput && aTarget && aSink);
if (!aOutput) {
return E_INVALIDARG;
}
*aOutInterface = nullptr;
*aOutput = nullptr;
if (!aTarget || !aSink) {
return E_INVALIDARG;
}
RefPtr<Interceptor> intcpt(new Interceptor(aSink));
return intcpt->GetInitialInterceptorForIID(aInitialIid, Move(aTarget),
aOutInterface);
RefPtr<WeakReferenceSupport> intcpt(new Interceptor(Move(aTarget), aSink));
return intcpt->QueryInterface(aIid, aOutput);
}
Interceptor::Interceptor(IInterceptorSink* aSink)
Interceptor::Interceptor(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink)
: WeakReferenceSupport(WeakReferenceSupport::Flags::eDestroyOnMainThread)
, mTarget(Move(aTarget))
, mEventSink(aSink)
, mMutex("mozilla::mscom::Interceptor::mMutex")
, mStdMarshal(nullptr)
{
MOZ_ASSERT(aSink);
MOZ_ASSERT(!IsProxy(mTarget.get()));
RefPtr<IWeakReference> weakRef;
if (SUCCEEDED(GetWeakReference(getter_AddRefs(weakRef)))) {
aSink->SetInterceptor(weakRef);
@ -204,55 +205,6 @@ Interceptor::CreateInterceptor(REFIID aIid, IUnknown* aOuter, IUnknown** aOutput
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
* that are delegated to us from the ICallInterceptor.

Просмотреть файл

@ -67,7 +67,7 @@ class Interceptor final : public WeakReferenceSupport
{
public:
static HRESULT Create(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink,
REFIID aInitialIid, void** aOutInterface);
REFIID aIid, void** aOutput);
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid, void** ppv) override;
@ -112,11 +112,8 @@ private:
};
private:
explicit Interceptor(IInterceptorSink* aSink);
Interceptor(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink);
~Interceptor();
HRESULT GetInitialInterceptorForIID(REFIID aTargetIid,
STAUniquePtr<IUnknown> aTarget,
void** aOutInterface);
MapEntry* Lookup(REFIID aIid);
HRESULT QueryInterfaceTarget(REFIID aIid, void** aOutput);
HRESULT ThreadSafeQueryInterface(REFIID aIid,
@ -124,7 +121,7 @@ private:
HRESULT CreateInterceptor(REFIID aIid, IUnknown* aOuter, IUnknown** aOutput);
private:
InterceptorTargetPtr<IUnknown> mTarget;
STAUniquePtr<IUnknown> mTarget;
RefPtr<IInterceptorSink> mEventSink;
mozilla::Mutex mMutex; // Guards mInterceptorMap
// Using a nsTArray since the # of interfaces is not going to be very high