Bug 1298412: Fix Interceptor construction to use Move semantics for STAUniquePtr instead of pass-by-reference; r=jimm

MozReview-Commit-ID: 8DzeT35Ao4O

--HG--
extra : rebase_source : 14a94903843e54c1c4a4b6c980805ed37d878911
This commit is contained in:
Aaron Klotz 2016-08-26 10:03:17 -06:00
Родитель b4d7db4559
Коммит 63a3869bb8
5 изменённых файлов: 14 добавлений и 11 удалений

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

@ -36,7 +36,7 @@ CreateHolderFromAccessible(Accessible* aAccToWrap)
STAUniquePtr<IAccessible> iaToProxy(rawNative);
IAccessible* rawIntercepted = nullptr;
HRESULT hr = MainThreadHandoff::WrapInterface(iaToProxy, &rawIntercepted);
HRESULT hr = MainThreadHandoff::WrapInterface(Move(iaToProxy), &rawIntercepted);
MOZ_ASSERT(SUCCEEDED(hr));
if (FAILED(hr)) {
return nullptr;

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

@ -23,7 +23,7 @@ namespace mozilla {
namespace mscom {
/* static */ HRESULT
Interceptor::Create(STAUniquePtr<IUnknown>& aTarget, IInterceptorSink* aSink,
Interceptor::Create(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink,
REFIID aIid, void** aOutput)
{
MOZ_ASSERT(aOutput && aTarget && aSink);
@ -34,13 +34,13 @@ Interceptor::Create(STAUniquePtr<IUnknown>& aTarget, IInterceptorSink* aSink,
if (!aTarget || !aSink) {
return E_INVALIDARG;
}
Interceptor* intcpt = new Interceptor(aTarget, aSink);
Interceptor* intcpt = new Interceptor(Move(aTarget), aSink);
HRESULT hr = intcpt->QueryInterface(aIid, aOutput);
static_cast<WeakReferenceSupport*>(intcpt)->Release();
return hr;
}
Interceptor::Interceptor(STAUniquePtr<IUnknown>& aTarget, IInterceptorSink* aSink)
Interceptor::Interceptor(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink)
: WeakReferenceSupport(WeakReferenceSupport::Flags::eDestroyOnMainThread)
, mTarget(Move(aTarget))
, mEventSink(aSink)

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

@ -60,7 +60,7 @@ class Interceptor final : public WeakReferenceSupport
, public IInterceptor
{
public:
static HRESULT Create(STAUniquePtr<IUnknown>& aTarget, IInterceptorSink* aSink,
static HRESULT Create(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink,
REFIID aIid, void** aOutput);
// IUnknown
@ -86,7 +86,7 @@ private:
};
private:
Interceptor(STAUniquePtr<IUnknown>& aTarget, IInterceptorSink* aSink);
Interceptor(STAUniquePtr<IUnknown> aTarget, IInterceptorSink* aSink);
~Interceptor();
MapEntry* Lookup(REFIID aIid);
HRESULT QueryInterfaceTarget(REFIID aIid, void** aOutput);
@ -104,7 +104,7 @@ private:
template <typename InterfaceT>
inline HRESULT
CreateInterceptor(STAUniquePtr<InterfaceT>& aTargetInterface,
CreateInterceptor(STAUniquePtr<InterfaceT> aTargetInterface,
IInterceptorSink* aEventSink,
InterfaceT** aOutInterface)
{
@ -115,7 +115,7 @@ CreateInterceptor(STAUniquePtr<InterfaceT>& aTargetInterface,
REFIID iidTarget = __uuidof(aTargetInterface);
STAUniquePtr<IUnknown> targetUnknown(aTargetInterface.release());
return Interceptor::Create(targetUnknown, aEventSink, iidTarget,
return Interceptor::Create(Move(targetUnknown), aEventSink, iidTarget,
(void**)aOutInterface);
}

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

@ -6,6 +6,7 @@
#include "mozilla/mscom/MainThreadHandoff.h"
#include "mozilla/Move.h"
#include "mozilla/mscom/InterceptorLog.h"
#include "mozilla/mscom/Registration.h"
#include "mozilla/mscom/Utils.h"
@ -373,7 +374,8 @@ MainThreadHandoff::OnWalkInterface(REFIID aIid, PVOID* aInterface,
}
RefPtr<IUnknown> wrapped;
hr = Interceptor::Create(origInterface, handoff, aIid, getter_AddRefs(wrapped));
hr = Interceptor::Create(Move(origInterface), handoff, aIid,
getter_AddRefs(wrapped));
MOZ_ASSERT(SUCCEEDED(hr));
if (FAILED(hr)) {
return hr;

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

@ -8,6 +8,7 @@
#define mozilla_mscom_MainThreadHandoff_h
#include "mozilla/Assertions.h"
#include "mozilla/Move.h"
#include "mozilla/mscom/Interceptor.h"
#include "mozilla/mscom/MainThreadInvoker.h"
#include "mozilla/mscom/Utils.h"
@ -26,7 +27,7 @@ public:
static HRESULT Create(IInterceptorSink** aOutput);
template <typename Interface>
static HRESULT WrapInterface(STAUniquePtr<Interface>& aTargetInterface,
static HRESULT WrapInterface(STAUniquePtr<Interface> aTargetInterface,
Interface** aOutInterface)
{
MOZ_ASSERT(!IsProxy(aTargetInterface.get()));
@ -35,7 +36,7 @@ public:
if (FAILED(hr)) {
return hr;
}
return CreateInterceptor(aTargetInterface, handoff, aOutInterface);
return CreateInterceptor(Move(aTargetInterface), handoff, aOutInterface);
}
// IUnknown