OLD | NEW |
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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 282 |
283 void ServiceWorkerProviderHost::AddMatchingRegistration( | 283 void ServiceWorkerProviderHost::AddMatchingRegistration( |
284 ServiceWorkerRegistration* registration) { | 284 ServiceWorkerRegistration* registration) { |
285 // TODO(shimazu): Change CHECK to DCHECK after https://crbug.com/634222 is | 285 // TODO(shimazu): Change CHECK to DCHECK after https://crbug.com/634222 is |
286 // fixed. | 286 // fixed. |
287 CHECK( | 287 CHECK( |
288 ServiceWorkerUtils::ScopeMatches(registration->pattern(), document_url_)); | 288 ServiceWorkerUtils::ScopeMatches(registration->pattern(), document_url_)); |
289 if (!IsContextSecureForServiceWorker()) | 289 if (!IsContextSecureForServiceWorker()) |
290 return; | 290 return; |
291 size_t key = registration->pattern().spec().size(); | 291 size_t key = registration->pattern().spec().size(); |
292 if (ContainsKey(matching_registrations_, key)) | 292 if (base::ContainsKey(matching_registrations_, key)) |
293 return; | 293 return; |
294 IncreaseProcessReference(registration->pattern()); | 294 IncreaseProcessReference(registration->pattern()); |
295 registration->AddListener(this); | 295 registration->AddListener(this); |
296 matching_registrations_[key] = registration; | 296 matching_registrations_[key] = registration; |
297 ReturnRegistrationForReadyIfNeeded(); | 297 ReturnRegistrationForReadyIfNeeded(); |
298 } | 298 } |
299 | 299 |
300 void ServiceWorkerProviderHost::RemoveMatchingRegistration( | 300 void ServiceWorkerProviderHost::RemoveMatchingRegistration( |
301 ServiceWorkerRegistration* registration) { | 301 ServiceWorkerRegistration* registration) { |
302 size_t key = registration->pattern().spec().size(); | 302 size_t key = registration->pattern().spec().size(); |
303 DCHECK(ContainsKey(matching_registrations_, key)); | 303 DCHECK(base::ContainsKey(matching_registrations_, key)); |
304 DecreaseProcessReference(registration->pattern()); | 304 DecreaseProcessReference(registration->pattern()); |
305 registration->RemoveListener(this); | 305 registration->RemoveListener(this); |
306 matching_registrations_.erase(key); | 306 matching_registrations_.erase(key); |
307 } | 307 } |
308 | 308 |
309 void ServiceWorkerProviderHost::AddAllMatchingRegistrations() { | 309 void ServiceWorkerProviderHost::AddAllMatchingRegistrations() { |
310 DCHECK(context_); | 310 DCHECK(context_); |
311 const std::map<int64_t, ServiceWorkerRegistration*>& registrations = | 311 const std::map<int64_t, ServiceWorkerRegistration*>& registrations = |
312 context_->GetLiveRegistrations(); | 312 context_->GetLiveRegistrations(); |
313 for (const auto& key_registration : registrations) { | 313 for (const auto& key_registration : registrations) { |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 Send(new ServiceWorkerMsg_SetControllerServiceWorker( | 665 Send(new ServiceWorkerMsg_SetControllerServiceWorker( |
666 render_thread_id_, provider_id(), | 666 render_thread_id_, provider_id(), |
667 GetOrCreateServiceWorkerHandle( | 667 GetOrCreateServiceWorkerHandle( |
668 associated_registration_->active_version()), | 668 associated_registration_->active_version()), |
669 false /* shouldNotifyControllerChange */)); | 669 false /* shouldNotifyControllerChange */)); |
670 } | 670 } |
671 } | 671 } |
672 } | 672 } |
673 | 673 |
674 } // namespace content | 674 } // namespace content |
OLD | NEW |