зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 389e9f39d6b8 (bug 1397128)
This commit is contained in:
Родитель
8463726683
Коммит
2ecdeffe66
|
@ -106,25 +106,6 @@ CacheStreamControlChild::SerializeStream(CacheReadStream* aReadStreamOut,
|
|||
aStreamCleanupList.AppendElement(Move(autoStream));
|
||||
}
|
||||
|
||||
void
|
||||
CacheStreamControlChild::OpenStream(const nsID& aId, InputStreamResolver&& aResolver)
|
||||
{
|
||||
NS_ASSERT_OWNINGTHREAD(CacheStreamControlChild);
|
||||
|
||||
if (mDestroyStarted) {
|
||||
aResolver(nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
SendOpenStream(aId)->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[aResolver](const OptionalIPCStream& aOptionalStream) {
|
||||
nsCOMPtr<nsIInputStream> stream = DeserializeIPCStream(aOptionalStream);
|
||||
aResolver(Move(stream));
|
||||
}, [aResolver](PromiseRejectReason aReason) {
|
||||
aResolver(nullptr);
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
CacheStreamControlChild::NoteClosedAfterForget(const nsID& aId)
|
||||
{
|
||||
|
|
|
@ -40,9 +40,6 @@ public:
|
|||
SerializeStream(CacheReadStream* aReadStreamOut, nsIInputStream* aStream,
|
||||
nsTArray<UniquePtr<mozilla::ipc::AutoIPCStream>>& aStreamCleanupList) override;
|
||||
|
||||
virtual void
|
||||
OpenStream(const nsID& aId, InputStreamResolver&& aResolver) override;
|
||||
|
||||
private:
|
||||
virtual void
|
||||
NoteClosedAfterForget(const nsID& aId) override;
|
||||
|
|
|
@ -68,25 +68,6 @@ CacheStreamControlParent::SerializeStream(CacheReadStream* aReadStreamOut,
|
|||
aStreamCleanupList.AppendElement(Move(autoStream));
|
||||
}
|
||||
|
||||
void
|
||||
CacheStreamControlParent::OpenStream(const nsID& aId,
|
||||
InputStreamResolver&& aResolver)
|
||||
{
|
||||
NS_ASSERT_OWNINGTHREAD(CacheStreamControlParent);
|
||||
MOZ_DIAGNOSTIC_ASSERT(aResolver);
|
||||
|
||||
if (!mStreamList || !mStreamList->ShouldOpenStreamFor(aId)) {
|
||||
aResolver(nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure to add ourself as a Listener even thought we are using
|
||||
// a separate resolver function to signal the completion of the
|
||||
// operation. The Manager uses the existence of the Listener to ensure
|
||||
// that its safe to complete the operation.
|
||||
mStreamList->Manager()->ExecuteOpenStream(this, Move(aResolver), aId);
|
||||
}
|
||||
|
||||
void
|
||||
CacheStreamControlParent::NoteClosedAfterForget(const nsID& aId)
|
||||
{
|
||||
|
@ -112,37 +93,11 @@ CacheStreamControlParent::ActorDestroy(ActorDestroyReason aReason)
|
|||
if (!mStreamList) {
|
||||
return;
|
||||
}
|
||||
mStreamList->Manager()->RemoveListener(this);
|
||||
mStreamList->RemoveStreamControl(this);
|
||||
mStreamList->NoteClosedAll();
|
||||
mStreamList = nullptr;
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
CacheStreamControlParent::RecvOpenStream(const nsID& aStreamId,
|
||||
OpenStreamResolver&& aResolver)
|
||||
{
|
||||
NS_ASSERT_OWNINGTHREAD(CacheStreamControlParent);
|
||||
|
||||
// This is safe because:
|
||||
// 1. We add ourself to the Manager as an operation Listener in OpenStream().
|
||||
// 2. We remove ourself as a Listener from the Manager in ActorDestroy().
|
||||
// 3. The Manager will not "complete" the operation if the Listener has
|
||||
// been removed. This means the lambda will not be invoked.
|
||||
// 4. The ActorDestroy() will also cause the child-side MozPromise for
|
||||
// this async returning method to be rejected. So we don't have to
|
||||
// call the resolver in this case.
|
||||
CacheStreamControlParent* self = this;
|
||||
|
||||
OpenStream(aStreamId, [self, aResolver](nsCOMPtr<nsIInputStream>&& aStream) {
|
||||
AutoIPCStream stream;
|
||||
Unused << stream.Serialize(aStream, self->Manager());
|
||||
aResolver(stream.TakeOptionalValue());
|
||||
});
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
CacheStreamControlParent::RecvNoteClosed(const nsID& aId)
|
||||
{
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#ifndef mozilla_dom_cache_CacheStreamControlParent_h
|
||||
#define mozilla_dom_cache_CacheStreamControlParent_h
|
||||
|
||||
#include "mozilla/dom/cache/Manager.h"
|
||||
#include "mozilla/dom/cache/PCacheStreamControlParent.h"
|
||||
#include "mozilla/dom/cache/StreamControl.h"
|
||||
#include "nsTObserverArray.h"
|
||||
|
@ -24,7 +23,6 @@ class StreamList;
|
|||
|
||||
class CacheStreamControlParent final : public PCacheStreamControlParent
|
||||
, public StreamControl
|
||||
, Manager::Listener
|
||||
{
|
||||
public:
|
||||
CacheStreamControlParent();
|
||||
|
@ -43,9 +41,6 @@ public:
|
|||
SerializeStream(CacheReadStream* aReadStreamOut, nsIInputStream* aStream,
|
||||
nsTArray<UniquePtr<mozilla::ipc::AutoIPCStream>>& aStreamCleanupList) override;
|
||||
|
||||
virtual void
|
||||
OpenStream(const nsID& aId, InputStreamResolver&& aResolver) override;
|
||||
|
||||
private:
|
||||
virtual void
|
||||
NoteClosedAfterForget(const nsID& aId) override;
|
||||
|
@ -57,10 +52,6 @@ private:
|
|||
|
||||
// PCacheStreamControlParent methods
|
||||
virtual void ActorDestroy(ActorDestroyReason aReason) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult
|
||||
RecvOpenStream(const nsID& aStreamId, OpenStreamResolver&& aResolve) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvNoteClosed(const nsID& aId) override;
|
||||
|
||||
void NotifyClose(const nsID& aId);
|
||||
|
|
|
@ -1456,7 +1456,7 @@ class Manager::OpenStreamAction final : public Manager::BaseAction
|
|||
{
|
||||
public:
|
||||
OpenStreamAction(Manager* aManager, ListenerId aListenerId,
|
||||
InputStreamResolver&& aResolver, const nsID& aBodyId)
|
||||
OpenStreamResolver&& aResolver, const nsID& aBodyId)
|
||||
: BaseAction(aManager, aListenerId)
|
||||
, mResolver(Move(aResolver))
|
||||
, mBodyId(aBodyId)
|
||||
|
@ -1482,7 +1482,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
InputStreamResolver mResolver;
|
||||
OpenStreamResolver mResolver;
|
||||
const nsID mBodyId;
|
||||
nsCOMPtr<nsIInputStream> mBodyStream;
|
||||
};
|
||||
|
@ -1856,7 +1856,7 @@ Manager::ExecuteStorageOp(Listener* aListener, Namespace aNamespace,
|
|||
}
|
||||
|
||||
void
|
||||
Manager::ExecuteOpenStream(Listener* aListener, InputStreamResolver&& aResolver,
|
||||
Manager::ExecuteOpenStream(Listener* aListener, OpenStreamResolver&& aResolver,
|
||||
const nsID& aBodyId)
|
||||
{
|
||||
NS_ASSERT_OWNINGTHREAD(Manager);
|
||||
|
|
|
@ -177,7 +177,8 @@ public:
|
|||
void ExecuteStorageOp(Listener* aListener, Namespace aNamespace,
|
||||
const CacheOpArgs& aOpArgs);
|
||||
|
||||
void ExecuteOpenStream(Listener* aListener, InputStreamResolver&& aResolver,
|
||||
typedef std::function<void(nsCOMPtr<nsIInputStream>&&)> OpenStreamResolver;
|
||||
void ExecuteOpenStream(Listener* aListener, OpenStreamResolver&& aResolver,
|
||||
const nsID& aBodyId);
|
||||
|
||||
void
|
||||
|
|
|
@ -3,10 +3,6 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
include protocol PBackground;
|
||||
include protocol PFileDescriptorSet;
|
||||
include protocol PChildToParentStream;
|
||||
include protocol PParentToChildStream;
|
||||
include IPCStream;
|
||||
|
||||
using struct nsID from "nsID.h";
|
||||
|
||||
|
@ -19,7 +15,6 @@ protocol PCacheStreamControl
|
|||
manager PBackground;
|
||||
|
||||
parent:
|
||||
async OpenStream(nsID aStreamId) returns(OptionalIPCStream aStream);
|
||||
async NoteClosed(nsID aStreamId);
|
||||
|
||||
child:
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#define mozilla_dom_cache_StreamControl_h
|
||||
|
||||
#include "mozilla/dom/cache/ReadStream.h"
|
||||
#include "mozilla/dom/cache/Types.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsTObserverArray.h"
|
||||
|
||||
|
@ -37,9 +36,6 @@ public:
|
|||
SerializeStream(CacheReadStream* aReadStreamOut, nsIInputStream* aStream,
|
||||
nsTArray<UniquePtr<mozilla::ipc::AutoIPCStream>>& aStreamCleanupList) = 0;
|
||||
|
||||
virtual void
|
||||
OpenStream(const nsID& aId, InputStreamResolver&& aResolver) = 0;
|
||||
|
||||
// inherited implementation of the ReadStream::Controllable list
|
||||
|
||||
// Begin controlling the given ReadStream. This causes a strong ref to
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace mozilla {
|
|||
namespace dom {
|
||||
namespace cache {
|
||||
|
||||
StreamList::StreamList(cache::Manager* aManager, Context* aContext)
|
||||
StreamList::StreamList(Manager* aManager, Context* aContext)
|
||||
: mManager(aManager)
|
||||
, mContext(aContext)
|
||||
, mCacheId(INVALID_CACHE_ID)
|
||||
|
@ -26,27 +26,6 @@ StreamList::StreamList(cache::Manager* aManager, Context* aContext)
|
|||
mContext->AddActivity(this);
|
||||
}
|
||||
|
||||
Manager*
|
||||
StreamList::Manager() const
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(mManager);
|
||||
return mManager;
|
||||
}
|
||||
|
||||
bool
|
||||
StreamList::ShouldOpenStreamFor(const nsID& aId) const
|
||||
{
|
||||
NS_ASSERT_OWNINGTHREAD(StreamList);
|
||||
|
||||
for (auto entry : mList) {
|
||||
if (entry.mId == aId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
StreamList::SetStreamControl(CacheStreamControlParent* aStreamControl)
|
||||
{
|
||||
|
|
|
@ -24,10 +24,7 @@ class Manager;
|
|||
class StreamList final : public Context::Activity
|
||||
{
|
||||
public:
|
||||
StreamList(cache::Manager* aManager, Context* aContext);
|
||||
|
||||
Manager* Manager() const;
|
||||
bool ShouldOpenStreamFor(const nsID& aId) const;
|
||||
StreamList(Manager* aManager, Context* aContext);
|
||||
|
||||
void SetStreamControl(CacheStreamControlParent* aStreamControl);
|
||||
void RemoveStreamControl(CacheStreamControlParent* aStreamControl);
|
||||
|
@ -58,7 +55,7 @@ private:
|
|||
nsID mId;
|
||||
nsCOMPtr<nsIInputStream> mStream;
|
||||
};
|
||||
RefPtr<cache::Manager> mManager;
|
||||
RefPtr<Manager> mManager;
|
||||
RefPtr<Context> mContext;
|
||||
CacheId mCacheId;
|
||||
CacheStreamControlParent* mStreamControl;
|
||||
|
|
|
@ -7,11 +7,9 @@
|
|||
#ifndef mozilla_dom_cache_Types_h
|
||||
#define mozilla_dom_cache_Types_h
|
||||
|
||||
#include <functional>
|
||||
#include <stdint.h>
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -37,8 +35,6 @@ struct QuotaInfo
|
|||
nsCString mOrigin;
|
||||
};
|
||||
|
||||
typedef std::function<void(nsCOMPtr<nsIInputStream>&&)> InputStreamResolver;
|
||||
|
||||
} // namespace cache
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
Загрузка…
Ссылка в новой задаче