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 TABMESSAGE_UTILS_H
8 : #define TABMESSAGE_UTILS_H
9 :
10 : #include "ipc/IPCMessageUtils.h"
11 : #include "mozilla/dom/AudioChannelBinding.h"
12 : #include "nsIDOMEvent.h"
13 : #include "nsPIDOMWindow.h"
14 : #include "nsCOMPtr.h"
15 :
16 : #ifdef MOZ_CRASHREPORTER
17 : #include "nsExceptionHandler.h"
18 : #endif
19 :
20 : namespace mozilla {
21 : namespace dom {
22 0 : struct RemoteDOMEvent
23 : {
24 : // Make sure to set the owner after deserializing.
25 : nsCOMPtr<nsIDOMEvent> mEvent;
26 : };
27 :
28 : bool ReadRemoteEvent(const IPC::Message* aMsg, PickleIterator* aIter,
29 : mozilla::dom::RemoteDOMEvent* aResult);
30 :
31 : #ifdef MOZ_CRASHREPORTER
32 : typedef CrashReporter::ThreadId NativeThreadId;
33 : #else
34 : // unused in this case
35 : typedef int32_t NativeThreadId;
36 : #endif
37 :
38 : } // namespace dom
39 : } // namespace mozilla
40 :
41 : namespace IPC {
42 :
43 : template<>
44 : struct ParamTraits<mozilla::dom::RemoteDOMEvent>
45 : {
46 : typedef mozilla::dom::RemoteDOMEvent paramType;
47 :
48 0 : static void Write(Message* aMsg, const paramType& aParam)
49 : {
50 0 : aParam.mEvent->Serialize(aMsg, true);
51 0 : }
52 :
53 0 : static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
54 : {
55 0 : return mozilla::dom::ReadRemoteEvent(aMsg, aIter, aResult);
56 : }
57 :
58 : static void Log(const paramType& aParam, std::wstring* aLog)
59 : {
60 : }
61 : };
62 :
63 : template<>
64 : struct ParamTraits<mozilla::dom::AudioChannel>
65 : {
66 : typedef mozilla::dom::AudioChannel paramType;
67 :
68 : static bool IsLegalValue(const paramType &aValue)
69 : {
70 : return aValue <= mozilla::dom::AudioChannel::Publicnotification;
71 : }
72 :
73 : static void Write(Message* aMsg, const paramType& aValue)
74 : {
75 : MOZ_ASSERT(IsLegalValue(aValue));
76 : WriteParam(aMsg, (uint32_t)aValue);
77 : }
78 :
79 : static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
80 : {
81 : uint32_t value;
82 : if(!ReadParam(aMsg, aIter, &value) ||
83 : !IsLegalValue(paramType(value))) {
84 : return false;
85 : }
86 : *aResult = paramType(value);
87 : return true;
88 : }
89 :
90 : static void Log(const paramType& aParam, std::wstring* aLog)
91 : {}
92 : };
93 :
94 : template <>
95 : struct ParamTraits<nsEventStatus>
96 : : public ContiguousEnumSerializer<nsEventStatus,
97 : nsEventStatus_eIgnore,
98 : nsEventStatus_eSentinel>
99 : {};
100 :
101 : template<>
102 : struct ParamTraits<nsSizeMode>
103 : : public ContiguousEnumSerializer<nsSizeMode,
104 : nsSizeMode_Normal,
105 : nsSizeMode_Invalid>
106 : {};
107 :
108 : template<>
109 : struct ParamTraits<UIStateChangeType>
110 : : public ContiguousEnumSerializer<UIStateChangeType,
111 : UIStateChangeType_NoChange,
112 : UIStateChangeType_Invalid>
113 : { };
114 :
115 : } // namespace IPC
116 :
117 : #endif // TABMESSAGE_UTILS_H
|