зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1293277 P1 Capture StorageAccess when snapshoting ClientSource state. r=baku
This commit is contained in:
Родитель
4db2688a52
Коммит
64d85c2b66
|
@ -2957,6 +2957,8 @@ public:
|
|||
eSessionScoped = 2,
|
||||
// Allow access to the storage
|
||||
eAllow = 3,
|
||||
// Keep this at the end. Used for serialization, but not a valid value.
|
||||
eNumValues = 4,
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -10,6 +10,7 @@ include ProtocolTypes;
|
|||
using class mozilla::TimeStamp from "mozilla/TimeStamp.h";
|
||||
using ClientType from "mozilla/dom/ClientIPCUtils.h";
|
||||
using FrameType from "mozilla/dom/ClientIPCUtils.h";
|
||||
using nsContentUtils::StorageAccess from "mozilla/dom/ClientIPCUtils.h";
|
||||
using VisibilityState from "mozilla/dom/ClientIPCUtils.h";
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -37,11 +38,13 @@ struct IPCClientWindowState
|
|||
{
|
||||
VisibilityState visibilityState;
|
||||
TimeStamp lastFocusTime;
|
||||
StorageAccess storageAccess;
|
||||
bool focused;
|
||||
};
|
||||
|
||||
struct IPCClientWorkerState
|
||||
{
|
||||
StorageAccess storageAccess;
|
||||
};
|
||||
|
||||
union IPCClientState
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "mozilla/dom/ClientBinding.h"
|
||||
#include "mozilla/dom/ClientsBinding.h"
|
||||
#include "mozilla/dom/DocumentBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
namespace IPC {
|
||||
template<>
|
||||
|
@ -36,6 +37,13 @@ namespace IPC {
|
|||
mozilla::dom::VisibilityState::Hidden,
|
||||
mozilla::dom::VisibilityState::EndGuard_>
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct ParamTraits<nsContentUtils::StorageAccess> :
|
||||
public ContiguousEnumSerializer<nsContentUtils::StorageAccess,
|
||||
nsContentUtils::StorageAccess::eDeny,
|
||||
nsContentUtils::StorageAccess::eNumValues>
|
||||
{};
|
||||
} // namespace IPC
|
||||
|
||||
#endif // _mozilla_dom_ClientIPCUtils_h
|
||||
|
|
|
@ -78,7 +78,9 @@ ClientSource::SnapshotWindowState(ClientState* aStateOut)
|
|||
if (!window || !window->IsCurrentInnerWindow() ||
|
||||
!window->HasActiveDocument()) {
|
||||
*aStateOut = ClientState(ClientWindowState(VisibilityState::Hidden,
|
||||
TimeStamp(), false));
|
||||
TimeStamp(),
|
||||
nsContentUtils::StorageAccess::eDeny,
|
||||
false));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -94,8 +96,12 @@ ClientSource::SnapshotWindowState(ClientState* aStateOut)
|
|||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
nsContentUtils::StorageAccess storage =
|
||||
nsContentUtils::StorageAllowedForDocument(doc);
|
||||
|
||||
*aStateOut = ClientState(ClientWindowState(doc->VisibilityState(),
|
||||
doc->LastFocusTime(), focused));
|
||||
doc->LastFocusTime(), storage,
|
||||
focused));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -589,7 +595,18 @@ ClientSource::SnapshotState(ClientState* aStateOut)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
*aStateOut = ClientState(ClientWorkerState());
|
||||
WorkerPrivate* workerPrivate = GetWorkerPrivate();
|
||||
if (!workerPrivate) {
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
}
|
||||
|
||||
// Workers only keep a boolean for storage access at the moment.
|
||||
// Map this back to eAllow or eDeny for now.
|
||||
nsContentUtils::StorageAccess storage =
|
||||
workerPrivate->IsStorageAllowed() ? nsContentUtils::StorageAccess::eAllow
|
||||
: nsContentUtils::StorageAccess::eDeny;
|
||||
|
||||
*aStateOut = ClientState(ClientWorkerState(storage));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,10 @@ namespace dom {
|
|||
|
||||
ClientWindowState::ClientWindowState(mozilla::dom::VisibilityState aVisibilityState,
|
||||
const TimeStamp& aLastFocusTime,
|
||||
nsContentUtils::StorageAccess aStorageAccess,
|
||||
bool aFocused)
|
||||
: mData(MakeUnique<IPCClientWindowState>(aVisibilityState, aLastFocusTime,
|
||||
aFocused))
|
||||
aStorageAccess, aFocused))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -72,14 +73,20 @@ ClientWindowState::Focused() const
|
|||
return mData->focused();
|
||||
}
|
||||
|
||||
nsContentUtils::StorageAccess
|
||||
ClientWindowState::GetStorageAccess() const
|
||||
{
|
||||
return mData->storageAccess();
|
||||
}
|
||||
|
||||
const IPCClientWindowState&
|
||||
ClientWindowState::ToIPC() const
|
||||
{
|
||||
return *mData;
|
||||
}
|
||||
|
||||
ClientWorkerState::ClientWorkerState()
|
||||
: mData(MakeUnique<IPCClientWorkerState>())
|
||||
ClientWorkerState::ClientWorkerState(nsContentUtils::StorageAccess aStorageAccess)
|
||||
: mData(MakeUnique<IPCClientWorkerState>(aStorageAccess))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -118,6 +125,12 @@ ClientWorkerState::~ClientWorkerState()
|
|||
{
|
||||
}
|
||||
|
||||
nsContentUtils::StorageAccess
|
||||
ClientWorkerState::GetStorageAccess() const
|
||||
{
|
||||
return mData->storageAccess();
|
||||
}
|
||||
|
||||
const IPCClientWorkerState&
|
||||
ClientWorkerState::ToIPC() const
|
||||
{
|
||||
|
@ -202,6 +215,16 @@ ClientState::AsWorkerState() const
|
|||
return mData.ref().as<ClientWorkerState>();
|
||||
}
|
||||
|
||||
nsContentUtils::StorageAccess
|
||||
ClientState::GetStorageAccess() const
|
||||
{
|
||||
if (IsWindowState()) {
|
||||
return AsWindowState().GetStorageAccess();
|
||||
}
|
||||
|
||||
return AsWorkerState().GetStorageAccess();
|
||||
}
|
||||
|
||||
const IPCClientState
|
||||
ClientState::ToIPC() const
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -29,6 +30,7 @@ class ClientWindowState final
|
|||
public:
|
||||
ClientWindowState(mozilla::dom::VisibilityState aVisibilityState,
|
||||
const TimeStamp& aLastFocusTime,
|
||||
nsContentUtils::StorageAccess aStorageAccess,
|
||||
bool aFocused);
|
||||
|
||||
explicit ClientWindowState(const IPCClientWindowState& aData);
|
||||
|
@ -53,6 +55,9 @@ public:
|
|||
bool
|
||||
Focused() const;
|
||||
|
||||
nsContentUtils::StorageAccess
|
||||
GetStorageAccess() const;
|
||||
|
||||
const IPCClientWindowState&
|
||||
ToIPC() const;
|
||||
};
|
||||
|
@ -68,7 +73,7 @@ class ClientWorkerState final
|
|||
UniquePtr<IPCClientWorkerState> mData;
|
||||
|
||||
public:
|
||||
ClientWorkerState();
|
||||
explicit ClientWorkerState(nsContentUtils::StorageAccess aStorageAccess);
|
||||
|
||||
explicit ClientWorkerState(const IPCClientWorkerState& aData);
|
||||
|
||||
|
@ -83,6 +88,9 @@ public:
|
|||
|
||||
~ClientWorkerState();
|
||||
|
||||
nsContentUtils::StorageAccess
|
||||
GetStorageAccess() const;
|
||||
|
||||
const IPCClientWorkerState&
|
||||
ToIPC() const;
|
||||
};
|
||||
|
@ -128,6 +136,9 @@ public:
|
|||
const ClientWorkerState&
|
||||
AsWorkerState() const;
|
||||
|
||||
nsContentUtils::StorageAccess
|
||||
GetStorageAccess() const;
|
||||
|
||||
const IPCClientState
|
||||
ToIPC() const;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче