| 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_context_core.h" | 5 #include "content/browser/service_worker/service_worker_context_core.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 const base::FilePath& path, | 213 const base::FilePath& path, |
| 214 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, | 214 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, |
| 215 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, | 215 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, |
| 216 storage::QuotaManagerProxy* quota_manager_proxy, | 216 storage::QuotaManagerProxy* quota_manager_proxy, |
| 217 storage::SpecialStoragePolicy* special_storage_policy, | 217 storage::SpecialStoragePolicy* special_storage_policy, |
| 218 base::ObserverListThreadSafe<ServiceWorkerContextObserver>* observer_list, | 218 base::ObserverListThreadSafe<ServiceWorkerContextObserver>* observer_list, |
| 219 ServiceWorkerContextWrapper* wrapper) | 219 ServiceWorkerContextWrapper* wrapper) |
| 220 : wrapper_(wrapper), | 220 : wrapper_(wrapper), |
| 221 providers_(new ProcessToProviderMap), | 221 providers_(new ProcessToProviderMap), |
| 222 provider_by_uuid_(new ProviderByClientUUIDMap), | 222 provider_by_uuid_(new ProviderByClientUUIDMap), |
| 223 force_update_on_page_load_(false), |
| 223 next_handle_id_(0), | 224 next_handle_id_(0), |
| 224 next_registration_handle_id_(0), | 225 next_registration_handle_id_(0), |
| 225 was_service_worker_registered_(false), | 226 was_service_worker_registered_(false), |
| 226 observer_list_(observer_list), | 227 observer_list_(observer_list), |
| 227 weak_factory_(this) { | 228 weak_factory_(this) { |
| 228 // These get a WeakPtr from weak_factory_, so must be set after weak_factory_ | 229 // These get a WeakPtr from weak_factory_, so must be set after weak_factory_ |
| 229 // is initialized. | 230 // is initialized. |
| 230 storage_ = ServiceWorkerStorage::Create( | 231 storage_ = ServiceWorkerStorage::Create( |
| 231 path, AsWeakPtr(), std::move(database_task_manager), disk_cache_thread, | 232 path, AsWeakPtr(), std::move(database_task_manager), disk_cache_thread, |
| 232 quota_manager_proxy, special_storage_policy); | 233 quota_manager_proxy, special_storage_policy); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 bool skip_script_comparison, | 392 bool skip_script_comparison, |
| 392 ServiceWorkerProviderHost* provider_host, | 393 ServiceWorkerProviderHost* provider_host, |
| 393 const UpdateCallback& callback) { | 394 const UpdateCallback& callback) { |
| 394 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 395 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 395 job_coordinator_->Update(registration, force_bypass_cache, | 396 job_coordinator_->Update(registration, force_bypass_cache, |
| 396 skip_script_comparison, provider_host, | 397 skip_script_comparison, provider_host, |
| 397 base::Bind(&ServiceWorkerContextCore::UpdateComplete, | 398 base::Bind(&ServiceWorkerContextCore::UpdateComplete, |
| 398 AsWeakPtr(), callback)); | 399 AsWeakPtr(), callback)); |
| 399 } | 400 } |
| 400 | 401 |
| 401 void ServiceWorkerContextCore::SetForceUpdateOnPageLoad( | |
| 402 int64_t registration_id, | |
| 403 bool force_update_on_page_load) { | |
| 404 ServiceWorkerRegistration* registration = | |
| 405 GetLiveRegistration(registration_id); | |
| 406 if (!registration) | |
| 407 return; | |
| 408 registration->set_force_update_on_page_load(force_update_on_page_load); | |
| 409 | |
| 410 if (observer_list_.get()) { | |
| 411 observer_list_->Notify( | |
| 412 FROM_HERE, | |
| 413 &ServiceWorkerContextObserver::OnForceUpdateOnPageLoadChanged, | |
| 414 registration_id, force_update_on_page_load); | |
| 415 } | |
| 416 } | |
| 417 | |
| 418 void ServiceWorkerContextCore::UnregisterServiceWorker( | 402 void ServiceWorkerContextCore::UnregisterServiceWorker( |
| 419 const GURL& pattern, | 403 const GURL& pattern, |
| 420 const UnregistrationCallback& callback) { | 404 const UnregistrationCallback& callback) { |
| 421 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 405 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 422 job_coordinator_->Unregister( | 406 job_coordinator_->Unregister( |
| 423 pattern, | 407 pattern, |
| 424 base::Bind(&ServiceWorkerContextCore::UnregistrationComplete, | 408 base::Bind(&ServiceWorkerContextCore::UnregistrationComplete, |
| 425 AsWeakPtr(), | 409 AsWeakPtr(), |
| 426 pattern, | 410 pattern, |
| 427 callback)); | 411 callback)); |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 } | 837 } |
| 854 | 838 |
| 855 void ServiceWorkerContextCore::OnRegistrationFinishedForCheckHasServiceWorker( | 839 void ServiceWorkerContextCore::OnRegistrationFinishedForCheckHasServiceWorker( |
| 856 const ServiceWorkerContext::CheckHasServiceWorkerCallback callback, | 840 const ServiceWorkerContext::CheckHasServiceWorkerCallback callback, |
| 857 const scoped_refptr<ServiceWorkerRegistration>& registration) { | 841 const scoped_refptr<ServiceWorkerRegistration>& registration) { |
| 858 callback.Run(registration->active_version() || | 842 callback.Run(registration->active_version() || |
| 859 registration->waiting_version()); | 843 registration->waiting_version()); |
| 860 } | 844 } |
| 861 | 845 |
| 862 } // namespace content | 846 } // namespace content |
| OLD | NEW |