#include "content/browser/service_worker/service_worker_registration.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/observer_list.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "content/browser/service_worker/service_worker_client.h"
#include "content/browser/service_worker/service_worker_consts.h"
#include "content/browser/service_worker/service_worker_context_core.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/browser/service_worker/service_worker_info.h"
#include "content/browser/service_worker/service_worker_job_coordinator.h"
#include "content/browser/service_worker/service_worker_metrics.h"
#include "content/browser/service_worker/service_worker_register_job.h"
#include "content/browser/service_worker/service_worker_version.h"
#include "content/common/content_navigation_policy.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/blink/public/common/service_worker/embedded_worker_status.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_registration.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_registration_options.mojom.h"
namespace content {
namespace {
constexpr base::TimeDelta kSelfUpdateDelay = …;
constexpr base::TimeDelta kMaxSelfUpdateDelay = …;
constexpr base::TimeDelta kMaxLameDuckTime = …;
ServiceWorkerVersionInfo GetVersionInfo(ServiceWorkerVersion* version) { … }
}
scoped_refptr<ServiceWorkerRegistration> ServiceWorkerRegistration::Create(
const blink::mojom::ServiceWorkerRegistrationOptions& options,
const blink::StorageKey& key,
int64_t registration_id,
base::WeakPtr<ServiceWorkerContextCore> context,
blink::mojom::AncestorFrameType ancestor_frame_type) { … }
ServiceWorkerRegistration::ServiceWorkerRegistration(
const blink::mojom::ServiceWorkerRegistrationOptions& options,
const blink::StorageKey& key,
int64_t registration_id,
base::WeakPtr<ServiceWorkerContextCore> context,
blink::mojom::AncestorFrameType ancestor_frame_type)
: … { … }
ServiceWorkerRegistration::~ServiceWorkerRegistration() { … }
void ServiceWorkerRegistration::SetStatus(Status status) { … }
bool ServiceWorkerRegistration::IsStored() const { … }
void ServiceWorkerRegistration::SetStored() { … }
void ServiceWorkerRegistration::UnsetStored() { … }
ServiceWorkerVersion* ServiceWorkerRegistration::GetNewestVersion() const { … }
void ServiceWorkerRegistration::AddListener(Listener* listener) { … }
void ServiceWorkerRegistration::RemoveListener(Listener* listener) { … }
void ServiceWorkerRegistration::NotifyRegistrationFailed() { … }
void ServiceWorkerRegistration::NotifyUpdateFound() { … }
void ServiceWorkerRegistration::NotifyVersionAttributesChanged(
blink::mojom::ChangedServiceWorkerObjectsMaskPtr mask) { … }
ServiceWorkerRegistrationInfo ServiceWorkerRegistration::GetInfo() { … }
void ServiceWorkerRegistration::SetActiveVersion(
const scoped_refptr<ServiceWorkerVersion>& version) { … }
void ServiceWorkerRegistration::SetWaitingVersion(
const scoped_refptr<ServiceWorkerVersion>& version) { … }
void ServiceWorkerRegistration::SetInstallingVersion(
const scoped_refptr<ServiceWorkerVersion>& version) { … }
void ServiceWorkerRegistration::UnsetVersion(ServiceWorkerVersion* version) { … }
void ServiceWorkerRegistration::UnsetVersionInternal(
ServiceWorkerVersion* version,
blink::mojom::ChangedServiceWorkerObjectsMask* mask) { … }
void ServiceWorkerRegistration::SetUpdateViaCache(
blink::mojom::ServiceWorkerUpdateViaCache update_via_cache) { … }
void ServiceWorkerRegistration::ActivateWaitingVersionWhenReady() { … }
void ServiceWorkerRegistration::ClaimClients() { … }
void ServiceWorkerRegistration::DeleteAndClearWhenReady() { … }
void ServiceWorkerRegistration::DeleteAndClearImmediately() { … }
void ServiceWorkerRegistration::AbortPendingClear(StatusCallback callback) { … }
void ServiceWorkerRegistration::OnNoControllees(ServiceWorkerVersion* version) { … }
void ServiceWorkerRegistration::OnNoWork(ServiceWorkerVersion* version) { … }
bool ServiceWorkerRegistration::IsReadyToActivate() const { … }
bool ServiceWorkerRegistration::IsLameDuckActiveVersion() const { … }
void ServiceWorkerRegistration::StartLameDuckTimer() { … }
void ServiceWorkerRegistration::RemoveLameDuckIfNeeded() { … }
void ServiceWorkerRegistration::ActivateWaitingVersion(bool delay) { … }
void ServiceWorkerRegistration::ContinueActivation(
scoped_refptr<ServiceWorkerVersion> activating_version) { … }
void ServiceWorkerRegistration::ForceDelete() { … }
void ServiceWorkerRegistration::NotifyRegistrationFinished() { … }
void ServiceWorkerRegistration::SetTaskRunnerForTest(
scoped_refptr<base::SingleThreadTaskRunner> task_runner) { … }
void ServiceWorkerRegistration::EnableNavigationPreload(bool enable) { … }
void ServiceWorkerRegistration::SetNavigationPreloadHeader(
const std::string& header) { … }
void ServiceWorkerRegistration::RegisterRegistrationFinishedCallback(
base::OnceClosure callback) { … }
void ServiceWorkerRegistration::DispatchActivateEvent(
scoped_refptr<ServiceWorkerVersion> activating_version,
blink::ServiceWorkerStatusCode start_worker_status) { … }
void ServiceWorkerRegistration::OnActivateEventFinished(
scoped_refptr<ServiceWorkerVersion> activating_version,
blink::ServiceWorkerStatusCode status) { … }
void ServiceWorkerRegistration::OnDeleteFinished(
blink::ServiceWorkerStatusCode status) { … }
void ServiceWorkerRegistration::Clear() { … }
void ServiceWorkerRegistration::OnRestoreFinished(
StatusCallback callback,
scoped_refptr<ServiceWorkerVersion> version,
blink::ServiceWorkerStatusCode status) { … }
void ServiceWorkerRegistration::DelayUpdate(
ServiceWorkerVersion& version,
blink::mojom::FetchClientSettingsObjectPtr
outside_fetch_client_settings_object,
blink::mojom::ServiceWorkerRegistrationObjectHost::UpdateCallback
callback) { … }
void ServiceWorkerRegistration::ExecuteUpdate(
blink::mojom::FetchClientSettingsObjectPtr
outside_fetch_client_settings_object,
blink::mojom::ServiceWorkerRegistrationObjectHost::UpdateCallback
callback) { … }
void ServiceWorkerRegistration::UpdateComplete(
blink::mojom::ServiceWorkerRegistrationObjectHost::UpdateCallback callback,
blink::ServiceWorkerStatusCode status,
const std::string& status_message,
int64_t registration_id) { … }
std::string ServiceWorkerRegistration::ComposeUpdateErrorMessagePrefix(
const ServiceWorkerVersion* version_to_update) const { … }
}