| Index: content/browser/service_worker/service_worker_provider_host.cc
|
| diff --git a/content/browser/service_worker/service_worker_provider_host.cc b/content/browser/service_worker/service_worker_provider_host.cc
|
| index 4155af21b5d9d6cc497a3c8dde9004b228c74977..8112f3dd4977e6d0eafe3a6a726db7488c0bc901 100644
|
| --- a/content/browser/service_worker/service_worker_provider_host.cc
|
| +++ b/content/browser/service_worker/service_worker_provider_host.cc
|
| @@ -41,6 +41,27 @@ ServiceWorkerProviderHost::~ServiceWorkerProviderHost() {
|
| waiting_version_->RemovePotentialControllee(this);
|
| if (installing_version_)
|
| installing_version_->RemovePotentialControllee(this);
|
| + if (associated_registration_)
|
| + associated_registration_->RemoveListener(this);
|
| +}
|
| +
|
| +void ServiceWorkerProviderHost::OnVersionAttributesChanged(
|
| + ServiceWorkerRegistration* registration,
|
| + ChangedVersionAttributesMask changed_mask,
|
| + const ServiceWorkerRegistrationInfo& info) {
|
| + if (changed_mask.installing_changed())
|
| + SetInstallingVersion(registration->installing_version());
|
| + if (changed_mask.waiting_changed())
|
| + SetWaitingVersion(registration->waiting_version());
|
| + if (changed_mask.active_changed())
|
| + SetActiveVersion(registration->active_version());
|
| +}
|
| +
|
| +void ServiceWorkerProviderHost::OnRegistrationFailed(
|
| + ServiceWorkerRegistration* registration) {
|
| + DCHECK(associated_registration_);
|
| + DCHECK_EQ(registration->id(), associated_registration_->id());
|
| + UnassociateRegistration();
|
| }
|
|
|
| void ServiceWorkerProviderHost::SetDocumentUrl(const GURL& url) {
|
| @@ -159,6 +180,29 @@ bool ServiceWorkerProviderHost::SetHostedVersionId(int64 version_id) {
|
| return true;
|
| }
|
|
|
| +void ServiceWorkerProviderHost::AssociateRegistration(
|
| + ServiceWorkerRegistration* registration) {
|
| + DCHECK(CanAssociateRegistration(registration));
|
| + associated_registration_ = registration;
|
| + registration->AddListener(this);
|
| +
|
| + SetActiveVersion(registration->active_version());
|
| + SetInstallingVersion(registration->installing_version());
|
| + SetWaitingVersion(registration->waiting_version());
|
| +}
|
| +
|
| +void ServiceWorkerProviderHost::UnassociateRegistration() {
|
| + if (!associated_registration_)
|
| + return;
|
| + associated_registration_->RemoveListener(this);
|
| + associated_registration_ = NULL;
|
| +
|
| + SetActiveVersion(NULL);
|
| + SetInstallingVersion(NULL);
|
| + SetWaitingVersion(NULL);
|
| + SetControllerVersion(NULL);
|
| +}
|
| +
|
| scoped_ptr<ServiceWorkerRequestHandler>
|
| ServiceWorkerProviderHost::CreateRequestHandler(
|
| ResourceType resource_type,
|
| @@ -201,6 +245,17 @@ bool ServiceWorkerProviderHost::CanAssociateVersion(
|
| version->registration_id();
|
| }
|
|
|
| +bool ServiceWorkerProviderHost::CanAssociateRegistration(
|
| + ServiceWorkerRegistration* registration) {
|
| + if (!context_)
|
| + return false;
|
| + if (running_hosted_version_)
|
| + return false;
|
| + if (!registration || associated_registration_)
|
| + return false;
|
| + return true;
|
| +}
|
| +
|
| void ServiceWorkerProviderHost::PostMessage(
|
| const base::string16& message,
|
| const std::vector<int>& sent_message_port_ids) {
|
|
|