2015-03-02 16:20:00 +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: */
|
|
|
|
/* 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_dom_cache_AutoUtils_h
|
|
|
|
#define mozilla_dom_cache_AutoUtils_h
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
2015-04-16 22:00:15 +03:00
|
|
|
#include "mozilla/dom/cache/CacheTypes.h"
|
2015-04-16 22:00:15 +03:00
|
|
|
#include "mozilla/dom/cache/Types.h"
|
2015-03-02 16:20:00 +03:00
|
|
|
#include "mozilla/dom/cache/TypeUtils.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
|
|
|
|
struct nsID;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class ErrorResult;
|
|
|
|
|
|
|
|
namespace ipc {
|
|
|
|
class PBackgroundParent;
|
2016-05-15 20:32:09 +03:00
|
|
|
class AutoIPCStream;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace ipc
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class InternalRequest;
|
|
|
|
|
|
|
|
namespace cache {
|
|
|
|
|
|
|
|
class CacheStreamControlParent;
|
2015-04-16 22:00:15 +03:00
|
|
|
class Manager;
|
2015-03-02 16:20:00 +03:00
|
|
|
struct SavedRequest;
|
|
|
|
struct SavedResponse;
|
|
|
|
class StreamList;
|
|
|
|
|
|
|
|
// A collection of RAII-style helper classes to ensure that IPC
|
|
|
|
// FileDescriptorSet actors are properly cleaned up. The user of these actors
|
|
|
|
// must manually either Forget() the Fds or Send__delete__() the actor
|
|
|
|
// depending on if the descriptors were actually sent.
|
|
|
|
//
|
|
|
|
// Note, these should only be used when *sending* streams across IPC. The
|
|
|
|
// deserialization case is handled by creating a ReadStream object.
|
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
class MOZ_STACK_CLASS AutoChildOpArgs final
|
2015-03-02 16:20:00 +03:00
|
|
|
{
|
2015-04-16 22:00:15 +03:00
|
|
|
public:
|
2015-03-02 16:20:00 +03:00
|
|
|
typedef TypeUtils::BodyAction BodyAction;
|
|
|
|
typedef TypeUtils::SchemeAction SchemeAction;
|
|
|
|
|
2016-05-15 20:32:09 +03:00
|
|
|
AutoChildOpArgs(TypeUtils* aTypeUtils, const CacheOpArgs& aOpArgs,
|
|
|
|
uint32_t aEntryCount);
|
2015-04-16 22:00:15 +03:00
|
|
|
~AutoChildOpArgs();
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
void Add(InternalRequest* aRequest, BodyAction aBodyAction,
|
2015-04-29 18:59:43 +03:00
|
|
|
SchemeAction aSchemeAction, ErrorResult& aRv);
|
2017-08-11 04:04:55 +03:00
|
|
|
void Add(JSContext* aCx, InternalRequest* aRequest, BodyAction aBodyAction,
|
2015-04-29 18:59:43 +03:00
|
|
|
SchemeAction aSchemeAction, Response& aResponse, ErrorResult& aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
const CacheOpArgs& SendAsOpArgs();
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
private:
|
2015-04-16 22:00:15 +03:00
|
|
|
TypeUtils* mTypeUtils;
|
|
|
|
CacheOpArgs mOpArgs;
|
2016-05-15 20:32:09 +03:00
|
|
|
nsTArray<UniquePtr<mozilla::ipc::AutoIPCStream>> mStreamCleanupList;
|
2015-04-16 22:00:15 +03:00
|
|
|
bool mSent;
|
2015-03-02 16:20:00 +03:00
|
|
|
};
|
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
class MOZ_STACK_CLASS AutoParentOpResult final
|
2015-03-02 16:20:00 +03:00
|
|
|
{
|
|
|
|
public:
|
2015-04-16 22:00:15 +03:00
|
|
|
AutoParentOpResult(mozilla::ipc::PBackgroundParent* aManager,
|
2016-05-15 20:32:09 +03:00
|
|
|
const CacheOpResult& aOpResult,
|
|
|
|
uint32_t aEntryCount);
|
2015-04-16 22:00:15 +03:00
|
|
|
~AutoParentOpResult();
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
void Add(CacheId aOpenedCacheId, Manager* aManager);
|
|
|
|
void Add(const SavedResponse& aSavedResponse, StreamList* aStreamList);
|
|
|
|
void Add(const SavedRequest& aSavedRequest, StreamList* aStreamList);
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
const CacheOpResult& SendAsOpResult();
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
private:
|
2015-04-16 22:00:15 +03:00
|
|
|
void SerializeResponseBody(const SavedResponse& aSavedResponse,
|
|
|
|
StreamList* aStreamList,
|
2015-04-16 22:00:15 +03:00
|
|
|
CacheResponse* aResponseOut);
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
void SerializeReadStream(const nsID& aId, StreamList* aStreamList,
|
2015-04-16 22:00:15 +03:00
|
|
|
CacheReadStream* aReadStreamOut);
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
mozilla::ipc::PBackgroundParent* mManager;
|
2015-04-16 22:00:15 +03:00
|
|
|
CacheOpResult mOpResult;
|
2015-03-02 16:20:00 +03:00
|
|
|
CacheStreamControlParent* mStreamControl;
|
2016-05-15 20:32:09 +03:00
|
|
|
nsTArray<UniquePtr<mozilla::ipc::AutoIPCStream>> mStreamCleanupList;
|
2015-03-02 16:20:00 +03:00
|
|
|
bool mSent;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace cache
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_cache_AutoUtils_h
|