Backed out 3 changesets (bug 1422314, bug 1420594) for failing xpcshell/test_ext_contentScripts_register.js on Android debug r=backout a=backout

Backed out changeset f5a3054a4c38 (bug 1420594)
Backed out changeset 7908b821ad3f (bug 1420594)
Backed out changeset b89daf5c23b8 (bug 1422314)
This commit is contained in:
Dorel Luca 2017-12-04 15:35:07 +02:00
parent 4302452fdf
commit ba2b0cf4d1
9 changed files with 16 additions and 301 deletions

View File

@ -37,12 +37,5 @@ DeallocClientManagerParent(PClientManagerParent* aActor)
return true;
}
void
InitClientManagerParent(PClientManagerParent* aActor)
{
auto actor = static_cast<ClientManagerParent*>(aActor);
actor->Init();
}
} // namespace dom
} // namespace mozilla

View File

@ -24,9 +24,6 @@ AllocClientManagerParent();
bool
DeallocClientManagerParent(PClientManagerParent* aActor);
void
InitClientManagerParent(PClientManagerParent* aActor);
} // namespace dom
} // namespace mozilla

View File

@ -117,13 +117,6 @@ ClientManagerParent::ClientManagerParent()
ClientManagerParent::~ClientManagerParent()
{
mService->RemoveManager(this);
}
void
ClientManagerParent::Init()
{
mService->AddManager(this);
}
} // namespace dom

View File

@ -63,9 +63,6 @@ class ClientManagerParent final : public PClientManagerParent
public:
ClientManagerParent();
~ClientManagerParent();
void
Init();
};
} // namespace dom

View File

@ -6,13 +6,9 @@
#include "ClientManagerService.h"
#include "ClientManagerParent.h"
#include "ClientSourceParent.h"
#include "mozilla/ipc/BackgroundParent.h"
#include "mozilla/ipc/PBackgroundSharedTypes.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/SystemGroup.h"
#include "nsIAsyncShutdown.h"
namespace mozilla {
namespace dom {
@ -60,137 +56,22 @@ MatchPrincipalInfo(const PrincipalInfo& aLeft, const PrincipalInfo& aRight)
MOZ_CRASH("unexpected principal type!");
}
class ClientShutdownBlocker final : public nsIAsyncShutdownBlocker
{
RefPtr<GenericPromise::Private> mPromise;
~ClientShutdownBlocker() = default;
public:
explicit ClientShutdownBlocker(GenericPromise::Private* aPromise)
: mPromise(aPromise)
{
MOZ_DIAGNOSTIC_ASSERT(mPromise);
}
NS_IMETHOD
GetName(nsAString& aNameOut) override
{
aNameOut =
NS_LITERAL_STRING("ClientManagerService: start destroying IPC actors early");
return NS_OK;
}
NS_IMETHOD
BlockShutdown(nsIAsyncShutdownClient* aClient) override
{
mPromise->Resolve(true, __func__);
aClient->RemoveBlocker(this);
return NS_OK;
}
NS_IMETHOD
GetState(nsIPropertyBag**) override
{
return NS_OK;
}
NS_DECL_ISUPPORTS
};
NS_IMPL_ISUPPORTS(ClientShutdownBlocker, nsIAsyncShutdownBlocker)
// Helper function the resolves a MozPromise when we detect that the browser
// has begun to shutdown.
RefPtr<GenericPromise>
OnShutdown()
{
RefPtr<GenericPromise::Private> ref = new GenericPromise::Private(__func__);
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction("ClientManagerServer::OnShutdown",
[ref] () {
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdown();
if (!svc) {
ref->Resolve(true, __func__);
return;
}
nsCOMPtr<nsIAsyncShutdownClient> phase;
MOZ_ALWAYS_SUCCEEDS(svc->GetXpcomWillShutdown(getter_AddRefs(phase)));
if (!phase) {
ref->Resolve(true, __func__);
return;
}
nsCOMPtr<nsIAsyncShutdownBlocker> blocker = new ClientShutdownBlocker(ref);
nsresult rv =
phase->AddBlocker(blocker, NS_LITERAL_STRING(__FILE__), __LINE__,
NS_LITERAL_STRING("ClientManagerService shutdown"));
if (NS_FAILED(rv)) {
ref->Resolve(true, __func__);
return;
}
});
MOZ_ALWAYS_SUCCEEDS(
SystemGroup::Dispatch(TaskCategory::Other, r.forget()));
return ref.forget();
}
} // anonymous namespace
ClientManagerService::ClientManagerService()
: mShutdown(false)
{
AssertIsOnBackgroundThread();
// While the ClientManagerService will be gracefully terminated as windows
// and workers are naturally killed, this can cause us to do extra work
// relatively late in the shutdown process. To avoid this we eagerly begin
// shutdown at the first sign it has begun. Since we handle normal shutdown
// gracefully we don't really need to block anything here. We just begin
// destroying our IPC actors immediately.
OnShutdown()->Then(GetCurrentThreadSerialEventTarget(), __func__,
[] () {
RefPtr<ClientManagerService> svc = ClientManagerService::GetInstance();
if (svc) {
svc->Shutdown();
}
});
}
ClientManagerService::~ClientManagerService()
{
AssertIsOnBackgroundThread();
MOZ_DIAGNOSTIC_ASSERT(mSourceTable.Count() == 0);
MOZ_DIAGNOSTIC_ASSERT(mManagerList.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(sClientManagerServiceInstance == this);
sClientManagerServiceInstance = nullptr;
}
void
ClientManagerService::Shutdown()
{
AssertIsOnBackgroundThread();
// If many ClientManagerService are created and destroyed quickly we can
// in theory get more than one shutdown listener calling us.
if (mShutdown) {
return;
}
mShutdown = true;
// Begin destroying our various manager actors which will in turn destroy
// all source, handle, and operation actors.
AutoTArray<ClientManagerParent*, 16> list(mManagerList);
for (auto actor : list) {
Unused << PClientManagerParent::Send__delete__(actor);
}
}
// static
already_AddRefed<ClientManagerService>
ClientManagerService::GetOrCreateInstance()
@ -205,20 +86,6 @@ ClientManagerService::GetOrCreateInstance()
return ref.forget();
}
// static
already_AddRefed<ClientManagerService>
ClientManagerService::GetInstance()
{
AssertIsOnBackgroundThread();
if (!sClientManagerServiceInstance) {
return nullptr;
}
RefPtr<ClientManagerService> ref(sClientManagerServiceInstance);
return ref.forget();
}
bool
ClientManagerService::AddSource(ClientSourceParent* aSource)
{
@ -267,28 +134,5 @@ ClientManagerService::FindSource(const nsID& aID, const PrincipalInfo& aPrincipa
return source;
}
void
ClientManagerService::AddManager(ClientManagerParent* aManager)
{
AssertIsOnBackgroundThread();
MOZ_DIAGNOSTIC_ASSERT(aManager);
MOZ_ASSERT(!mManagerList.Contains(aManager));
mManagerList.AppendElement(aManager);
// If shutdown has already begun then immediately destroy the actor.
if (mShutdown) {
Unused << PClientManagerParent::Send__delete__(aManager);
}
}
void
ClientManagerService::RemoveManager(ClientManagerParent* aManager)
{
AssertIsOnBackgroundThread();
MOZ_DIAGNOSTIC_ASSERT(aManager);
DebugOnly<bool> removed = mManagerList.RemoveElement(aManager);
MOZ_ASSERT(removed);
}
} // namespace dom
} // namespace mozilla

View File

@ -7,14 +7,12 @@
#define _mozilla_dom_ClientManagerService_h
#include "mozilla/ipc/PBackgroundSharedTypes.h"
#include "mozilla/MozPromise.h"
#include "nsDataHashtable.h"
namespace mozilla {
namespace dom {
class ClientManagerParent;
class ClientSourceParent;
// Define a singleton service to manage client activity throughout the
@ -26,24 +24,13 @@ class ClientManagerService final
// optimize for insertion, removal, and lookup by UUID.
nsDataHashtable<nsIDHashKey, ClientSourceParent*> mSourceTable;
nsTArray<ClientManagerParent*> mManagerList;
bool mShutdown;
ClientManagerService();
~ClientManagerService();
void
Shutdown();
public:
static already_AddRefed<ClientManagerService>
GetOrCreateInstance();
// Returns nullptr if the service is not already created.
static already_AddRefed<ClientManagerService>
GetInstance();
bool
AddSource(ClientSourceParent* aSource);
@ -54,12 +41,6 @@ public:
FindSource(const nsID& aID,
const mozilla::ipc::PrincipalInfo& aPrincipalInfo);
void
AddManager(ClientManagerParent* aManager);
void
RemoveManager(ClientManagerParent* aManager);
NS_INLINE_DECL_REFCOUNTING(mozilla::dom::ClientManagerService)
};

View File

@ -23,7 +23,6 @@
#include "nsContentUtils.h"
#include "nsError.h"
#include "nsHostObjectURI.h"
#include "nsIAsyncShutdown.h"
#include "nsIMemoryReporter.h"
#include "nsIPrincipal.h"
#include "nsIUUIDGenerator.h"
@ -438,7 +437,6 @@ NS_IMPL_ISUPPORTS(BlobURLsReporter, nsIMemoryReporter)
class ReleasingTimerHolder final : public nsITimerCallback
, public nsINamed
, public nsIAsyncShutdownBlocker
{
public:
NS_DECL_ISUPPORTS
@ -446,98 +444,27 @@ public:
static void
Create(const nsACString& aURI, bool aBroadcastToOtherProcesses)
{
MOZ_ASSERT(NS_IsMainThread());
RefPtr<ReleasingTimerHolder> holder =
new ReleasingTimerHolder(aURI, aBroadcastToOtherProcesses);
auto raii = mozilla::MakeScopeExit([&] {
holder->CancelTimerAndRevokeURI();
});
nsresult rv = NS_NewTimerWithCallback(getter_AddRefs(holder->mTimer),
holder, RELEASING_TIMER,
nsITimer::TYPE_ONE_SHOT,
SystemGroup::EventTargetFor(TaskCategory::Other));
NS_ENSURE_SUCCESS_VOID(rv);
nsCOMPtr<nsIAsyncShutdownClient> phase = GetShutdownPhase();
NS_ENSURE_TRUE_VOID(!!phase);
rv = phase->AddBlocker(holder, NS_LITERAL_STRING(__FILE__), __LINE__,
NS_LITERAL_STRING("ReleasingTimerHolder shutdown"));
NS_ENSURE_SUCCESS_VOID(rv);
raii.release();
}
// nsITimerCallback interface
NS_IMETHOD
Notify(nsITimer* aTimer) override
{
RevokeURI(mBroadcastToOtherProcesses);
return NS_OK;
}
// nsINamed interface
NS_IMETHOD
GetName(nsACString& aName) override
{
aName.AssignLiteral("ReleasingTimerHolder");
return NS_OK;
}
// nsIAsyncShutdownBlocker interface
NS_IMETHOD
GetName(nsAString& aName) override
{
aName.AssignLiteral("ReleasingTimerHolder");
return NS_OK;
}
NS_IMETHOD
BlockShutdown(nsIAsyncShutdownClient* aClient) override
{
CancelTimerAndRevokeURI();
return NS_OK;
}
NS_IMETHOD
GetState(nsIPropertyBag**) override
{
return NS_OK;
}
private:
ReleasingTimerHolder(const nsACString& aURI, bool aBroadcastToOtherProcesses)
: mURI(aURI)
, mBroadcastToOtherProcesses(aBroadcastToOtherProcesses)
{}
~ReleasingTimerHolder()
{}
void
RevokeURI(bool aBroadcastToOtherProcesses)
{
// Remove the shutting down blocker
nsCOMPtr<nsIAsyncShutdownClient> phase = GetShutdownPhase();
if (phase) {
phase->RemoveBlocker(this);
}
// If we have to broadcast the unregistration, let's do it now.
if (aBroadcastToOtherProcesses) {
if (mBroadcastToOtherProcesses) {
BroadcastBlobURLUnregistration(mURI);
}
DataInfo* info = GetDataInfo(mURI, true /* We care about revoked dataInfo */);
if (!info) {
// Already gone!
return;
return NS_OK;
}
MOZ_ASSERT(info->mRevoked);
@ -554,31 +481,25 @@ private:
delete gDataTable;
gDataTable = nullptr;
}
return NS_OK;
}
void
CancelTimerAndRevokeURI()
NS_IMETHOD
GetName(nsACString& aName) override
{
if (mTimer) {
mTimer->Cancel();
mTimer = nullptr;
}
RevokeURI(false /* aBroadcastToOtherProcesses */);
aName.AssignLiteral("ReleasingTimerHolder");
return NS_OK;
}
static nsCOMPtr<nsIAsyncShutdownClient>
GetShutdownPhase()
{
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdown();
NS_ENSURE_TRUE(!!svc, nullptr);
private:
ReleasingTimerHolder(const nsACString& aURI, bool aBroadcastToOtherProcesses)
: mURI(aURI)
, mBroadcastToOtherProcesses(aBroadcastToOtherProcesses)
{}
nsCOMPtr<nsIAsyncShutdownClient> phase;
nsresult rv = svc->GetXpcomWillShutdown(getter_AddRefs(phase));
NS_ENSURE_SUCCESS(rv, nullptr);
return Move(phase);
}
~ReleasingTimerHolder()
{}
nsCString mURI;
bool mBroadcastToOtherProcesses;
@ -586,8 +507,7 @@ private:
nsCOMPtr<nsITimer> mTimer;
};
NS_IMPL_ISUPPORTS(ReleasingTimerHolder, nsITimerCallback, nsINamed,
nsIAsyncShutdownBlocker)
NS_IMPL_ISUPPORTS(ReleasingTimerHolder, nsITimerCallback, nsINamed)
} // namespace mozilla

View File

@ -980,13 +980,6 @@ BackgroundParentImpl::DeallocPClientManagerParent(mozilla::dom::PClientManagerPa
return mozilla::dom::DeallocClientManagerParent(aActor);
}
mozilla::ipc::IPCResult
BackgroundParentImpl::RecvPClientManagerConstructor(mozilla::dom::PClientManagerParent* aActor)
{
mozilla::dom::InitClientManagerParent(aActor);
return IPC_OK();
}
} // namespace ipc
} // namespace mozilla

View File

@ -268,9 +268,6 @@ protected:
virtual bool
DeallocPClientManagerParent(PClientManagerParent* aActor) override;
virtual mozilla::ipc::IPCResult
RecvPClientManagerConstructor(PClientManagerParent* aActor) override;
};
} // namespace ipc