зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1252998 - StorageActivityService - part 7 - StorageActivityService in QuotaManager, r=janv
This commit is contained in:
Родитель
013a32f315
Коммит
e8bc84f98b
|
@ -36,6 +36,7 @@
|
|||
#include "mozilla/dom/quota/PQuotaParent.h"
|
||||
#include "mozilla/dom/quota/PQuotaRequestParent.h"
|
||||
#include "mozilla/dom/quota/PQuotaUsageRequestParent.h"
|
||||
#include "mozilla/dom/StorageActivityService.h"
|
||||
#include "mozilla/ipc/BackgroundParent.h"
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
#include "mozilla/IntegerRange.h"
|
||||
|
@ -3025,6 +3026,11 @@ QuotaObject::LockedMaybeUpdateSize(int64_t aSize, bool aTruncate)
|
|||
|
||||
quotaManager->mQuotaMutex.AssertCurrentThreadOwns();
|
||||
|
||||
if (mWritingDone == false && mOriginInfo) {
|
||||
mWritingDone = true;
|
||||
StorageActivityService::SendActivity(mOriginInfo->mOrigin);
|
||||
}
|
||||
|
||||
if (mQuotaCheckDisabled) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ private:
|
|||
, mPath(aPath)
|
||||
, mSize(aSize)
|
||||
, mQuotaCheckDisabled(false)
|
||||
, mWritingDone(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(QuotaObject);
|
||||
}
|
||||
|
@ -86,6 +87,7 @@ private:
|
|||
int64_t mSize;
|
||||
|
||||
bool mQuotaCheckDisabled;
|
||||
bool mWritingDone;
|
||||
};
|
||||
|
||||
END_QUOTA_NAMESPACE
|
||||
|
|
|
@ -64,6 +64,34 @@ StorageActivityService::SendActivity(const mozilla::ipc::PrincipalInfo& aPrincip
|
|||
SystemGroup::Dispatch(TaskCategory::Other, r.forget());
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
StorageActivityService::SendActivity(const nsACString& aOrigin)
|
||||
{
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
nsCString origin;
|
||||
origin.Assign(aOrigin);
|
||||
|
||||
RefPtr<Runnable> r = NS_NewRunnableFunction(
|
||||
"StorageActivityService::SendActivity",
|
||||
[origin] () {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
RefPtr<StorageActivityService> service = GetOrCreate();
|
||||
if (NS_WARN_IF(!service)) {
|
||||
return;
|
||||
}
|
||||
|
||||
service->SendActivityInternal(origin);
|
||||
});
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
Unused << r->Run();
|
||||
} else {
|
||||
SystemGroup::Dispatch(TaskCategory::Other, r.forget());
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<StorageActivityService>
|
||||
StorageActivityService::GetOrCreate()
|
||||
{
|
||||
|
@ -118,8 +146,15 @@ StorageActivityService::SendActivityInternal(nsIPrincipal* aPrincipal)
|
|||
return;
|
||||
}
|
||||
|
||||
mActivities.Put(origin, PR_Now());
|
||||
SendActivityInternal(origin);
|
||||
}
|
||||
|
||||
void
|
||||
StorageActivityService::SendActivityInternal(const nsACString& aOrigin)
|
||||
{
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
mActivities.Put(aOrigin, PR_Now());
|
||||
MaybeStartTimer();
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,10 @@ public:
|
|||
static void
|
||||
SendActivity(const mozilla::ipc::PrincipalInfo& aPrincipalInfo);
|
||||
|
||||
// Thread-safe but for parent process only!
|
||||
static void
|
||||
SendActivity(const nsACString& aOrigin);
|
||||
|
||||
// Used by XPCOM. Don't use it, use SendActivity() instead.
|
||||
static already_AddRefed<StorageActivityService>
|
||||
GetOrCreate();
|
||||
|
@ -50,6 +54,9 @@ private:
|
|||
void
|
||||
SendActivityInternal(nsIPrincipal* aPrincipal);
|
||||
|
||||
void
|
||||
SendActivityInternal(const nsACString& aOrigin);
|
||||
|
||||
void
|
||||
SendActivityToParent(nsIPrincipal* aPrincipal);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче