Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
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/. */
6 #ifndef TABMESSAGE_UTILS_H
7 #define TABMESSAGE_UTILS_H
9 #include "AudioChannelCommon.h"
10 #include "ipc/IPCMessageUtils.h"
11 #include "mozilla/dom/AudioChannelBinding.h"
12 #include "nsIDOMEvent.h"
13 #include "nsCOMPtr.h"
15 #ifdef MOZ_CRASHREPORTER
16 #include "nsExceptionHandler.h"
17 #endif
19 namespace mozilla {
20 namespace dom {
21 struct RemoteDOMEvent
22 {
23 // Make sure to set the owner after deserializing.
24 nsCOMPtr<nsIDOMEvent> mEvent;
25 };
27 bool ReadRemoteEvent(const IPC::Message* aMsg, void** aIter,
28 mozilla::dom::RemoteDOMEvent* aResult);
30 #ifdef MOZ_CRASHREPORTER
31 typedef CrashReporter::ThreadId NativeThreadId;
32 #else
33 // unused in this case
34 typedef int32_t NativeThreadId;
35 #endif
37 }
38 }
40 namespace IPC {
42 template<>
43 struct ParamTraits<mozilla::dom::RemoteDOMEvent>
44 {
45 typedef mozilla::dom::RemoteDOMEvent paramType;
47 static void Write(Message* aMsg, const paramType& aParam)
48 {
49 aParam.mEvent->Serialize(aMsg, true);
50 }
52 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
53 {
54 return mozilla::dom::ReadRemoteEvent(aMsg, aIter, aResult);
55 }
57 static void Log(const paramType& aParam, std::wstring* aLog)
58 {
59 }
60 };
62 template<>
63 struct ParamTraits<mozilla::dom::AudioChannel>
64 {
65 typedef mozilla::dom::AudioChannel paramType;
67 static bool IsLegalValue(const paramType &aValue) {
68 return aValue <= mozilla::dom::AudioChannel::Publicnotification;
69 }
71 static void Write(Message* aMsg, const paramType& aValue) {
72 MOZ_ASSERT(IsLegalValue(aValue));
73 WriteParam(aMsg, (uint32_t)aValue);
74 }
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 }
86 static void Log(const paramType& aParam, std::wstring* aLog)
87 {
88 }
89 };
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 { };
98 }
101 #endif