Line data Source code
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/. */
6 :
7 : #ifndef mozilla_dom_permission_message_utils_h__
8 : #define mozilla_dom_permission_message_utils_h__
9 :
10 : #include "ipc/IPCMessageUtils.h"
11 : #include "nsCOMPtr.h"
12 : #include "nsIPrincipal.h"
13 :
14 : namespace IPC {
15 :
16 85 : class Principal
17 : {
18 : friend struct ParamTraits<Principal>;
19 :
20 : public:
21 42 : Principal()
22 42 : : mPrincipal(nullptr)
23 42 : {}
24 :
25 44 : explicit Principal(nsIPrincipal* aPrincipal)
26 44 : : mPrincipal(aPrincipal)
27 44 : {}
28 :
29 42 : operator nsIPrincipal*() const { return mPrincipal.get(); }
30 :
31 0 : Principal& operator=(const Principal& aOther)
32 : {
33 0 : mPrincipal = aOther.mPrincipal;
34 0 : return *this;
35 : }
36 :
37 : private:
38 : nsCOMPtr<nsIPrincipal> mPrincipal;
39 : };
40 :
41 : template <>
42 : struct ParamTraits<Principal>
43 : {
44 : typedef Principal paramType;
45 : static void Write(Message* aMsg, const paramType& aParam);
46 : static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult);
47 : };
48 :
49 : } // namespace IPC
50 :
51 : #endif // mozilla_dom_permission_message_utils_h__
52 :
|