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