mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1619592 - Remove unused EnsureStorageAndOriginIsInitialized method; r=dom-workers-and-storage-reviewers,sg
Differential Revision: https://phabricator.services.mozilla.com/D65939
This commit is contained in:
parent
a6e62c857a
commit
a19671cf78
@ -362,10 +362,6 @@ mozilla::ipc::IPCResult QuotaRequestChild::Recv__delete__(
|
||||
aResponse.get_InitializeTemporaryOriginResponse().created());
|
||||
break;
|
||||
|
||||
case RequestResponse::TInitStorageAndOriginResponse:
|
||||
HandleResponse(aResponse.get_InitStorageAndOriginResponse().created());
|
||||
break;
|
||||
|
||||
case RequestResponse::TPersistedResponse:
|
||||
HandleResponse(aResponse.get_PersistedResponse().persisted());
|
||||
break;
|
||||
|
@ -1695,24 +1695,6 @@ class InitializeTemporaryOriginOp final : public InitializeOriginRequestBase {
|
||||
void GetResponse(RequestResponse& aResponse) override;
|
||||
};
|
||||
|
||||
class InitStorageAndOriginOp final : public QuotaRequestBase {
|
||||
nsCString mSuffix;
|
||||
nsCString mGroup;
|
||||
bool mCreated;
|
||||
|
||||
public:
|
||||
explicit InitStorageAndOriginOp(const RequestParams& aParams);
|
||||
|
||||
void Init(Quota& aQuota) override;
|
||||
|
||||
private:
|
||||
~InitStorageAndOriginOp() = default;
|
||||
|
||||
nsresult DoDirectoryWork(QuotaManager& aQuotaManager) override;
|
||||
|
||||
void GetResponse(RequestResponse& aResponse) override;
|
||||
};
|
||||
|
||||
class ResetOrClearOp final : public QuotaRequestBase {
|
||||
const bool mClear;
|
||||
|
||||
@ -6766,33 +6748,6 @@ already_AddRefed<DirectoryLock> QuotaManager::OpenDirectoryInternal(
|
||||
return blocked ? lock.forget() : nullptr;
|
||||
}
|
||||
|
||||
Result<nsCOMPtr<nsIFile>, nsresult>
|
||||
QuotaManager::EnsureStorageAndOriginIsInitialized(
|
||||
PersistenceType aPersistenceType, const QuotaInfo& aQuotaInfo) {
|
||||
AssertIsOnIOThread();
|
||||
|
||||
QM_TRY_RETURN(
|
||||
EnsureStorageAndOriginIsInitializedInternal(aPersistenceType, aQuotaInfo)
|
||||
.map([](const auto& res) { return res.first; }));
|
||||
}
|
||||
|
||||
Result<std::pair<nsCOMPtr<nsIFile>, bool>, nsresult>
|
||||
QuotaManager::EnsureStorageAndOriginIsInitializedInternal(
|
||||
PersistenceType aPersistenceType, const QuotaInfo& aQuotaInfo) {
|
||||
AssertIsOnIOThread();
|
||||
|
||||
QM_TRY(EnsureStorageIsInitialized());
|
||||
|
||||
if (aPersistenceType == PERSISTENCE_TYPE_PERSISTENT) {
|
||||
QM_TRY_RETURN(EnsurePersistentOriginIsInitialized(aQuotaInfo));
|
||||
}
|
||||
|
||||
QM_TRY(EnsureTemporaryStorageIsInitialized());
|
||||
|
||||
QM_TRY_RETURN(
|
||||
EnsureTemporaryOriginIsInitialized(aPersistenceType, aQuotaInfo));
|
||||
}
|
||||
|
||||
Result<std::pair<nsCOMPtr<nsIFile>, bool>, nsresult>
|
||||
QuotaManager::EnsurePersistentOriginIsInitialized(const QuotaInfo& aQuotaInfo) {
|
||||
AssertIsOnIOThread();
|
||||
@ -8573,24 +8528,6 @@ bool Quota::VerifyRequestParams(const RequestParams& aParams) const {
|
||||
break;
|
||||
}
|
||||
|
||||
case RequestParams::TInitStorageAndOriginParams: {
|
||||
const InitStorageAndOriginParams& params =
|
||||
aParams.get_InitStorageAndOriginParams();
|
||||
|
||||
if (NS_WARN_IF(
|
||||
!QuotaManager::IsPrincipalInfoValid(params.principalInfo()))) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!IsValidPersistenceType(params.persistenceType()))) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case RequestParams::TClearOriginParams: {
|
||||
const ClearResetOriginParams& params =
|
||||
aParams.get_ClearOriginParams().commonParams();
|
||||
@ -8821,9 +8758,6 @@ PQuotaRequestParent* Quota::AllocPQuotaRequestParent(
|
||||
case RequestParams::TInitializeTemporaryOriginParams:
|
||||
return MakeRefPtr<InitializeTemporaryOriginOp>(aParams);
|
||||
|
||||
case RequestParams::TInitStorageAndOriginParams:
|
||||
return MakeRefPtr<InitStorageAndOriginOp>(aParams);
|
||||
|
||||
case RequestParams::TClearOriginParams:
|
||||
return MakeRefPtr<ClearOriginOp>(aParams);
|
||||
|
||||
@ -9683,60 +9617,6 @@ void InitializeTemporaryOriginOp::GetResponse(RequestResponse& aResponse) {
|
||||
aResponse = InitializeTemporaryOriginResponse(mCreated);
|
||||
}
|
||||
|
||||
InitStorageAndOriginOp::InitStorageAndOriginOp(const RequestParams& aParams)
|
||||
: QuotaRequestBase(/* aExclusive */ false), mCreated(false) {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aParams.type() == RequestParams::TInitStorageAndOriginParams);
|
||||
|
||||
const InitStorageAndOriginParams& params =
|
||||
aParams.get_InitStorageAndOriginParams();
|
||||
|
||||
auto quotaInfo =
|
||||
QuotaManager::GetInfoFromValidatedPrincipalInfo(params.principalInfo());
|
||||
|
||||
// Overwrite OriginOperationBase default values.
|
||||
mNeedsQuotaManagerInit = true;
|
||||
mNeedsStorageInit = false;
|
||||
|
||||
// Overwrite NormalOriginOperationBase default values.
|
||||
mPersistenceType.SetValue(params.persistenceType());
|
||||
|
||||
mOriginScope.SetFromOrigin(quotaInfo.mOrigin);
|
||||
|
||||
// Overwrite InitStorageAndOriginOp default values.
|
||||
mSuffix = std::move(quotaInfo.mSuffix);
|
||||
mGroup = std::move(quotaInfo.mGroup);
|
||||
}
|
||||
|
||||
void InitStorageAndOriginOp::Init(Quota& aQuota) { AssertIsOnOwningThread(); }
|
||||
|
||||
nsresult InitStorageAndOriginOp::DoDirectoryWork(QuotaManager& aQuotaManager) {
|
||||
AssertIsOnIOThread();
|
||||
MOZ_ASSERT(!mPersistenceType.IsNull());
|
||||
|
||||
AUTO_PROFILER_LABEL("InitStorageAndOriginOp::DoDirectoryWork", OTHER);
|
||||
|
||||
QM_TRY_UNWRAP(
|
||||
mCreated,
|
||||
(aQuotaManager
|
||||
.EnsureStorageAndOriginIsInitializedInternal(
|
||||
mPersistenceType.Value(),
|
||||
QuotaInfo{mSuffix, mGroup, nsCString{mOriginScope.GetOrigin()}})
|
||||
.map([](const auto& res) { return res.second; })));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void InitStorageAndOriginOp::GetResponse(RequestResponse& aResponse) {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
InitStorageAndOriginResponse response;
|
||||
|
||||
response.created() = mCreated;
|
||||
|
||||
aResponse = response;
|
||||
}
|
||||
|
||||
ResetOrClearOp::ResetOrClearOp(bool aClear)
|
||||
: QuotaRequestBase(/* aExclusive */ true), mClear(aClear) {
|
||||
AssertIsOnOwningThread();
|
||||
|
@ -57,12 +57,6 @@ struct InitializeTemporaryOriginParams
|
||||
PrincipalInfo principalInfo;
|
||||
};
|
||||
|
||||
struct InitStorageAndOriginParams
|
||||
{
|
||||
PrincipalInfo principalInfo;
|
||||
PersistenceType persistenceType;
|
||||
};
|
||||
|
||||
struct AllUsageParams
|
||||
{
|
||||
bool getAll;
|
||||
@ -141,7 +135,6 @@ union RequestParams
|
||||
InitTemporaryStorageParams;
|
||||
InitializePersistentOriginParams;
|
||||
InitializeTemporaryOriginParams;
|
||||
InitStorageAndOriginParams;
|
||||
ClearOriginParams;
|
||||
ResetOriginParams;
|
||||
ClearDataParams;
|
||||
|
@ -41,11 +41,6 @@ struct InitializeTemporaryOriginResponse
|
||||
bool created;
|
||||
};
|
||||
|
||||
struct InitStorageAndOriginResponse
|
||||
{
|
||||
bool created;
|
||||
};
|
||||
|
||||
struct ClearOriginResponse
|
||||
{
|
||||
};
|
||||
@ -96,7 +91,6 @@ union RequestResponse
|
||||
InitTemporaryStorageResponse;
|
||||
InitializePersistentOriginResponse;
|
||||
InitializeTemporaryOriginResponse;
|
||||
InitStorageAndOriginResponse;
|
||||
ClearOriginResponse;
|
||||
ResetOriginResponse;
|
||||
ClearDataResponse;
|
||||
|
@ -338,19 +338,6 @@ class QuotaManager final : public BackgroundThreadObject {
|
||||
|
||||
nsresult EnsureStorageIsInitialized();
|
||||
|
||||
/**
|
||||
* @returns a Result with the success value pointing to the storage directory
|
||||
* for the origin.
|
||||
*/
|
||||
Result<nsCOMPtr<nsIFile>, nsresult> EnsureStorageAndOriginIsInitialized(
|
||||
PersistenceType aPersistenceType, const QuotaInfo& aQuotaInfo);
|
||||
|
||||
// Returns a pair of an nsIFile object referring to the directory, and a bool
|
||||
// indicating whether the directory was newly created.
|
||||
Result<std::pair<nsCOMPtr<nsIFile>, bool>, nsresult>
|
||||
EnsureStorageAndOriginIsInitializedInternal(PersistenceType aPersistenceType,
|
||||
const QuotaInfo& aQuotaInfo);
|
||||
|
||||
// Returns a pair of an nsIFile object referring to the directory, and a bool
|
||||
// indicating whether the directory was newly created.
|
||||
Result<std::pair<nsCOMPtr<nsIFile>, bool>, nsresult>
|
||||
|
@ -602,46 +602,6 @@ QuotaManagerService::InitializeTemporaryOrigin(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
QuotaManagerService::InitStorageAndOrigin(nsIPrincipal* aPrincipal,
|
||||
const nsACString& aPersistenceType,
|
||||
nsIQuotaRequest** _retval) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(nsContentUtils::IsCallerChrome());
|
||||
|
||||
if (NS_WARN_IF(!StaticPrefs::dom_quotaManager_testing())) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
RefPtr<Request> request = new Request();
|
||||
|
||||
InitStorageAndOriginParams params;
|
||||
|
||||
nsresult rv =
|
||||
CheckedPrincipalToPrincipalInfo(aPrincipal, params.principalInfo());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
const auto maybePersistenceType =
|
||||
PersistenceTypeFromString(aPersistenceType, fallible);
|
||||
if (NS_WARN_IF(maybePersistenceType.isNothing())) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
params.persistenceType() = maybePersistenceType.value();
|
||||
|
||||
RequestInfo info(request, params);
|
||||
|
||||
rv = InitiateRequest(info);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
request.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
QuotaManagerService::GetUsage(nsIQuotaUsageCallback* aCallback, bool aGetAll,
|
||||
nsIQuotaUsageRequest** _retval) {
|
||||
|
@ -93,24 +93,6 @@ interface nsIQuotaManagerService : nsISupports
|
||||
initializeTemporaryOrigin(in ACString aPersistenceType,
|
||||
in nsIPrincipal aPrincipal);
|
||||
|
||||
/**
|
||||
* Initializes storage directory, temporary storage (if persistence type is
|
||||
* default or temporary) and directory for the given origin. This can be used
|
||||
* in tests to verify origin initialization.
|
||||
*
|
||||
* If the dom.quotaManager.testing preference is not true the call will be
|
||||
* a no-op.
|
||||
*
|
||||
* @param aPrincipal
|
||||
* A principal for the origin whose directory is to be initialized.
|
||||
* @param aPersistenceType
|
||||
* A string that tells what persistence type of origin will be
|
||||
* initialized.
|
||||
*/
|
||||
[must_use] nsIQuotaRequest
|
||||
initStorageAndOrigin(in nsIPrincipal aPrincipal,
|
||||
in ACString aPersistenceType);
|
||||
|
||||
/**
|
||||
* Schedules an asynchronous callback that will inspect all origins and
|
||||
* return the total amount of disk space being used by storages for each
|
||||
|
@ -168,29 +168,6 @@ function initTemporaryOrigin(persistence, principal, callback) {
|
||||
return request;
|
||||
}
|
||||
|
||||
function initStorageAndOrigin(principal, persistence, callback) {
|
||||
let request = SpecialPowers._getQuotaManager().initStorageAndOrigin(
|
||||
principal,
|
||||
persistence
|
||||
);
|
||||
request.callback = callback;
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
function initStorageAndChromeOrigin(persistence, callback) {
|
||||
let principal = Cc["@mozilla.org/systemprincipal;1"].createInstance(
|
||||
Ci.nsIPrincipal
|
||||
);
|
||||
let request = SpecialPowers._getQuotaManager().initStorageAndOrigin(
|
||||
principal,
|
||||
persistence
|
||||
);
|
||||
request.callback = callback;
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
function clearClient(principal, persistence, client, callback) {
|
||||
let request = SpecialPowers._getQuotaManager().clearStoragesForPrincipal(
|
||||
principal,
|
||||
|
Loading…
Reference in New Issue
Block a user