2016-05-28 00:54:31 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-07-07 22:13:04 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_ipc_backgroundutils_h__
|
|
|
|
#define mozilla_ipc_backgroundutils_h__
|
|
|
|
|
2015-06-04 21:51:57 +03:00
|
|
|
#include "ipc/IPCMessageUtils.h"
|
2014-07-07 22:13:04 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2015-06-04 21:51:57 +03:00
|
|
|
#include "mozilla/BasePrincipal.h"
|
2014-07-07 22:13:04 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nscore.h"
|
|
|
|
|
2015-07-01 16:56:00 +03:00
|
|
|
class nsILoadInfo;
|
2014-07-07 22:13:04 +04:00
|
|
|
class nsIPrincipal;
|
|
|
|
|
2015-06-04 21:51:57 +03:00
|
|
|
namespace IPC {
|
|
|
|
|
2015-11-03 04:50:54 +03:00
|
|
|
namespace detail {
|
|
|
|
template<class ParamType>
|
|
|
|
struct OriginAttributesParamTraits
|
2015-06-04 21:51:57 +03:00
|
|
|
{
|
2015-11-03 04:50:54 +03:00
|
|
|
typedef ParamType paramType;
|
2015-06-04 21:51:57 +03:00
|
|
|
|
|
|
|
static void Write(Message* aMsg, const paramType& aParam)
|
|
|
|
{
|
|
|
|
nsAutoCString suffix;
|
|
|
|
aParam.CreateSuffix(suffix);
|
|
|
|
WriteParam(aMsg, suffix);
|
|
|
|
}
|
|
|
|
|
2016-04-21 07:09:15 +03:00
|
|
|
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
|
2015-06-04 21:51:57 +03:00
|
|
|
{
|
|
|
|
nsAutoCString suffix;
|
|
|
|
return ReadParam(aMsg, aIter, &suffix) &&
|
|
|
|
aResult->PopulateFromSuffix(suffix);
|
|
|
|
}
|
|
|
|
};
|
2015-11-03 04:50:54 +03:00
|
|
|
} // namespace detail
|
|
|
|
|
|
|
|
template<>
|
|
|
|
struct ParamTraits<mozilla::PrincipalOriginAttributes>
|
|
|
|
: public detail::OriginAttributesParamTraits<mozilla::PrincipalOriginAttributes> {};
|
|
|
|
|
|
|
|
template<>
|
|
|
|
struct ParamTraits<mozilla::DocShellOriginAttributes>
|
|
|
|
: public detail::OriginAttributesParamTraits<mozilla::DocShellOriginAttributes> {};
|
|
|
|
|
|
|
|
template<>
|
|
|
|
struct ParamTraits<mozilla::NeckoOriginAttributes>
|
|
|
|
: public detail::OriginAttributesParamTraits<mozilla::NeckoOriginAttributes> {};
|
|
|
|
|
|
|
|
template<>
|
|
|
|
struct ParamTraits<mozilla::GenericOriginAttributes>
|
|
|
|
: public detail::OriginAttributesParamTraits<mozilla::GenericOriginAttributes> {};
|
2015-06-04 21:51:57 +03:00
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace IPC
|
2015-06-04 21:51:57 +03:00
|
|
|
|
2014-07-07 22:13:04 +04:00
|
|
|
namespace mozilla {
|
2015-06-19 01:37:20 +03:00
|
|
|
namespace net {
|
2015-07-14 08:43:13 +03:00
|
|
|
class OptionalLoadInfoArgs;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace net
|
2015-06-19 01:37:20 +03:00
|
|
|
|
2015-07-14 08:43:13 +03:00
|
|
|
using namespace mozilla::net;
|
|
|
|
|
2014-07-07 22:13:04 +04:00
|
|
|
namespace ipc {
|
|
|
|
|
|
|
|
class PrincipalInfo;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a PrincipalInfo to an nsIPrincipal.
|
|
|
|
*
|
|
|
|
* MUST be called on the main thread only.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsIPrincipal>
|
|
|
|
PrincipalInfoToPrincipal(const PrincipalInfo& aPrincipalInfo,
|
|
|
|
nsresult* aOptionalResult = nullptr);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert an nsIPrincipal to a PrincipalInfo.
|
|
|
|
*
|
|
|
|
* MUST be called on the main thread only.
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
|
|
|
|
PrincipalInfo* aPrincipalInfo);
|
|
|
|
|
2015-06-19 01:37:20 +03:00
|
|
|
/**
|
|
|
|
* Convert a LoadInfo to LoadInfoArgs struct.
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo,
|
2015-07-14 08:43:13 +03:00
|
|
|
OptionalLoadInfoArgs* outOptionalLoadInfoArgs);
|
2015-06-19 01:37:20 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert LoadInfoArgs to a LoadInfo.
|
|
|
|
*/
|
|
|
|
nsresult
|
2015-07-14 08:43:13 +03:00
|
|
|
LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs,
|
2015-06-19 01:37:20 +03:00
|
|
|
nsILoadInfo** outLoadInfo);
|
|
|
|
|
2014-07-07 22:13:04 +04:00
|
|
|
} // namespace ipc
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_ipc_backgroundutils_h__
|