dom/ipc/TabMessageUtils.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial