Backed out changeset 0eb505a8ac7c (bug 1395329) for Windows static bustage in Interceptor.obj. r=backout
This commit is contained in:
@@ -305,7 +305,6 @@ Interceptor::MapEntry*
|
|||||||
Interceptor::Lookup(REFIID aIid)
|
Interceptor::Lookup(REFIID aIid)
|
||||||
{
|
{
|
||||||
mMutex.AssertCurrentThreadOwns();
|
mMutex.AssertCurrentThreadOwns();
|
||||||
|
|
||||||
for (uint32_t index = 0, len = mInterceptorMap.Length(); index < len; ++index) {
|
for (uint32_t index = 0, len = mInterceptorMap.Length(); index < len; ++index) {
|
||||||
if (mInterceptorMap[index].mIID == aIid) {
|
if (mInterceptorMap[index].mIID == aIid) {
|
||||||
return &mInterceptorMap[index];
|
return &mInterceptorMap[index];
|
||||||
@@ -368,57 +367,15 @@ Interceptor::CreateInterceptor(REFIID aIid, IUnknown* aOuter, IUnknown** aOutput
|
|||||||
}
|
}
|
||||||
|
|
||||||
HRESULT
|
HRESULT
|
||||||
Interceptor::PublishTarget(detail::LiveSetAutoLock& aLiveSetLock,
|
Interceptor::GetInitialInterceptorForIID(detail::LiveSetAutoLock& aLock,
|
||||||
RefPtr<IUnknown> aInterceptor,
|
|
||||||
REFIID aTargetIid,
|
|
||||||
STAUniquePtr<IUnknown> aTarget)
|
|
||||||
{
|
|
||||||
RefPtr<IWeakReference> weakRef;
|
|
||||||
HRESULT hr = GetWeakReference(getter_AddRefs(weakRef));
|
|
||||||
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);
|
|
||||||
GetLiveSet().Put(mTarget.get(), weakRef.forget());
|
|
||||||
|
|
||||||
// Now we transfer aTarget's ownership into mInterceptorMap.
|
|
||||||
mInterceptorMap.AppendElement(MapEntry(aTargetIid,
|
|
||||||
aInterceptor,
|
|
||||||
aTarget.release()));
|
|
||||||
|
|
||||||
// Release the live set lock because subsequent operations may post work to
|
|
||||||
// the main thread, creating potential for deadlocks.
|
|
||||||
aLiveSetLock.Unlock();
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT
|
|
||||||
Interceptor::GetInitialInterceptorForIID(detail::LiveSetAutoLock& aLiveSetLock,
|
|
||||||
REFIID aTargetIid,
|
REFIID aTargetIid,
|
||||||
STAUniquePtr<IUnknown> aTarget,
|
STAUniquePtr<IUnknown> aTarget,
|
||||||
void** aOutInterceptor)
|
void** aOutInterceptor)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aOutInterceptor);
|
MOZ_ASSERT(aOutInterceptor);
|
||||||
MOZ_ASSERT(aTargetIid != IID_IMarshal);
|
MOZ_ASSERT(aTargetIid != IID_IUnknown && aTargetIid != IID_IMarshal);
|
||||||
MOZ_ASSERT(!IsProxy(aTarget.get()));
|
MOZ_ASSERT(!IsProxy(aTarget.get()));
|
||||||
|
|
||||||
if (aTargetIid == IID_IUnknown) {
|
|
||||||
// We must lock ourselves so that nothing can race with us once we have been
|
|
||||||
// published to the live set.
|
|
||||||
AutoLock lock(*this);
|
|
||||||
|
|
||||||
HRESULT hr = PublishTarget(aLiveSetLock, nullptr, aTargetIid, Move(aTarget));
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QueryInterface(aTargetIid, aOutInterceptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Raise the refcount for stabilization purposes during aggregation
|
// Raise the refcount for stabilization purposes during aggregation
|
||||||
RefPtr<IUnknown> kungFuDeathGrip(static_cast<IUnknown*>(
|
RefPtr<IUnknown> kungFuDeathGrip(static_cast<IUnknown*>(
|
||||||
static_cast<WeakReferenceSupport*>(this)));
|
static_cast<WeakReferenceSupport*>(this)));
|
||||||
@@ -442,15 +399,27 @@ Interceptor::GetInitialInterceptorForIID(detail::LiveSetAutoLock& aLiveSetLock,
|
|||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We must lock ourselves so that nothing can race with us once we have been
|
RefPtr<IWeakReference> weakRef;
|
||||||
// published to the live set.
|
hr = GetWeakReference(getter_AddRefs(weakRef));
|
||||||
AutoLock lock(*this);
|
|
||||||
|
|
||||||
hr = PublishTarget(aLiveSetLock, unkInterceptor, aTargetIid, Move(aTarget));
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
return 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);
|
||||||
|
GetLiveSet().Put(mTarget.get(), weakRef.forget());
|
||||||
|
|
||||||
|
// Release the live set lock because GetInterceptorForIID will post work to
|
||||||
|
// the main thread, creating potential for deadlocks.
|
||||||
|
aLock.Unlock();
|
||||||
|
|
||||||
|
// Now we transfer aTarget's ownership into mInterceptorMap.
|
||||||
|
mInterceptorMap.AppendElement(MapEntry(aTargetIid,
|
||||||
|
unkInterceptor,
|
||||||
|
aTarget.release()));
|
||||||
|
|
||||||
if (mEventSink->MarshalAs(aTargetIid) == aTargetIid) {
|
if (mEventSink->MarshalAs(aTargetIid) == aTargetIid) {
|
||||||
return unkInterceptor->QueryInterface(aTargetIid, aOutInterceptor);
|
return unkInterceptor->QueryInterface(aTargetIid, aOutInterceptor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
explicit Interceptor(IInterceptorSink* aSink);
|
explicit Interceptor(IInterceptorSink* aSink);
|
||||||
~Interceptor();
|
~Interceptor();
|
||||||
HRESULT GetInitialInterceptorForIID(detail::LiveSetAutoLock& aLiveSetLock,
|
HRESULT GetInitialInterceptorForIID(detail::LiveSetAutoLock& aLock,
|
||||||
REFIID aTargetIid,
|
REFIID aTargetIid,
|
||||||
STAUniquePtr<IUnknown> aTarget,
|
STAUniquePtr<IUnknown> aTarget,
|
||||||
void** aOutInterface);
|
void** aOutInterface);
|
||||||
@@ -129,10 +129,6 @@ private:
|
|||||||
HRESULT ThreadSafeQueryInterface(REFIID aIid,
|
HRESULT ThreadSafeQueryInterface(REFIID aIid,
|
||||||
IUnknown** aOutInterface) override;
|
IUnknown** aOutInterface) override;
|
||||||
HRESULT CreateInterceptor(REFIID aIid, IUnknown* aOuter, IUnknown** aOutput);
|
HRESULT CreateInterceptor(REFIID aIid, IUnknown* aOuter, IUnknown** aOutput);
|
||||||
HRESULT PublishTarget(detail::LiveSetAutoLock& aLiveSetLock,
|
|
||||||
RefPtr<IUnknown> aInterceptor,
|
|
||||||
REFIID aTargetIid,
|
|
||||||
STAUniquePtr<IUnknown> aTarget);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
InterceptorTargetPtr<IUnknown> mTarget;
|
InterceptorTargetPtr<IUnknown> mTarget;
|
||||||
|
|||||||
@@ -109,18 +109,6 @@ WeakReferenceSupport::~WeakReferenceSupport()
|
|||||||
::DeleteCriticalSection(&mCSForQI);
|
::DeleteCriticalSection(&mCSForQI);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
WeakReferenceSupport::Lock()
|
|
||||||
{
|
|
||||||
::EnterCriticalSection(&mCSForQI);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
WeakReferenceSupport::Unlock()
|
|
||||||
{
|
|
||||||
::LeaveCriticalSection(&mCSForQI);
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT
|
HRESULT
|
||||||
WeakReferenceSupport::QueryInterface(REFIID riid, void** ppv)
|
WeakReferenceSupport::QueryInterface(REFIID riid, void** ppv)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "mozilla/Assertions.h"
|
#include "mozilla/Assertions.h"
|
||||||
#include "mozilla/Atomics.h"
|
#include "mozilla/Atomics.h"
|
||||||
#include "mozilla/Mutex.h"
|
|
||||||
#include "mozilla/RefPtr.h"
|
#include "mozilla/RefPtr.h"
|
||||||
#include "nsISupportsImpl.h"
|
#include "nsISupportsImpl.h"
|
||||||
|
|
||||||
@@ -102,12 +101,6 @@ protected:
|
|||||||
virtual HRESULT ThreadSafeQueryInterface(REFIID aIid,
|
virtual HRESULT ThreadSafeQueryInterface(REFIID aIid,
|
||||||
IUnknown** aOutInterface) = 0;
|
IUnknown** aOutInterface) = 0;
|
||||||
|
|
||||||
void Lock();
|
|
||||||
void Unlock();
|
|
||||||
|
|
||||||
typedef BaseAutoLock<WeakReferenceSupport> AutoLock;
|
|
||||||
friend class AutoLock;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefPtr<detail::SharedRef> mSharedRef;
|
RefPtr<detail::SharedRef> mSharedRef;
|
||||||
ULONG mRefCnt;
|
ULONG mRefCnt;
|
||||||
|
|||||||
Reference in New Issue
Block a user