| 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 67b10a78ecc5f67db3558614ad66363396779441..a409d2a2bebe66e69979bb094c86fded2ce0dcf2 100644
|
| --- a/content/browser/service_worker/service_worker_provider_host.cc
|
| +++ b/content/browser/service_worker/service_worker_provider_host.cc
|
| @@ -103,10 +103,7 @@ ServiceWorkerProviderHost::~ServiceWorkerProviderHost() {
|
| if (controlling_version_.get())
|
| controlling_version_->RemoveControllee(this);
|
|
|
| - for (auto& key_registration : matching_registrations_) {
|
| - DecreaseProcessReference(key_registration.second->pattern());
|
| - key_registration.second->RemoveListener(this);
|
| - }
|
| + RemoveAllMatchingRegistrations();
|
|
|
| for (const GURL& pattern : associated_patterns_)
|
| DecreaseProcessReference(pattern);
|
| @@ -182,6 +179,8 @@ void ServiceWorkerProviderHost::OnSkippedWaiting(
|
| void ServiceWorkerProviderHost::SetDocumentUrl(const GURL& url) {
|
| DCHECK(!url.has_ref());
|
| document_url_ = url;
|
| + if (IsProviderForClient())
|
| + SyncMatchingRegistrations();
|
| }
|
|
|
| void ServiceWorkerProviderHost::SetTopmostFrameUrl(const GURL& url) {
|
| @@ -306,19 +305,6 @@ void ServiceWorkerProviderHost::RemoveMatchingRegistration(
|
| matching_registrations_.erase(key);
|
| }
|
|
|
| -void ServiceWorkerProviderHost::AddAllMatchingRegistrations() {
|
| - DCHECK(context_);
|
| - const std::map<int64_t, ServiceWorkerRegistration*>& registrations =
|
| - context_->GetLiveRegistrations();
|
| - for (const auto& key_registration : registrations) {
|
| - ServiceWorkerRegistration* registration = key_registration.second;
|
| - if (!registration->is_uninstalled() &&
|
| - ServiceWorkerUtils::ScopeMatches(registration->pattern(),
|
| - document_url_))
|
| - AddMatchingRegistration(registration);
|
| - }
|
| -}
|
| -
|
| ServiceWorkerRegistration*
|
| ServiceWorkerProviderHost::MatchRegistration() const {
|
| ServiceWorkerRegistrationMap::const_reverse_iterator it =
|
| @@ -601,6 +587,28 @@ void ServiceWorkerProviderHost::SendAssociateRegistrationMessage() {
|
| render_thread_id_, provider_id(), handle->GetObjectInfo(), attrs));
|
| }
|
|
|
| +void ServiceWorkerProviderHost::SyncMatchingRegistrations() {
|
| + DCHECK(context_);
|
| + RemoveAllMatchingRegistrations();
|
| + const auto& registrations = context_->GetLiveRegistrations();
|
| + for (const auto& key_registration : registrations) {
|
| + ServiceWorkerRegistration* registration = key_registration.second;
|
| + if (!registration->is_uninstalled() &&
|
| + ServiceWorkerUtils::ScopeMatches(registration->pattern(),
|
| + document_url_))
|
| + AddMatchingRegistration(registration);
|
| + }
|
| +}
|
| +
|
| +void ServiceWorkerProviderHost::RemoveAllMatchingRegistrations() {
|
| + for (const auto& it : matching_registrations_) {
|
| + ServiceWorkerRegistration* registration = it.second.get();
|
| + DecreaseProcessReference(registration->pattern());
|
| + registration->RemoveListener(this);
|
| + }
|
| + matching_registrations_.clear();
|
| +}
|
| +
|
| void ServiceWorkerProviderHost::IncreaseProcessReference(
|
| const GURL& pattern) {
|
| if (context_ && context_->process_manager()) {
|
|
|