Backed out changeset dd26b9ddef2c (bug 1292452)

This commit is contained in:
Sebastian Hengst 2016-08-19 10:02:02 +02:00
parent ea5a423e4b
commit 1ab23ac869
2 changed files with 21 additions and 40 deletions

View File

@ -148,8 +148,7 @@ MainThreadHandoff::OnCall(ICallFrame* aFrame)
// (2) Execute the method call syncrhonously on the main thread
RefPtr<HandoffRunnable> handoffInfo(new HandoffRunnable(aFrame,
targetInterface.get()));
MainThreadInvoker invoker;
if (!invoker.Invoke(do_AddRef(handoffInfo))) {
if (!mInvoker.Invoke(do_AddRef(handoffInfo))) {
MOZ_ASSERT(false);
return E_UNEXPECTED;
}
@ -174,7 +173,15 @@ MainThreadHandoff::OnCall(ICallFrame* aFrame)
return S_OK;
}
// (5) Unfortunately ICallFrame::WalkFrame does not correctly handle array
// (5) Scan the outputs looking for any outparam interfaces that need wrapping.
// NB: WalkFrame does not correctly handle array outparams. It processes the
// first element of an array but not the remaining elements (if any).
hr = aFrame->WalkFrame(CALLFRAME_WALK_OUT, this);
if (FAILED(hr)) {
return hr;
}
// (6) Unfortunately ICallFrame::WalkFrame does not correctly handle array
// outparams. Instead, we find out whether anybody has called
// mscom::RegisterArrayData to supply array parameter information and use it
// if available. This is a terrible hack, but it works for the short term. In
@ -186,14 +193,6 @@ MainThreadHandoff::OnCall(ICallFrame* aFrame)
if (FAILED(hr)) {
return hr;
}
} else {
// (6) Scan the outputs looking for any outparam interfaces that need wrapping.
// NB: WalkFrame does not correctly handle array outparams. It processes the
// first element of an array but not the remaining elements (if any).
hr = aFrame->WalkFrame(CALLFRAME_WALK_OUT, this);
if (FAILED(hr)) {
return hr;
}
}
return S_OK;
@ -226,54 +225,35 @@ MainThreadHandoff::FixArrayElements(ICallFrame* aFrame,
{
// Extract the array length
VARIANT paramVal;
VariantInit(&paramVal);
HRESULT hr = aFrame->GetParam(aArrayData.mLengthParamIndex, &paramVal);
MOZ_ASSERT(SUCCEEDED(hr) &&
(paramVal.vt == (VT_I4 | VT_BYREF) ||
paramVal.vt == (VT_UI4 | VT_BYREF)));
MOZ_ASSERT(paramVal.vt == (VT_I4 | VT_BYREF) ||
paramVal.vt == (VT_UI4 | VT_BYREF));
if (FAILED(hr) || (paramVal.vt != (VT_I4 | VT_BYREF) &&
paramVal.vt != (VT_UI4 | VT_BYREF))) {
return hr;
}
const LONG arrayLength = *(paramVal.plVal);
if (!arrayLength) {
// Nothing to do
if (arrayLength <= 1) {
// Nothing needs to be processed (we skip index 0)
return S_OK;
}
// Extract the array parameter
VariantInit(&paramVal);
PVOID arrayPtr = nullptr;
hr = aFrame->GetParam(aArrayData.mArrayParamIndex, &paramVal);
if (hr == DISP_E_BADVARTYPE) {
// ICallFrame::GetParam is not able to coerce the param into a VARIANT.
// That's ok, we can try to do it ourselves.
CALLFRAMEPARAMINFO paramInfo;
hr = aFrame->GetParamInfo(aArrayData.mArrayParamIndex, &paramInfo);
if (FAILED(hr)) {
return hr;
}
PVOID stackBase = aFrame->GetStackLocation();
// We dereference twice because we need to obtain the value of a parameter
// from a stack offset (one), and since that is an outparam, we need to
// find the value that is actually being returned (two).
arrayPtr = **reinterpret_cast<PVOID**>(reinterpret_cast<PBYTE>(stackBase) +
paramInfo.stackOffset);
} else if (FAILED(hr)) {
if (FAILED(hr)) {
return hr;
} else {
arrayPtr = ResolveArrayPtr(paramVal);
}
PVOID arrayPtr = ResolveArrayPtr(paramVal);
MOZ_ASSERT(arrayPtr);
if (!arrayPtr) {
return DISP_E_BADVARTYPE;
}
// We walk the elements of the array and invoke OnWalkInterface to wrap each
// one, just as ICallFrame::WalkFrame would do.
for (LONG index = 0; index < arrayLength; ++index) {
// Start index is 1 because ICallFrame::WalkFrame already took care of index
// 0. We walk the remaining elements of the array and invoke OnWalkInterface
// to wrap each one, just as ICallFrame::WalkFrame would do.
for (LONG index = 1; index < arrayLength; ++index) {
hr = OnWalkInterface(aArrayData.mArrayParamIid,
ResolveInterfacePtr(arrayPtr, paramVal.vt, index),
FALSE, TRUE);

View File

@ -61,6 +61,7 @@ private:
private:
ULONG mRefCnt;
MainThreadInvoker mInvoker;
RefPtr<IWeakReference> mInterceptor;
};