gecko-dev/ipc/mscom/Utils.cpp
Aaron Klotz 08f3a463ec Bug 1334665: Eliminate runtime dynamic linking for pre-win7 functions in ipc/mscom; r=jimm
MozReview-Commit-ID: 7ySl728hdka

--HG--
extra : rebase_source : fd5914c70fb89176a71ffbc636c0f39662cf9d38
2017-01-27 14:53:20 -07:00

49 lines
1.2 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/mscom/Utils.h"
#include "mozilla/RefPtr.h"
#include <objbase.h>
#include <objidl.h>
namespace mozilla {
namespace mscom {
bool
IsCurrentThreadMTA()
{
APTTYPE aptType;
APTTYPEQUALIFIER aptTypeQualifier;
HRESULT hr = CoGetApartmentType(&aptType, &aptTypeQualifier);
if (FAILED(hr)) {
return false;
}
return aptType == APTTYPE_MTA;
}
bool
IsProxy(IUnknown* aUnknown)
{
if (!aUnknown) {
return false;
}
// Only proxies implement this interface, so if it is present then we must
// be dealing with a proxied object.
RefPtr<IClientSecurity> clientSecurity;
HRESULT hr = aUnknown->QueryInterface(IID_IClientSecurity,
(void**)getter_AddRefs(clientSecurity));
if (SUCCEEDED(hr) || hr == RPC_E_WRONG_THREAD) {
return true;
}
return false;
}
} // namespace mscom
} // namespace mozilla