1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/ipc/TabMessageUtils.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,101 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef TABMESSAGE_UTILS_H 1.10 +#define TABMESSAGE_UTILS_H 1.11 + 1.12 +#include "AudioChannelCommon.h" 1.13 +#include "ipc/IPCMessageUtils.h" 1.14 +#include "mozilla/dom/AudioChannelBinding.h" 1.15 +#include "nsIDOMEvent.h" 1.16 +#include "nsCOMPtr.h" 1.17 + 1.18 +#ifdef MOZ_CRASHREPORTER 1.19 +#include "nsExceptionHandler.h" 1.20 +#endif 1.21 + 1.22 +namespace mozilla { 1.23 +namespace dom { 1.24 +struct RemoteDOMEvent 1.25 +{ 1.26 + // Make sure to set the owner after deserializing. 1.27 + nsCOMPtr<nsIDOMEvent> mEvent; 1.28 +}; 1.29 + 1.30 +bool ReadRemoteEvent(const IPC::Message* aMsg, void** aIter, 1.31 + mozilla::dom::RemoteDOMEvent* aResult); 1.32 + 1.33 +#ifdef MOZ_CRASHREPORTER 1.34 +typedef CrashReporter::ThreadId NativeThreadId; 1.35 +#else 1.36 +// unused in this case 1.37 +typedef int32_t NativeThreadId; 1.38 +#endif 1.39 + 1.40 +} 1.41 +} 1.42 + 1.43 +namespace IPC { 1.44 + 1.45 +template<> 1.46 +struct ParamTraits<mozilla::dom::RemoteDOMEvent> 1.47 +{ 1.48 + typedef mozilla::dom::RemoteDOMEvent paramType; 1.49 + 1.50 + static void Write(Message* aMsg, const paramType& aParam) 1.51 + { 1.52 + aParam.mEvent->Serialize(aMsg, true); 1.53 + } 1.54 + 1.55 + static bool Read(const Message* aMsg, void** aIter, paramType* aResult) 1.56 + { 1.57 + return mozilla::dom::ReadRemoteEvent(aMsg, aIter, aResult); 1.58 + } 1.59 + 1.60 + static void Log(const paramType& aParam, std::wstring* aLog) 1.61 + { 1.62 + } 1.63 +}; 1.64 + 1.65 +template<> 1.66 +struct ParamTraits<mozilla::dom::AudioChannel> 1.67 +{ 1.68 + typedef mozilla::dom::AudioChannel paramType; 1.69 + 1.70 + static bool IsLegalValue(const paramType &aValue) { 1.71 + return aValue <= mozilla::dom::AudioChannel::Publicnotification; 1.72 + } 1.73 + 1.74 + static void Write(Message* aMsg, const paramType& aValue) { 1.75 + MOZ_ASSERT(IsLegalValue(aValue)); 1.76 + WriteParam(aMsg, (uint32_t)aValue); 1.77 + } 1.78 + 1.79 + static bool Read(const Message* aMsg, void** aIter, paramType* aResult) { 1.80 + uint32_t value; 1.81 + if(!ReadParam(aMsg, aIter, &value) || 1.82 + !IsLegalValue(paramType(value))) { 1.83 + return false; 1.84 + } 1.85 + *aResult = paramType(value); 1.86 + return true; 1.87 + } 1.88 + 1.89 + static void Log(const paramType& aParam, std::wstring* aLog) 1.90 + { 1.91 + } 1.92 +}; 1.93 + 1.94 +template <> 1.95 +struct ParamTraits<mozilla::dom::AudioChannelState> 1.96 + : public ContiguousEnumSerializer<mozilla::dom::AudioChannelState, 1.97 + mozilla::dom::AUDIO_CHANNEL_STATE_NORMAL, 1.98 + mozilla::dom::AUDIO_CHANNEL_STATE_LAST> 1.99 +{ }; 1.100 + 1.101 +} 1.102 + 1.103 + 1.104 +#endif