mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 15:17:29 +09:00
Use a static mutex for getting deviceId keys in MediaParent.
This commit is contained in:
parent
47d488b84d
commit
60036bd843
1 changed files with 22 additions and 12 deletions
|
|
@ -37,6 +37,7 @@ mozilla::LazyLogModule gMediaParentLog("MediaParent");
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace media {
|
namespace media {
|
||||||
|
|
||||||
|
StaticMutex sOriginKeyStoreMutex;
|
||||||
static OriginKeyStore* sOriginKeyStore = nullptr;
|
static OriginKeyStore* sOriginKeyStore = nullptr;
|
||||||
|
|
||||||
class OriginKeyStore : public nsISupports
|
class OriginKeyStore : public nsISupports
|
||||||
|
|
@ -332,6 +333,7 @@ class OriginKeyStore : public nsISupports
|
||||||
private:
|
private:
|
||||||
virtual ~OriginKeyStore()
|
virtual ~OriginKeyStore()
|
||||||
{
|
{
|
||||||
|
StaticMutexAutoLock lock(sOriginKeyStoreMutex);
|
||||||
sOriginKeyStore = nullptr;
|
sOriginKeyStore = nullptr;
|
||||||
LOG((__FUNCTION__));
|
LOG((__FUNCTION__));
|
||||||
}
|
}
|
||||||
|
|
@ -340,6 +342,7 @@ public:
|
||||||
static OriginKeyStore* Get()
|
static OriginKeyStore* Get()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
StaticMutexAutoLock lock(sOriginKeyStoreMutex);
|
||||||
if (!sOriginKeyStore) {
|
if (!sOriginKeyStore) {
|
||||||
sOriginKeyStore = new OriginKeyStore();
|
sOriginKeyStore = new OriginKeyStore();
|
||||||
}
|
}
|
||||||
|
|
@ -384,8 +387,8 @@ Parent<Super>::RecvGetOriginKey(const uint32_t& aRequestId,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then over to stream-transport thread to do the actual file io.
|
// Then over to stream-transport thread (a thread pool) to do the actual
|
||||||
// Stash a pledge to hold the answer and get an id for this request.
|
// file io. Stash a pledge to hold the answer and get an id for this request.
|
||||||
|
|
||||||
RefPtr<Pledge<nsCString>> p = new Pledge<nsCString>();
|
RefPtr<Pledge<nsCString>> p = new Pledge<nsCString>();
|
||||||
uint32_t id = mOutstandingPledges.Append(*p);
|
uint32_t id = mOutstandingPledges.Append(*p);
|
||||||
|
|
@ -397,12 +400,17 @@ Parent<Super>::RecvGetOriginKey(const uint32_t& aRequestId,
|
||||||
rv = sts->Dispatch(NewRunnableFrom([this, that, id, profileDir, aOrigin,
|
rv = sts->Dispatch(NewRunnableFrom([this, that, id, profileDir, aOrigin,
|
||||||
aPrivateBrowsing, aPersist]() -> nsresult {
|
aPrivateBrowsing, aPersist]() -> nsresult {
|
||||||
MOZ_ASSERT(!NS_IsMainThread());
|
MOZ_ASSERT(!NS_IsMainThread());
|
||||||
mOriginKeyStore->mOriginKeys.SetProfileDir(profileDir);
|
StaticMutexAutoLock lock(sOriginKeyStoreMutex);
|
||||||
|
if (!sOriginKeyStore) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
sOriginKeyStore->mOriginKeys.SetProfileDir(profileDir);
|
||||||
|
|
||||||
nsCString result;
|
nsCString result;
|
||||||
if (aPrivateBrowsing) {
|
if (aPrivateBrowsing) {
|
||||||
mOriginKeyStore->mPrivateBrowsingOriginKeys.GetOriginKey(aOrigin, result);
|
sOriginKeyStore->mPrivateBrowsingOriginKeys.GetOriginKey(aOrigin, result);
|
||||||
} else {
|
} else {
|
||||||
mOriginKeyStore->mOriginKeys.GetOriginKey(aOrigin, result, aPersist);
|
sOriginKeyStore->mOriginKeys.GetOriginKey(aOrigin, result, aPersist);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass result back to main thread.
|
// Pass result back to main thread.
|
||||||
|
|
@ -450,19 +458,21 @@ Parent<Super>::RecvSanitizeOriginKeys(const uint64_t& aSinceWhen,
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Over to stream-transport thread to do the file io.
|
// Over to stream-transport thread (a thread pool) to do the file io.
|
||||||
|
|
||||||
nsCOMPtr<nsIEventTarget> sts = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
nsCOMPtr<nsIEventTarget> sts = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||||
MOZ_ASSERT(sts);
|
MOZ_ASSERT(sts);
|
||||||
RefPtr<OriginKeyStore> store(mOriginKeyStore);
|
rv = sts->Dispatch(NewRunnableFrom([profileDir, aSinceWhen,
|
||||||
|
|
||||||
rv = sts->Dispatch(NewRunnableFrom([profileDir, store, aSinceWhen,
|
|
||||||
aOnlyPrivateBrowsing]() -> nsresult {
|
aOnlyPrivateBrowsing]() -> nsresult {
|
||||||
MOZ_ASSERT(!NS_IsMainThread());
|
MOZ_ASSERT(!NS_IsMainThread());
|
||||||
store->mPrivateBrowsingOriginKeys.Clear(aSinceWhen);
|
StaticMutexAutoLock lock(sOriginKeyStoreMutex);
|
||||||
|
if (!sOriginKeyStore) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
sOriginKeyStore->mPrivateBrowsingOriginKeys.Clear(aSinceWhen);
|
||||||
if (!aOnlyPrivateBrowsing) {
|
if (!aOnlyPrivateBrowsing) {
|
||||||
store->mOriginKeys.SetProfileDir(profileDir);
|
sOriginKeyStore->mOriginKeys.SetProfileDir(profileDir);
|
||||||
store->mOriginKeys.Clear(aSinceWhen);
|
sOriginKeyStore->mOriginKeys.Clear(aSinceWhen);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}), NS_DISPATCH_NORMAL);
|
}), NS_DISPATCH_NORMAL);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue