Bug 1824753 [wpt PR 39216] - [FLEDGE] Add WPT test that FLEDGE is not allowed in...
[gecko.git] / dom / ipc / PermissionMessageUtils.h
blob7a32b9e930be75d2870dfefbb07838854b81ca90
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 #ifndef mozilla_dom_permission_message_utils_h__
8 #define mozilla_dom_permission_message_utils_h__
10 #include "mozilla/ipc/IPDLParamTraits.h"
11 #include "ipc/IPCMessageUtils.h"
12 #include "nsCOMPtr.h"
13 #include "nsIPrincipal.h"
15 namespace mozilla::ipc {
17 template <>
18 struct IPDLParamTraits<nsIPrincipal*> {
19 static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor,
20 nsIPrincipal* aParam);
21 static bool Read(IPC::MessageReader* aReader, IProtocol* aActor,
22 RefPtr<nsIPrincipal>* aResult);
24 // Overload to support deserializing nsCOMPtr<nsIPrincipal> directly.
25 static bool Read(IPC::MessageReader* aReader, IProtocol* aActor,
26 nsCOMPtr<nsIPrincipal>* aResult) {
27 RefPtr<nsIPrincipal> result;
28 if (!Read(aReader, aActor, &result)) {
29 return false;
31 *aResult = std::move(result);
32 return true;
36 } // namespace mozilla::ipc
38 #endif // mozilla_dom_permission_message_utils_h__