mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
c99a51f5f4
- Bug 1182963 - Use nsTHashTable::Iterator in FrameLayerBuilder. r=roc,njn Get rid of EnumerateEntries by inlining those enumerate functions. Also move gPaintedDisplayItemLayerUserData, gColorLayerUserData, etc. to the front of the file since LayerManagerData::Dump() references to one of them. (4215d86e0) - Bug 1182744 - Make MaskLayerImageKey::mLayerCount and its mutators private. r=dholbert (ae7381aee) - Bug 1182963 - Use nsTHashTable::Iterator in MaskLayerImageCache. r=njn (60770935a) - Bug 1182963 - Use nsTHashTable::Iterator in nsRefreshDriver. r=njn (311c72284) - Bug 1182963 - Use nsTHashTable::Iterator in nsPresShell. r=njn (ef8af9c5b) - Bug 1182963 - Use nsTHashTable::Iterator in nsPresContext. r=njn (e248de8c8) - Bug 1182973 - Use nsTHashtable::Iterator in dom/bindings/. r=bz. Changing the return type of Enumerator from PLDHashOperator to void -- possible because the only such functions always return PL_DHASH_NEXT -- is a double-win here. (68ad67b8c) - Bug 1182961 (part 1, attempt 2) - Use nsTHashtable::Iterator in CacheIndex. r=michal. (e84f52fdf) - Bug 1182961 (part 3, attempt 2) - Use nsTHashtable::Iterator in CacheIndex. r=michal. (b099c48a5) - Bug 1182961 (part 2, attempt 2) - Use nsTHashtable::Iterator in CacheIndex. r=michal. (ffccf9c18) - Bug 1182975 - Part 1: Use early return consistently when iterating over mBoundContentSet. r=wchen (8f7d57782) - Bug 1182975 - Part 2: Convert EnumRuleProcessors to use an iterator. r=wchen (7f36b3706) - Bug 1182975 - Part 3: Convert the rest of the uses of EnumerateEntries in nsBindingManager to Iterator(). r=wchen (c3caecad2) - Bug 1183158 - Part 1: Get rid of RegistrationEnumerator; r=baku (bdadc7d7b) - Bug 1183158 - Part 2: Get rid of SoftUpdateEnumerator; r=baku (d0133d02e) - Bug 1183158 - Part 3: Get rid of UnregisterEnumerator; r=baku (48e1e3396) - Bug 1183158 - Part 4: Get rid of RemoveEnumerator; r=baku (4ce903c6a) - Bug 1183158 - Part 5: Get rid of RemoveAllEnumerator; r=baku (9df9eea73)
236 lines
5.8 KiB
C++
236 lines
5.8 KiB
C++
/* -*- 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/. */
|
|
|
|
#include "ServiceWorkerManagerService.h"
|
|
#include "ServiceWorkerManagerParent.h"
|
|
#include "ServiceWorkerRegistrar.h"
|
|
#include "mozilla/ipc/BackgroundParent.h"
|
|
#include "mozilla/unused.h"
|
|
|
|
namespace mozilla {
|
|
|
|
using namespace ipc;
|
|
|
|
namespace dom {
|
|
namespace workers {
|
|
|
|
namespace {
|
|
|
|
ServiceWorkerManagerService* sInstance = nullptr;
|
|
|
|
} // anonymous namespace
|
|
|
|
ServiceWorkerManagerService::ServiceWorkerManagerService()
|
|
{
|
|
AssertIsOnBackgroundThread();
|
|
|
|
// sInstance is a raw ServiceWorkerManagerService*.
|
|
MOZ_ASSERT(!sInstance);
|
|
sInstance = this;
|
|
}
|
|
|
|
ServiceWorkerManagerService::~ServiceWorkerManagerService()
|
|
{
|
|
AssertIsOnBackgroundThread();
|
|
MOZ_ASSERT(sInstance == this);
|
|
MOZ_ASSERT(mAgents.Count() == 0);
|
|
|
|
sInstance = nullptr;
|
|
}
|
|
|
|
/* static */ already_AddRefed<ServiceWorkerManagerService>
|
|
ServiceWorkerManagerService::Get()
|
|
{
|
|
AssertIsOnBackgroundThread();
|
|
|
|
nsRefPtr<ServiceWorkerManagerService> instance = sInstance;
|
|
return instance.forget();
|
|
}
|
|
|
|
/* static */ already_AddRefed<ServiceWorkerManagerService>
|
|
ServiceWorkerManagerService::GetOrCreate()
|
|
{
|
|
AssertIsOnBackgroundThread();
|
|
|
|
nsRefPtr<ServiceWorkerManagerService> instance = sInstance;
|
|
if (!instance) {
|
|
instance = new ServiceWorkerManagerService();
|
|
}
|
|
return instance.forget();
|
|
}
|
|
|
|
void
|
|
ServiceWorkerManagerService::RegisterActor(ServiceWorkerManagerParent* aParent)
|
|
{
|
|
AssertIsOnBackgroundThread();
|
|
MOZ_ASSERT(aParent);
|
|
MOZ_ASSERT(!mAgents.Contains(aParent));
|
|
|
|
mAgents.PutEntry(aParent);
|
|
}
|
|
|
|
void
|
|
ServiceWorkerManagerService::UnregisterActor(ServiceWorkerManagerParent* aParent)
|
|
{
|
|
AssertIsOnBackgroundThread();
|
|
MOZ_ASSERT(aParent);
|
|
MOZ_ASSERT(mAgents.Contains(aParent));
|
|
|
|
mAgents.RemoveEntry(aParent);
|
|
}
|
|
|
|
void
|
|
ServiceWorkerManagerService::PropagateRegistration(
|
|
uint64_t aParentID,
|
|
ServiceWorkerRegistrationData& aData)
|
|
{
|
|
AssertIsOnBackgroundThread();
|
|
|
|
DebugOnly<bool> parentFound = false;
|
|
for (auto iter = mAgents.Iter(); !iter.Done(); iter.Next()) {
|
|
ServiceWorkerManagerParent* parent = iter.Get()->GetKey();
|
|
MOZ_ASSERT(parent);
|
|
|
|
if (parent->ID() != aParentID) {
|
|
unused << parent->SendNotifyRegister(aData);
|
|
#ifdef DEBUG
|
|
} else {
|
|
parentFound = true;
|
|
#endif
|
|
}
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
MOZ_ASSERT(parentFound);
|
|
#endif
|
|
}
|
|
|
|
void
|
|
ServiceWorkerManagerService::PropagateSoftUpdate(
|
|
uint64_t aParentID,
|
|
const OriginAttributes& aOriginAttributes,
|
|
const nsAString& aScope)
|
|
{
|
|
AssertIsOnBackgroundThread();
|
|
|
|
DebugOnly<bool> parentFound = false;
|
|
for (auto iter = mAgents.Iter(); !iter.Done(); iter.Next()) {
|
|
ServiceWorkerManagerParent* parent = iter.Get()->GetKey();
|
|
MOZ_ASSERT(parent);
|
|
|
|
if (parent->ID() != aParentID) {
|
|
nsString scope(aScope);
|
|
unused << parent->SendNotifySoftUpdate(aOriginAttributes,
|
|
scope);
|
|
#ifdef DEBUG
|
|
} else {
|
|
parentFound = true;
|
|
#endif
|
|
}
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
MOZ_ASSERT(parentFound);
|
|
#endif
|
|
}
|
|
|
|
void
|
|
ServiceWorkerManagerService::PropagateUnregister(
|
|
uint64_t aParentID,
|
|
const PrincipalInfo& aPrincipalInfo,
|
|
const nsAString& aScope)
|
|
{
|
|
AssertIsOnBackgroundThread();
|
|
|
|
nsRefPtr<dom::ServiceWorkerRegistrar> service =
|
|
dom::ServiceWorkerRegistrar::Get();
|
|
MOZ_ASSERT(service);
|
|
|
|
// It's possible that we don't have any ServiceWorkerManager managing this
|
|
// scope but we still need to unregister it from the ServiceWorkerRegistrar.
|
|
service->UnregisterServiceWorker(aPrincipalInfo,
|
|
NS_ConvertUTF16toUTF8(aScope));
|
|
|
|
DebugOnly<bool> parentFound = false;
|
|
for (auto iter = mAgents.Iter(); !iter.Done(); iter.Next()) {
|
|
ServiceWorkerManagerParent* parent = iter.Get()->GetKey();
|
|
MOZ_ASSERT(parent);
|
|
|
|
if (parent->ID() != aParentID) {
|
|
nsString scope(aScope);
|
|
unused << parent->SendNotifyUnregister(aPrincipalInfo, scope);
|
|
#ifdef DEBUG
|
|
} else {
|
|
parentFound = true;
|
|
#endif
|
|
}
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
MOZ_ASSERT(parentFound);
|
|
#endif
|
|
}
|
|
|
|
void
|
|
ServiceWorkerManagerService::PropagateRemove(uint64_t aParentID,
|
|
const nsACString& aHost)
|
|
{
|
|
AssertIsOnBackgroundThread();
|
|
|
|
DebugOnly<bool> parentFound = false;
|
|
for (auto iter = mAgents.Iter(); !iter.Done(); iter.Next()) {
|
|
ServiceWorkerManagerParent* parent = iter.Get()->GetKey();
|
|
MOZ_ASSERT(parent);
|
|
|
|
if (parent->ID() != aParentID) {
|
|
nsCString host(aHost);
|
|
unused << parent->SendNotifyRemove(host);
|
|
#ifdef DEBUG
|
|
} else {
|
|
parentFound = true;
|
|
#endif
|
|
}
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
MOZ_ASSERT(parentFound);
|
|
#endif
|
|
}
|
|
|
|
void
|
|
ServiceWorkerManagerService::PropagateRemoveAll(uint64_t aParentID)
|
|
{
|
|
AssertIsOnBackgroundThread();
|
|
|
|
nsRefPtr<dom::ServiceWorkerRegistrar> service =
|
|
dom::ServiceWorkerRegistrar::Get();
|
|
MOZ_ASSERT(service);
|
|
|
|
service->RemoveAll();
|
|
|
|
DebugOnly<bool> parentFound = false;
|
|
for (auto iter = mAgents.Iter(); !iter.Done(); iter.Next()) {
|
|
ServiceWorkerManagerParent* parent = iter.Get()->GetKey();
|
|
MOZ_ASSERT(parent);
|
|
|
|
if (parent->ID() != aParentID) {
|
|
unused << parent->SendNotifyRemoveAll();
|
|
#ifdef DEBUG
|
|
} else {
|
|
parentFound = true;
|
|
#endif
|
|
}
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
MOZ_ASSERT(parentFound);
|
|
#endif
|
|
}
|
|
|
|
} // workers namespace
|
|
} // dom namespace
|
|
} // mozilla namespace
|