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 {
|
|
|
|
|
|
|
|
template<>
|
|
|
|
struct ParamTraits<mozilla::OriginAttributes>
|
|
|
|
{
|
|
|
|
typedef mozilla::OriginAttributes paramType;
|
|
|
|
|
|
|
|
static void Write(Message* aMsg, const paramType& aParam)
|
|
|
|
{
|
|
|
|
nsAutoCString suffix;
|
|
|
|
aParam.CreateSuffix(suffix);
|
|
|
|
WriteParam(aMsg, suffix);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
|
|
|
{
|
|
|
|
nsAutoCString suffix;
|
|
|
|
return ReadParam(aMsg, aIter, &suffix) &&
|
|
|
|
aResult->PopulateFromSuffix(suffix);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
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__
|