Bug 1287002: Utility functions for Microsoft COM glue; r=jimm

MozReview-Commit-ID: DTH2lIvKjX9

--HG--
extra : rebase_source : e7e4e32f2175322c4ab20a205e37f6b2d34822f8
This commit is contained in:
Aaron Klotz 2016-07-14 16:55:31 -06:00
parent 140fb74701
commit 67768a9eb7
3 changed files with 57 additions and 0 deletions

34
ipc/mscom/Utils.cpp Normal file
View File

@ -0,0 +1,34 @@
/* -*- 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 <objidl.h>
namespace mozilla {
namespace mscom {
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

21
ipc/mscom/Utils.h Normal file
View File

@ -0,0 +1,21 @@
/* -*- 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/. */
#ifndef mozilla_mscom_Utils_h
#define mozilla_mscom_Utils_h
struct IUnknown;
namespace mozilla {
namespace mscom {
bool IsProxy(IUnknown* aUnknown);
} // namespace mscom
} // namespace mozilla
#endif // mozilla_mscom_Utils_h

View File

@ -6,9 +6,11 @@
EXPORTS.mozilla.mscom += [
'COMApartmentRegion.h',
'Utils.h',
]
UNIFIED_SOURCES += [
'Utils.cpp',
]
include('/ipc/chromium/chromium-config.mozbuild')