gecko-dev/ipc/mscom/Utils.cpp

49 строки
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