Bug 1891340 - Part 1: Add parameters to customize the before and after icon tints...
[gecko.git] / ipc / mscom / AgileReference.cpp
blob76fe773b0a234de7a91ceca749ea46aca727fac4
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/mscom/AgileReference.h"
9 #include <utility>
10 #include "mozilla/Assertions.h"
11 #include "mozilla/mscom/Utils.h"
13 #if defined(__MINGW32__)
15 // Declarations from Windows SDK specific to Windows 8.1
17 enum AgileReferenceOptions {
18 AGILEREFERENCE_DEFAULT = 0,
19 AGILEREFERENCE_DELAYEDMARSHAL = 1,
22 HRESULT WINAPI RoGetAgileReference(AgileReferenceOptions options, REFIID riid,
23 IUnknown* pUnk,
24 IAgileReference** ppAgileReference);
26 // Unfortunately, at time of writing, MinGW doesn't know how to statically link
27 // to RoGetAgileReference. On these builds only, we substitute a runtime-linked
28 // function pointer.
30 # include "mozilla/DynamicallyLinkedFunctionPtr.h"
32 static const mozilla::StaticDynamicallyLinkedFunctionPtr<
33 decltype(&::RoGetAgileReference)>
34 pRoGetAgileReference(L"ole32.dll", "RoGetAgileReference");
36 # define RoGetAgileReference pRoGetAgileReference
38 #endif // defined(__MINGW32__)
40 namespace mozilla::mscom::detail {
42 HRESULT AgileReference_CreateImpl(RefPtr<IAgileReference>& aRefPtr, REFIID riid,
43 IUnknown* aObject) {
44 MOZ_ASSERT(aObject);
45 MOZ_ASSERT(IsCOMInitializedOnCurrentThread());
46 return ::RoGetAgileReference(AGILEREFERENCE_DEFAULT, riid, aObject,
47 getter_AddRefs(aRefPtr));
50 HRESULT AgileReference_ResolveImpl(RefPtr<IAgileReference> const& aRefPtr,
51 REFIID riid, void** aOutInterface) {
52 MOZ_ASSERT(aRefPtr);
53 MOZ_ASSERT(aOutInterface);
54 MOZ_ASSERT(IsCOMInitializedOnCurrentThread());
56 if (!aRefPtr || !aOutInterface) {
57 return E_INVALIDARG;
60 *aOutInterface = nullptr;
61 return aRefPtr->Resolve(riid, aOutInterface);
64 } // namespace mozilla::mscom::detail