2015-03-02 16:20:00 +03:00
|
|
|
/* -*- 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 "mozilla/dom/cache/ActorChild.h"
|
|
|
|
|
2016-06-23 11:53:14 +03:00
|
|
|
#include "mozilla/dom/cache/CacheWorkerHolder.h"
|
2015-04-16 22:00:16 +03:00
|
|
|
#include "nsThreadUtils.h"
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace cache {
|
|
|
|
|
|
|
|
void
|
2016-06-23 11:53:14 +03:00
|
|
|
ActorChild::SetWorkerHolder(CacheWorkerHolder* aWorkerHolder)
|
2015-03-02 16:20:00 +03:00
|
|
|
{
|
2015-03-04 17:14:25 +03:00
|
|
|
// Some of the Cache actors can have multiple DOM objects associated with
|
2016-06-23 11:53:14 +03:00
|
|
|
// them. In this case the workerHolder will be added multiple times. This is
|
|
|
|
// permitted, but the workerHolder should be the same each time.
|
|
|
|
if (mWorkerHolder) {
|
2017-01-06 23:41:15 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mWorkerHolder == aWorkerHolder);
|
2015-03-04 17:14:25 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-23 11:53:14 +03:00
|
|
|
mWorkerHolder = aWorkerHolder;
|
|
|
|
if (mWorkerHolder) {
|
|
|
|
mWorkerHolder->AddActor(this);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-06-23 11:53:14 +03:00
|
|
|
ActorChild::RemoveWorkerHolder()
|
2015-03-02 16:20:00 +03:00
|
|
|
{
|
2016-06-23 11:53:14 +03:00
|
|
|
MOZ_ASSERT_IF(!NS_IsMainThread(), mWorkerHolder);
|
|
|
|
if (mWorkerHolder) {
|
|
|
|
mWorkerHolder->RemoveActor(this);
|
|
|
|
mWorkerHolder = nullptr;
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-23 11:53:14 +03:00
|
|
|
CacheWorkerHolder*
|
|
|
|
ActorChild::GetWorkerHolder() const
|
2015-03-02 16:20:00 +03:00
|
|
|
{
|
2016-06-23 11:53:14 +03:00
|
|
|
return mWorkerHolder;
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2016-06-23 11:53:14 +03:00
|
|
|
ActorChild::WorkerHolderNotified() const
|
2015-03-02 16:20:00 +03:00
|
|
|
{
|
2016-06-23 11:53:14 +03:00
|
|
|
return mWorkerHolder && mWorkerHolder->Notified();
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
2015-03-16 17:10:36 +03:00
|
|
|
ActorChild::ActorChild()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-03-02 16:20:00 +03:00
|
|
|
ActorChild::~ActorChild()
|
|
|
|
{
|
2017-01-06 23:41:15 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!mWorkerHolder);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace cache
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|