dom/ipc/TabMessageUtils.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:6a53b43f1b2b
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef TABMESSAGE_UTILS_H
7 #define TABMESSAGE_UTILS_H
8
9 #include "AudioChannelCommon.h"
10 #include "ipc/IPCMessageUtils.h"
11 #include "mozilla/dom/AudioChannelBinding.h"
12 #include "nsIDOMEvent.h"
13 #include "nsCOMPtr.h"
14
15 #ifdef MOZ_CRASHREPORTER
16 #include "nsExceptionHandler.h"
17 #endif
18
19 namespace mozilla {
20 namespace dom {
21 struct RemoteDOMEvent
22 {
23 // Make sure to set the owner after deserializing.
24 nsCOMPtr<nsIDOMEvent> mEvent;
25 };
26
27 bool ReadRemoteEvent(const IPC::Message* aMsg, void** aIter,
28 mozilla::dom::RemoteDOMEvent* aResult);
29
30 #ifdef MOZ_CRASHREPORTER
31 typedef CrashReporter::ThreadId NativeThreadId;
32 #else
33 // unused in this case
34 typedef int32_t NativeThreadId;
35 #endif
36
37 }
38 }
39
40 namespace IPC {
41
42 template<>
43 struct ParamTraits<mozilla::dom::RemoteDOMEvent>
44 {
45 typedef mozilla::dom::RemoteDOMEvent paramType;
46
47 static void Write(Message* aMsg, const paramType& aParam)
48 {
49 aParam.mEvent->Serialize(aMsg, true);
50 }
51
52 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
53 {
54 return mozilla::dom::ReadRemoteEvent(aMsg, aIter, aResult);
55 }
56
57 static void Log(const paramType& aParam, std::wstring* aLog)
58 {
59 }
60 };
61
62 template<>
63 struct ParamTraits<mozilla::dom::AudioChannel>
64 {
65 typedef mozilla::dom::AudioChannel paramType;
66
67 static bool IsLegalValue(const paramType &aValue) {
68 return aValue <= mozilla::dom::AudioChannel::Publicnotification;
69 }
70
71 static void Write(Message* aMsg, const paramType& aValue) {
72 MOZ_ASSERT(IsLegalValue(aValue));
73 WriteParam(aMsg, (uint32_t)aValue);
74 }
75
76 static bool Read(const Message* aMsg, void** aIter, paramType* aResult) {
77 uint32_t value;
78 if(!ReadParam(aMsg, aIter, &value) ||
79 !IsLegalValue(paramType(value))) {
80 return false;
81 }
82 *aResult = paramType(value);
83 return true;
84 }
85
86 static void Log(const paramType& aParam, std::wstring* aLog)
87 {
88 }
89 };
90
91 template <>
92 struct ParamTraits<mozilla::dom::AudioChannelState>
93 : public ContiguousEnumSerializer<mozilla::dom::AudioChannelState,
94 mozilla::dom::AUDIO_CHANNEL_STATE_NORMAL,
95 mozilla::dom::AUDIO_CHANNEL_STATE_LAST>
96 { };
97
98 }
99
100
101 #endif

mercurial