Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: content/browser/service_worker/service_worker_provider_host.cc

Issue 1181573010: ServiceWorker: Fix matching registration info missing during shift-reload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/service_worker_provider_host.h" 5 #include "content/browser/service_worker/service_worker_provider_host.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "content/browser/frame_host/frame_tree.h" 9 #include "content/browser/frame_host/frame_tree.h"
10 #include "content/browser/frame_host/frame_tree_node.h" 10 #include "content/browser/frame_host/frame_tree_node.h"
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 286
287 void ServiceWorkerProviderHost::RemoveMatchingRegistration( 287 void ServiceWorkerProviderHost::RemoveMatchingRegistration(
288 ServiceWorkerRegistration* registration) { 288 ServiceWorkerRegistration* registration) {
289 size_t key = registration->pattern().spec().size(); 289 size_t key = registration->pattern().spec().size();
290 DCHECK(ContainsKey(matching_registrations_, key)); 290 DCHECK(ContainsKey(matching_registrations_, key));
291 DecreaseProcessReference(registration->pattern()); 291 DecreaseProcessReference(registration->pattern());
292 registration->RemoveListener(this); 292 registration->RemoveListener(this);
293 matching_registrations_.erase(key); 293 matching_registrations_.erase(key);
294 } 294 }
295 295
296 void ServiceWorkerProviderHost::AddAllMatchingRegistrations() {
297 DCHECK(context_);
298 const std::map<int64, ServiceWorkerRegistration*>& registrations =
299 context_->GetLiveRegistrations();
300 for (const auto& key_registration : registrations) {
301 ServiceWorkerRegistration* registration = key_registration.second;
302 if (!registration->is_uninstalled() &&
303 ServiceWorkerUtils::ScopeMatches(registration->pattern(),
304 document_url_))
305 AddMatchingRegistration(registration);
306 }
307 }
308
296 ServiceWorkerRegistration* 309 ServiceWorkerRegistration*
297 ServiceWorkerProviderHost::MatchRegistration() const { 310 ServiceWorkerProviderHost::MatchRegistration() const {
298 ServiceWorkerRegistrationMap::const_reverse_iterator it = 311 ServiceWorkerRegistrationMap::const_reverse_iterator it =
299 matching_registrations_.rbegin(); 312 matching_registrations_.rbegin();
300 for (; it != matching_registrations_.rend(); ++it) { 313 for (; it != matching_registrations_.rend(); ++it) {
301 if (it->second->is_uninstalled()) 314 if (it->second->is_uninstalled())
302 continue; 315 continue;
303 if (it->second->is_uninstalling()) 316 if (it->second->is_uninstalling())
304 return nullptr; 317 return nullptr;
305 return it->second.get(); 318 return it->second.get();
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 return context_ != NULL; 673 return context_ != NULL;
661 } 674 }
662 675
663 void ServiceWorkerProviderHost::Send(IPC::Message* message) const { 676 void ServiceWorkerProviderHost::Send(IPC::Message* message) const {
664 DCHECK(dispatcher_host_); 677 DCHECK(dispatcher_host_);
665 DCHECK(IsReadyToSendMessages()); 678 DCHECK(IsReadyToSendMessages());
666 dispatcher_host_->Send(message); 679 dispatcher_host_->Send(message);
667 } 680 }
668 681
669 } // namespace content 682 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698