Commit cd1e538a authored by Hiroki Nakagawa's avatar Hiroki Nakagawa Committed by Commit Bot

ServiceWorker: Rename "running_hosted_version" to "version"

This CL renames ServiceWorkerHost's running_hosted_version to version
because it's obvious that the version kept by ServiceWorkerHost is the
running hosted version.

Bug: 931087
Change-Id: Icfa6ae852418c7e089b254b19a745756fd6d3c74
Tbr: kinuko@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2206935
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771470}
parent 10bf4a61
......@@ -219,7 +219,7 @@ void BindBadgeServiceForServiceWorker(
FROM_HERE, content::BrowserThread::UI,
base::BindOnce(&BindBadgeServiceForServiceWorkerOnUI,
service_worker_host->worker_process_id(),
service_worker_host->running_hosted_version()->scope(),
service_worker_host->version()->scope(),
std::move(receiver)));
}
......@@ -938,8 +938,7 @@ void PopulateBinderMap(SharedWorkerHost* host, mojo::BinderMap* map) {
// Service workers
ServiceWorkerVersionInfo GetContextForHost(ServiceWorkerHost* host) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
return host->running_hosted_version()->GetInfo();
return host->version()->GetInfo();
}
void PopulateServiceWorkerBinders(ServiceWorkerHost* host,
......
......@@ -51,20 +51,20 @@ void CreateQuicTransportConnectorImpl(
ServiceWorkerHost::ServiceWorkerHost(
mojo::PendingAssociatedReceiver<blink::mojom::ServiceWorkerContainerHost>
host_receiver,
ServiceWorkerVersion* running_hosted_version,
ServiceWorkerVersion* version,
base::WeakPtr<ServiceWorkerContextCore> context)
: running_hosted_version_(running_hosted_version),
: version_(version),
container_host_(std::make_unique<content::ServiceWorkerContainerHost>(
std::move(context))),
host_receiver_(container_host_.get(), std::move(host_receiver)) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK(running_hosted_version_);
DCHECK(version_);
container_host_->set_service_worker_host(this);
container_host_->UpdateUrls(
running_hosted_version_->script_url(),
net::SiteForCookies::FromUrl(running_hosted_version_->script_url()),
running_hosted_version_->script_origin());
version_->script_url(),
net::SiteForCookies::FromUrl(version_->script_url()),
version_->script_origin());
}
ServiceWorkerHost::~ServiceWorkerHost() {
......@@ -75,8 +75,8 @@ ServiceWorkerHost::~ServiceWorkerHost() {
// that. Otherwise, this destructor can trigger their Mojo connection error
// handlers, which would call back into halfway destroyed |this|. This is
// because they are associated with the ServiceWorker interface, which can be
// destroyed while in this destructor (|running_hosted_version_|'s
// |event_dispatcher_|). See https://crbug.com/854993.
// destroyed while in this destructor (|version_|'s |event_dispatcher_|).
// See https://crbug.com/854993.
container_host_.reset();
}
......@@ -97,8 +97,7 @@ void ServiceWorkerHost::CreateQuicTransportConnector(
RunOrPostTaskOnThread(
FROM_HERE, BrowserThread::UI,
base::BindOnce(&CreateQuicTransportConnectorImpl, worker_process_id_,
running_hosted_version_->script_origin(),
std::move(receiver)));
version_->script_origin(), std::move(receiver)));
}
void ServiceWorkerHost::BindCacheStorage(
......@@ -106,8 +105,7 @@ void ServiceWorkerHost::BindCacheStorage(
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK(!base::FeatureList::IsEnabled(
blink::features::kEagerCacheStorageSetupForServiceWorkers));
running_hosted_version_->embedded_worker()->BindCacheStorage(
std::move(receiver));
version_->embedded_worker()->BindCacheStorage(std::move(receiver));
}
base::WeakPtr<ServiceWorkerHost> ServiceWorkerHost::GetWeakPtr() {
......
......@@ -48,14 +48,12 @@ class CONTENT_EXPORT ServiceWorkerHost {
public:
ServiceWorkerHost(mojo::PendingAssociatedReceiver<
blink::mojom::ServiceWorkerContainerHost> host_receiver,
ServiceWorkerVersion* running_hosted_version,
ServiceWorkerVersion* version,
base::WeakPtr<ServiceWorkerContextCore> context);
~ServiceWorkerHost();
int worker_process_id() const { return worker_process_id_; }
ServiceWorkerVersion* running_hosted_version() const {
return running_hosted_version_;
}
ServiceWorkerVersion* version() const { return version_; }
// Completes initialization of this provider host. It is called once a
// renderer process has been found to host the worker.
......@@ -83,7 +81,7 @@ class CONTENT_EXPORT ServiceWorkerHost {
// The service worker being hosted. Raw pointer is safe because the version
// owns |this|.
ServiceWorkerVersion* const running_hosted_version_;
ServiceWorkerVersion* const version_;
BrowserInterfaceBrokerImpl<ServiceWorkerHost, const ServiceWorkerVersionInfo&>
broker_{this};
......
......@@ -131,8 +131,7 @@ bool PrepareExtendableMessageEventFromServiceWorker(
worker->worker_host()
->container_host()
->GetOrCreateServiceWorkerObjectHost(
source_container_host->service_worker_host()
->running_hosted_version());
source_container_host->service_worker_host()->version());
if (service_worker_object_host) {
// CreateCompleteObjectInfoToSend() is safe because |source_worker_info|
// will be sent immediately by the caller of this function.
......@@ -289,9 +288,8 @@ void ServiceWorkerObjectHost::DispatchExtendableMessageEvent(
if (container_host_->IsContainerForServiceWorker()) {
// Clamp timeout to the sending worker's remaining timeout, to prevent
// postMessage from keeping workers alive forever.
base::TimeDelta timeout = container_host_->service_worker_host()
->running_hosted_version()
->remaining_timeout();
base::TimeDelta timeout =
container_host_->service_worker_host()->version()->remaining_timeout();
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
......
......@@ -187,7 +187,7 @@ void ServiceWorkerRegistrationObjectHost::Update(
// with an "InvalidStateError" DOMException and abort these steps.
ServiceWorkerVersion* version = nullptr;
if (container_host_->IsContainerForServiceWorker()) {
version = container_host_->service_worker_host()->running_hosted_version();
version = container_host_->service_worker_host()->version();
DCHECK(version);
if (ServiceWorkerVersion::Status::INSTALLING == version->status()) {
// This can happen if update() is called during execution of the
......
......@@ -36,8 +36,7 @@ ServiceWorkerScriptLoaderFactory::ServiceWorkerScriptLoaderFactory(
loader_factory_for_new_scripts_(
std::move(loader_factory_for_new_scripts)) {
DCHECK(loader_factory_for_new_scripts_ ||
ServiceWorkerVersion::IsInstalled(
worker_host_->running_hosted_version()->status()));
ServiceWorkerVersion::IsInstalled(worker_host_->version()->status()));
}
ServiceWorkerScriptLoaderFactory::~ServiceWorkerScriptLoaderFactory() = default;
......@@ -79,8 +78,7 @@ void ServiceWorkerScriptLoaderFactory::CreateLoaderAndStart(
// using ServiceWorkerNewScriptLoader.
// Case A and C:
scoped_refptr<ServiceWorkerVersion> version =
worker_host_->running_hosted_version();
scoped_refptr<ServiceWorkerVersion> version = worker_host_->version();
int64_t resource_id =
version->script_cache_map()->LookupResourceId(resource_request.url);
if (resource_id != blink::mojom::kInvalidServiceWorkerResourceId) {
......@@ -160,8 +158,7 @@ bool ServiceWorkerScriptLoaderFactory::CheckIfScriptRequestIsValid(
if (!context_ || !worker_host_)
return false;
scoped_refptr<ServiceWorkerVersion> version =
worker_host_->running_hosted_version();
scoped_refptr<ServiceWorkerVersion> version = worker_host_->version();
if (!version)
return false;
......@@ -206,8 +203,7 @@ void ServiceWorkerScriptLoaderFactory::CopyScript(
storage->CreateResponseReader(resource_id),
storage->CreateResponseWriter(new_resource_id));
scoped_refptr<ServiceWorkerVersion> version =
worker_host_->running_hosted_version();
scoped_refptr<ServiceWorkerVersion> version = worker_host_->version();
version->script_cache_map()->NotifyStartedCaching(url, new_resource_id);
net::Error error = cache_writer_->StartCopy(
......@@ -229,8 +225,7 @@ void ServiceWorkerScriptLoaderFactory::OnCopyScriptFinished(
net::Error error) {
int64_t resource_size = cache_writer_->bytes_written();
cache_writer_.reset();
scoped_refptr<ServiceWorkerVersion> version =
worker_host_->running_hosted_version();
scoped_refptr<ServiceWorkerVersion> version = worker_host_->version();
if (error != net::OK) {
version->script_cache_map()->NotifyFinishedCaching(
......@@ -274,8 +269,8 @@ void ServiceWorkerScriptLoaderFactory::OnResourceIdAssignedForNewScriptLoader(
mojo::MakeSelfOwnedReceiver(
ServiceWorkerNewScriptLoader::CreateAndStart(
routing_id, request_id, options, resource_request, std::move(client),
worker_host_->running_hosted_version(),
loader_factory_for_new_scripts_, traffic_annotation, resource_id),
worker_host_->version(), loader_factory_for_new_scripts_,
traffic_annotation, resource_id),
std::move(receiver));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment