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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 const std::string& backend_key, | 575 const std::string& backend_key, |
576 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& | 576 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& |
577 callback) { | 577 callback) { |
578 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 578 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
579 | 579 |
580 service_worker_context_->GetUserDataForAllRegistrations(backend_key, | 580 service_worker_context_->GetUserDataForAllRegistrations(backend_key, |
581 callback); | 581 callback); |
582 } | 582 } |
583 | 583 |
584 void BackgroundSyncManager::FireOneShotSync( | 584 void BackgroundSyncManager::FireOneShotSync( |
| 585 const BackgroundSyncRegistration& registration, |
585 const scoped_refptr<ServiceWorkerVersion>& active_version, | 586 const scoped_refptr<ServiceWorkerVersion>& active_version, |
586 const ServiceWorkerVersion::StatusCallback& callback) { | 587 const ServiceWorkerVersion::StatusCallback& callback) { |
587 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 588 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
588 | 589 |
589 active_version->DispatchSyncEvent(callback); | 590 active_version->DispatchSyncEvent( |
| 591 mojo::ConvertTo<SyncRegistrationPtr>(registration), callback); |
590 } | 592 } |
591 | 593 |
592 void BackgroundSyncManager::UnregisterImpl( | 594 void BackgroundSyncManager::UnregisterImpl( |
593 int64 sw_registration_id, | 595 int64 sw_registration_id, |
594 const RegistrationKey& registration_key, | 596 const RegistrationKey& registration_key, |
595 BackgroundSyncRegistration::RegistrationId sync_registration_id, | 597 BackgroundSyncRegistration::RegistrationId sync_registration_id, |
596 SyncPeriodicity periodicity, | 598 SyncPeriodicity periodicity, |
597 const StatusCallback& callback) { | 599 const StatusCallback& callback) { |
598 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 600 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
599 | 601 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 service_worker_registration) { | 839 service_worker_registration) { |
838 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 840 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
839 if (service_worker_status != SERVICE_WORKER_OK) { | 841 if (service_worker_status != SERVICE_WORKER_OK) { |
840 base::ThreadTaskRunnerHandle::Get()->PostTask( | 842 base::ThreadTaskRunnerHandle::Get()->PostTask( |
841 FROM_HERE, base::Bind(event_fired_callback)); | 843 FROM_HERE, base::Bind(event_fired_callback)); |
842 base::ThreadTaskRunnerHandle::Get()->PostTask( | 844 base::ThreadTaskRunnerHandle::Get()->PostTask( |
843 FROM_HERE, base::Bind(event_completed_callback)); | 845 FROM_HERE, base::Bind(event_completed_callback)); |
844 return; | 846 return; |
845 } | 847 } |
846 | 848 |
| 849 BackgroundSyncRegistration* registration = |
| 850 LookupRegistration(service_worker_registration->id(), registration_key); |
| 851 |
847 FireOneShotSync( | 852 FireOneShotSync( |
848 service_worker_registration->active_version(), | 853 *registration, service_worker_registration->active_version(), |
849 base::Bind(&BackgroundSyncManager::EventComplete, | 854 base::Bind(&BackgroundSyncManager::EventComplete, |
850 weak_ptr_factory_.GetWeakPtr(), service_worker_registration, | 855 weak_ptr_factory_.GetWeakPtr(), service_worker_registration, |
851 service_worker_registration->id(), registration_key, | 856 service_worker_registration->id(), registration_key, |
852 registration_id, event_completed_callback)); | 857 registration_id, event_completed_callback)); |
853 | 858 |
854 base::ThreadTaskRunnerHandle::Get()->PostTask( | 859 base::ThreadTaskRunnerHandle::Get()->PostTask( |
855 FROM_HERE, base::Bind(event_fired_callback)); | 860 FROM_HERE, base::Bind(event_fired_callback)); |
856 } | 861 } |
857 | 862 |
858 // |service_worker_registration| is just to keep the registration alive | 863 // |service_worker_registration| is just to keep the registration alive |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 BackgroundSyncManager::MakeStatusCompletion(const StatusCallback& callback) { | 1041 BackgroundSyncManager::MakeStatusCompletion(const StatusCallback& callback) { |
1037 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1042 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1038 | 1043 |
1039 return base::Bind( | 1044 return base::Bind( |
1040 &BackgroundSyncManager::CompleteOperationCallback<StatusCallback, | 1045 &BackgroundSyncManager::CompleteOperationCallback<StatusCallback, |
1041 ErrorType>, | 1046 ErrorType>, |
1042 weak_ptr_factory_.GetWeakPtr(), callback); | 1047 weak_ptr_factory_.GetWeakPtr(), callback); |
1043 } | 1048 } |
1044 | 1049 |
1045 } // namespace content | 1050 } // namespace content |
OLD | NEW |