mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 06:09:19 +00:00
Bug 1910848 - Replace custom OriginUsage with a common OriginUsageMetadata struct; r=dom-storage-reviewers,jari
This is a prerequisite to make GetUsageOp independent from the actor. Differential Revision: https://phabricator.services.mozilla.com/D194053
This commit is contained in:
parent
4b2b6abbcb
commit
d6b1701348
@ -125,7 +125,7 @@ void QuotaUsageRequestChild::HandleResponse(nsresult aResponse) {
|
||||
}
|
||||
|
||||
void QuotaUsageRequestChild::HandleResponse(
|
||||
const nsTArray<OriginUsage>& aResponse) {
|
||||
const OriginUsageMetadataArray& aResponse) {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(mRequest);
|
||||
|
||||
@ -138,8 +138,8 @@ void QuotaUsageRequestChild::HandleResponse(
|
||||
|
||||
for (const auto& originUsage : aResponse) {
|
||||
usageResults.AppendElement(MakeRefPtr<UsageResult>(
|
||||
originUsage.origin(), originUsage.persisted(), originUsage.usage(),
|
||||
originUsage.lastAccessed()));
|
||||
originUsage.mOrigin, originUsage.mPersisted, originUsage.mUsage,
|
||||
originUsage.mLastAccessTime));
|
||||
}
|
||||
|
||||
variant->SetAsArray(nsIDataType::VTYPE_INTERFACE_IS,
|
||||
@ -176,7 +176,7 @@ void QuotaUsageRequestChild::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult QuotaUsageRequestChild::Recv__delete__(
|
||||
const UsageRequestResponse& aResponse) {
|
||||
UsageRequestResponse&& aResponse) {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(mRequest);
|
||||
|
||||
|
@ -95,7 +95,7 @@ class QuotaUsageRequestChild final : public PQuotaUsageRequestChild {
|
||||
|
||||
void HandleResponse(nsresult aResponse);
|
||||
|
||||
void HandleResponse(const nsTArray<OriginUsage>& aResponse);
|
||||
void HandleResponse(const OriginUsageMetadataArray& aResponse);
|
||||
|
||||
void HandleResponse(const OriginUsageResponse& aResponse);
|
||||
|
||||
@ -103,7 +103,7 @@ class QuotaUsageRequestChild final : public PQuotaUsageRequestChild {
|
||||
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult Recv__delete__(
|
||||
const UsageRequestResponse& aResponse) override;
|
||||
UsageRequestResponse&& aResponse) override;
|
||||
};
|
||||
|
||||
class QuotaRequestChild final : public PQuotaRequestChild {
|
||||
|
@ -77,6 +77,15 @@ struct FullOriginMetadata : OriginMetadata {
|
||||
mLastAccessTime(aLastAccessTime) {}
|
||||
};
|
||||
|
||||
struct OriginUsageMetadata : FullOriginMetadata {
|
||||
uint64_t mUsage;
|
||||
|
||||
OriginUsageMetadata() = default;
|
||||
|
||||
OriginUsageMetadata(FullOriginMetadata aFullOriginMetadata, uint64_t aUsage)
|
||||
: FullOriginMetadata(std::move(aFullOriginMetadata)), mUsage(aUsage) {}
|
||||
};
|
||||
|
||||
struct ClientMetadata : OriginMetadata {
|
||||
Client::Type mClientType;
|
||||
|
||||
|
15
dom/quota/CommonMetadataArray.h
Normal file
15
dom/quota/CommonMetadataArray.h
Normal file
@ -0,0 +1,15 @@
|
||||
/* -*- 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 DOM_QUOTA_COMMONMETADATAARRAY_H_
|
||||
#define DOM_QUOTA_COMMONMETADATAARRAY_H_
|
||||
|
||||
#include "mozilla/dom/quota/CommonMetadataArrayFwd.h"
|
||||
|
||||
#include "mozilla/dom/quota/CommonMetadata.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#endif // DOM_QUOTA_COMMONMETADATAARRAY_H_
|
20
dom/quota/CommonMetadataArrayFwd.h
Normal file
20
dom/quota/CommonMetadataArrayFwd.h
Normal file
@ -0,0 +1,20 @@
|
||||
/* -*- 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 DOM_QUOTA_COMMONMETADATAARRAYFWD_H_
|
||||
#define DOM_QUOTA_COMMONMETADATAARRAYFWD_H_
|
||||
|
||||
#include "nsTArrayForwardDeclare.h"
|
||||
|
||||
namespace mozilla::dom::quota {
|
||||
|
||||
struct OriginUsageMetadata;
|
||||
|
||||
using OriginUsageMetadataArray = nsTArray<OriginUsageMetadata>;
|
||||
|
||||
} // namespace mozilla::dom::quota
|
||||
|
||||
#endif // DOM_QUOTA_COMMONMETADATAARRAYFWD_H_
|
@ -230,7 +230,7 @@ class GetUsageOp final
|
||||
: public OpenStorageDirectoryHelper<QuotaUsageRequestBase>,
|
||||
public TraverseRepositoryHelper,
|
||||
public OriginUsageHelper {
|
||||
nsTArray<OriginUsage> mOriginUsages;
|
||||
OriginUsageMetadataArray mOriginUsages;
|
||||
nsTHashMap<nsCStringHashKey, uint32_t> mOriginUsagesIndex;
|
||||
|
||||
bool mGetAll;
|
||||
@ -1292,17 +1292,24 @@ void GetUsageOp::ProcessOriginInternal(QuotaManager* aQuotaManager,
|
||||
|
||||
entry.Insert(mOriginUsages.Length());
|
||||
|
||||
return mOriginUsages.EmplaceBack(nsCString{aOrigin}, false, 0, 0);
|
||||
OriginUsageMetadata metadata;
|
||||
metadata.mOrigin = aOrigin;
|
||||
metadata.mPersistenceType = PERSISTENCE_TYPE_DEFAULT;
|
||||
metadata.mPersisted = false;
|
||||
metadata.mLastAccessTime = 0;
|
||||
metadata.mUsage = 0;
|
||||
|
||||
return mOriginUsages.EmplaceBack(std::move(metadata));
|
||||
});
|
||||
|
||||
if (aPersistenceType == PERSISTENCE_TYPE_DEFAULT) {
|
||||
originUsage->persisted() = aPersisted;
|
||||
originUsage->mPersisted = aPersisted;
|
||||
}
|
||||
|
||||
originUsage->usage() = originUsage->usage() + aUsage;
|
||||
originUsage->mUsage = originUsage->mUsage + aUsage;
|
||||
|
||||
originUsage->lastAccessed() =
|
||||
std::max<int64_t>(originUsage->lastAccessed(), aTimestamp);
|
||||
originUsage->mLastAccessTime =
|
||||
std::max<int64_t>(originUsage->mLastAccessTime, aTimestamp);
|
||||
}
|
||||
|
||||
const Atomic<bool>& GetUsageOp::GetIsCanceledFlag() {
|
||||
|
@ -6,6 +6,9 @@ include protocol PQuota;
|
||||
|
||||
include "mozilla/dom/quota/SerializationHelpers.h";
|
||||
|
||||
[MoveOnly] using mozilla::dom::quota::OriginUsageMetadataArray
|
||||
from "mozilla/dom/quota/CommonMetadataArray.h";
|
||||
|
||||
using mozilla::dom::quota::UsageInfo
|
||||
from "mozilla/dom/quota/UsageInfo.h";
|
||||
|
||||
@ -13,17 +16,9 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
namespace quota {
|
||||
|
||||
struct OriginUsage
|
||||
{
|
||||
nsCString origin;
|
||||
bool persisted;
|
||||
uint64_t usage;
|
||||
uint64_t lastAccessed;
|
||||
};
|
||||
|
||||
struct AllUsageResponse
|
||||
{
|
||||
OriginUsage[] originUsages;
|
||||
OriginUsageMetadataArray originUsages;
|
||||
};
|
||||
|
||||
struct OriginUsageResponse
|
||||
|
@ -36,7 +36,8 @@ void QuotaUsageRequestBase::SendResults() {
|
||||
response = mResultCode;
|
||||
}
|
||||
|
||||
Unused << PQuotaUsageRequestParent::Send__delete__(this, response);
|
||||
Unused << PQuotaUsageRequestParent::Send__delete__(this,
|
||||
std::move(response));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,23 @@ struct ParamTraits<mozilla::dom::quota::FullOriginMetadata> {
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::quota::OriginUsageMetadata> {
|
||||
using ParamType = mozilla::dom::quota::OriginUsageMetadata;
|
||||
|
||||
static void Write(MessageWriter* aWriter, const ParamType& aParam) {
|
||||
ParamTraits<mozilla::dom::quota::FullOriginMetadata>::Write(aWriter,
|
||||
aParam);
|
||||
WriteParam(aWriter, aParam.mUsage);
|
||||
}
|
||||
|
||||
static bool Read(MessageReader* aReader, ParamType* aResult) {
|
||||
return ParamTraits<mozilla::dom::quota::FullOriginMetadata>::Read(
|
||||
aReader, aResult) &&
|
||||
ReadParam(aReader, &aResult->mUsage);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::OriginAttributesPattern> {
|
||||
typedef mozilla::OriginAttributesPattern paramType;
|
||||
|
@ -38,6 +38,8 @@ EXPORTS.mozilla.dom.quota += [
|
||||
"Client.h",
|
||||
"ClientImpl.h",
|
||||
"CommonMetadata.h",
|
||||
"CommonMetadataArray.h",
|
||||
"CommonMetadataArrayFwd.h",
|
||||
"Config.h",
|
||||
"Constants.h",
|
||||
"DebugOnlyMacro.h",
|
||||
|
Loading…
x
Reference in New Issue
Block a user