OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/background_sync/background_sync_manager.h" | 5 #include "content/browser/background_sync/background_sync_manager.h" |
6 | 6 |
7 #include "base/barrier_closure.h" | 7 #include "base/barrier_closure.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 const std::string& backend_key, | 527 const std::string& backend_key, |
528 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& | 528 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& |
529 callback) { | 529 callback) { |
530 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 530 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
531 | 531 |
532 service_worker_context_->GetUserDataForAllRegistrations(backend_key, | 532 service_worker_context_->GetUserDataForAllRegistrations(backend_key, |
533 callback); | 533 callback); |
534 } | 534 } |
535 | 535 |
536 void BackgroundSyncManager::FireOneShotSync( | 536 void BackgroundSyncManager::FireOneShotSync( |
| 537 BackgroundSyncRegistration* registration, |
537 const scoped_refptr<ServiceWorkerVersion>& active_version, | 538 const scoped_refptr<ServiceWorkerVersion>& active_version, |
538 const ServiceWorkerVersion::StatusCallback& callback) { | 539 const ServiceWorkerVersion::StatusCallback& callback) { |
539 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 540 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
540 | 541 |
541 active_version->DispatchSyncEvent(callback); | 542 active_version->DispatchSyncEvent( |
| 543 mojo::ConvertTo<SyncRegistrationPtr>(*registration), callback); |
542 } | 544 } |
543 | 545 |
544 void BackgroundSyncManager::UnregisterImpl( | 546 void BackgroundSyncManager::UnregisterImpl( |
545 int64 sw_registration_id, | 547 int64 sw_registration_id, |
546 const RegistrationKey& registration_key, | 548 const RegistrationKey& registration_key, |
547 BackgroundSyncRegistration::RegistrationId sync_registration_id, | 549 BackgroundSyncRegistration::RegistrationId sync_registration_id, |
548 const StatusCallback& callback) { | 550 const StatusCallback& callback) { |
549 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 551 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
550 | 552 |
551 if (disabled_) { | 553 if (disabled_) { |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 const scoped_refptr<ServiceWorkerRegistration>& | 770 const scoped_refptr<ServiceWorkerRegistration>& |
769 service_worker_registration) { | 771 service_worker_registration) { |
770 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 772 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
771 | 773 |
772 if (service_worker_status != SERVICE_WORKER_OK) { | 774 if (service_worker_status != SERVICE_WORKER_OK) { |
773 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 775 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
774 base::Bind(callback)); | 776 base::Bind(callback)); |
775 return; | 777 return; |
776 } | 778 } |
777 | 779 |
| 780 BackgroundSyncRegistration* registration = |
| 781 LookupRegistration(service_worker_registration->id(), registration_key); |
| 782 |
778 FireOneShotSync( | 783 FireOneShotSync( |
779 service_worker_registration->active_version(), | 784 registration, service_worker_registration->active_version(), |
780 base::Bind(&BackgroundSyncManager::EventComplete, | 785 base::Bind(&BackgroundSyncManager::EventComplete, |
781 weak_ptr_factory_.GetWeakPtr(), service_worker_registration, | 786 weak_ptr_factory_.GetWeakPtr(), service_worker_registration, |
782 service_worker_registration->id(), registration_key, | 787 service_worker_registration->id(), registration_key, |
783 registration_id)); | 788 registration_id)); |
784 | 789 |
785 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 790 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
786 base::Bind(callback)); | 791 base::Bind(callback)); |
787 } | 792 } |
788 | 793 |
789 // |service_worker_registration| is just to keep the registration alive | 794 // |service_worker_registration| is just to keep the registration alive |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 BackgroundSyncManager::MakeStatusCompletion(const StatusCallback& callback) { | 952 BackgroundSyncManager::MakeStatusCompletion(const StatusCallback& callback) { |
948 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 953 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
949 | 954 |
950 return base::Bind( | 955 return base::Bind( |
951 &BackgroundSyncManager::CompleteOperationCallback<StatusCallback, | 956 &BackgroundSyncManager::CompleteOperationCallback<StatusCallback, |
952 ErrorType>, | 957 ErrorType>, |
953 weak_ptr_factory_.GetWeakPtr(), callback); | 958 weak_ptr_factory_.GetWeakPtr(), callback); |
954 } | 959 } |
955 | 960 |
956 } // namespace content | 961 } // namespace content |
OLD | NEW |